diff --git a/Basic/Primitive/primitive.pd b/Basic/Primitive/primitive.pd index 25e29dc72..cd70e024d 100644 --- a/Basic/Primitive/primitive.pd +++ b/Basic/Primitive/primitive.pd @@ -3587,6 +3587,7 @@ PDL_IF_BAD( if ((got_badflag && $ISBAD(got())) && (exp_badflag && $ISBADVAR(expctd,expected))) { $result() = 1; continue; } if ((got_badflag && $ISBAD(got())) || (exp_badflag && $ISBADVAR(expctd,expected))) { $result() = 0; continue; } ,) +if ($got() == expctd) { $result() = 1; continue; } $GENERIC() diff = $got() - expctd; double abs_diff2 = PDL_IF_GENTYPE_REAL( diff * diff, diff --git a/Basic/t/core.t b/Basic/t/core.t index a03f360d4..3844e19b1 100644 --- a/Basic/t/core.t +++ b/Basic/t/core.t @@ -378,9 +378,9 @@ is_pdl pdl([1], pdl[2,3,4], pdl[5]), pdl([[[1,0,0],[0,0,0]],[[2,3,4],[5,0,0]]]), is_pdl $c, pdl([1,0,0],[2,3,4]), "implicit, undefval of undef falls back to 0"; $PDL::undefval = inf; $c = pdl undef; - ok all($c == inf), "explicit, undefval of PDL scalar works" or diag("c=$c\n"); + is_pdl $c, inf, "explicit, undefval of PDL scalar works"; $c = pdl [1], [2,3,4]; - ok all($c == pdl([1,inf,inf],[2,3,4])), "implicit, undefval of a PDL scalar works" or diag("c=$c\n"); + is_pdl $c, pdl([1,inf,inf],[2,3,4]), {rtol=>0, test_name=>"implicit, undefval of a PDL scalar works"}; } { diff --git a/Basic/t/primitive-misc.t b/Basic/t/primitive-misc.t index c968b4424..a746e79f8 100644 --- a/Basic/t/primitive-misc.t +++ b/Basic/t/primitive-misc.t @@ -76,6 +76,12 @@ subtest approx_artol => sub { $got_a = $fgot->approx_artol($fexpected, 1e-6); $exp_a_mask = pdl('1 1 1 0 0 1'); ok all($got_a == $exp_a_mask), 'bad values pattern' or diag "got=$got_a\nexp=$exp_a_mask"; + $got_a = inf(1)->approx_artol(inf(1)); + $exp_a_mask = pdl([1]); + ok all($got_a == $exp_a_mask), 'inf matches inf' or diag "got=$got_a\nexp=$exp_a_mask"; + $got_a = pdl('inf bad')->approx_artol(pdl('inf bad')); + $exp_a_mask = pdl([1,1]); + ok all($got_a == $exp_a_mask), 'inf,bad matches inf,bad' or diag "got=$got_a\nexp=$exp_a_mask"; }; done_testing; diff --git a/Basic/t/tp-is_pdl.t b/Basic/t/tp-is_pdl.t index 097910f9a..88ebb5e60 100644 --- a/Basic/t/tp-is_pdl.t +++ b/Basic/t/tp-is_pdl.t @@ -203,6 +203,8 @@ test_test( 'custom test name is also displayed correctly when supplied as an opt # error is raised. throws_ok { is_pdl( $got, $expected, pdl(1,1,1,1) ) } qr/^error in arguments: third argument is an ndarray at /, 'third argument is an ndarray'; +throws_ok { is_pdl( $got, $expected, 1e-4, "label" ) } + qr/^error in arguments: > 3 given/, '>3 argument given'; $expected = long( 4,5,6,7,8,9 ); $expected->badflag( 1 );