unit testing - Converting datatypes for failing test function in Perl? -
minimum code
use strict; use warnings; use v5.16; use test::more tests => 2; is_deeply( [ [0, 0], [1, 0] ], [ [0, 0], [1, 0] ], 'intersects x-axis @ (0, 0) , (1, 0)' ); is_deeply( ( [0, 0], [1, 0] ), ( [0, 0], [1, 0] ), 'intersects x-axis @ (0, 0) , (1, 0)' );
which returns
ok 1 - intersects x-axis @ (0, 0) , (1, 0) is_deeply() takes 2 or 3 args, gave 5. means passed array or hash instead of reference @ test44.pl line 14 not ok 2 # failed test @ test44.pl line 14. # looks failed 1 test of 2 run.
the first code succeeds [[-,-],[-,-]]
entries second fails ([-,-],[-,-])
entries. function returns ([-,-], [-,-])
want test if on x-axis.
there many args test, reason why test fails. conversion may needed. however, data chunks big no duplication of data not idea because of speed.
how can proceed testing such data ([-,-],[-,-])
fit expected result efficiently?
use anonymous arrays, each 1 of them interpreted 1 argument:
is_deeply( [ [0, 0], [1, 0] ], [ [0, 0], [1, 0] ], 'intersects x-axis @ (0, 0) , (1, 0)' );
the parentheses in original code nothing, lists flattened, i.e. code equivalent to
is_deeply( [0, 0], [1, 0], [0, 0], [1, 0], 'intersects x-axis @ (0, 0) , (1, 0)' );
5 arguments is_deeply
.
Comments
Post a Comment