Skip to content

Commit 614e658

Browse files
committed
zap remaining misuse of all,== from tests - #34
1 parent 6a5c48d commit 614e658

14 files changed

+76
-89
lines changed

t/fft.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ foreach my $type(double,float,cdouble,cfloat){
1010
my $pa = pdl($type,1,-1,1,-1);
1111
my $pb = zeroes($type,$pa->dims);
1212
fft($pa,$pb);
13-
ok(all($pa==pdl($type,0,0,4,0)), "fft for type $type");
13+
is_pdl $pa, pdl($type,0,0,4,0), "fft for type $type";
1414
ifft($pa,$pb);
15-
ok(all($pa==pdl($type,1,-1,1,-1)), "ifft for type $type");
15+
is_pdl $pa, pdl($type,1,-1,1,-1), "ifft for type $type";
1616
}
1717

1818
my $pa = rfits("lib/PDL/Demos/m51.fits");

t/fits.t

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ wfits($t, $file);
2929
$t2 = rfits $file;
3030
is_pdl $t2, $t, 'w/rfits round-trip';
3131
my $h = $t2->gethdr;
32-
ok( $$h{FOO} eq "foo" && $$h{BAR} == 42,
33-
"header check on FOO/BAR" );
34-
ok( $$h{'NUM'}+1 == 124 && $$h{'NUMSTR'} eq '0123',
35-
"header check on NUM/NUMSTR" );
32+
is $$h{FOO}, "foo", "header check on FOO";
33+
is $$h{BAR}, 42, "header check on BAR";
34+
is $$h{'NUM'}+1, 124, "header check on NUM";
35+
is $$h{'NUMSTR'}, '0123', "header check on NUMSTR";
3636
unlink $file;
3737

3838
SKIP: {
@@ -227,7 +227,7 @@ SKIP:{
227227
unlink $file;
228228
wfits($ar,$file);
229229
my $y = rfits($file);
230-
ok(all($ar==$y),"fftnd output (non-contiguous in memory) is written correctly");
230+
is_pdl $ar, $y, "fftnd output (non-contiguous in memory) is written correctly";
231231
unlink $file;
232232
}
233233

@@ -243,11 +243,8 @@ lives_ok { wfits([$x,$y],$file) } "wfits with multiple HDUs didn't fail";
243243

244244
lives_ok { @aa = rfits($file) } "rfits in list context didn't fail";
245245

246-
ok( $aa[0]->ndims == $x->ndims && all($aa[0]->shape == $x->shape), "first element has right shape");
247-
ok( all($aa[0] == $x), "first element reproduces written one");
248-
249-
ok( $aa[1]->ndims == $y->ndims && all($aa[1]->shape == $y->shape), "second element has right shape");
250-
ok( all($aa[1] == $y), "Second element reproduces written one");
246+
is_pdl $aa[0], $x, "first element reproduces written one";
247+
is_pdl $aa[1], $y, "Second element reproduces written one";
251248

252249
unlink $file;
253250

@@ -263,9 +260,9 @@ SKIP:{
263260
is $@, '', "writing a longlong image succeeded";
264261
eval { $y = rfits($file); };
265262
is $@, '', "Reading the longlong image succeeded";
266-
ok(ref($y->hdr) eq "HASH", "Reading the longlong image produced a PDL with a hash header");
267-
ok($y->hdr->{BITPIX} == 64, "BITPIX value was correct");
268-
ok(all($y==$x),"The new image matches the old one (longlong)");
263+
isa_ok $y->hdr, "HASH", "Reading the longlong image produced a PDL with a hash header";
264+
is $y->hdr->{BITPIX}, 64, "BITPIX value was correct";
265+
is_pdl $y, $x, "The new image matches the old one (longlong)";
269266
unlink $file;
270267
}
271268

t/flexraw-iotypes.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use PDL::Types ':All';
55
use PDL::IO::FlexRaw;
66
use File::Temp;
77
use Test::More;
8+
use Test::PDL;
89

910
our @types = grep $_ != indx(), types();
1011

@@ -17,7 +18,7 @@ for my $type (@types) {
1718
writeflexhdr($data,$hdr);
1819
my $npdl = eval {readflex $data};
1920
is $pdl->type, $npdl->type;
20-
ok all $pdl == $npdl;
21+
is_pdl $pdl, $npdl;
2122
}
2223

2324
unlink $data, "${data}.hdr";

t/inlinepdlpp.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use strict;
22
use warnings;
33
use Test::More;
4+
use Test::PDL;
45

56
BEGIN {
67
my $inline_test_dir = './.inlinepdlpp';
@@ -33,7 +34,7 @@ is $@, '', 'bind no error';
3334
my $x = sequence(3,3);
3435
my $y = $x->testinc;
3536
is myshape($x), myshape($y), 'myshape eq';
36-
ok(all $y == $x+1, '==');
37+
is_pdl $y, $x+1;
3738

3839
sub myshape { join ',', $_[0]->dims }
3940

t/io-pnm.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sub rpnm_unlink {
2121
close $fh;
2222
open $fh, '<', $file;
2323
my $pdl2 = rpnm($fh);
24-
ok all($pdl == $pdl2), 'rpnm from fh same as from disk file';
24+
is_pdl $pdl, $pdl2, 'rpnm from fh same as from disk file';
2525
unlink $file;
2626
return $pdl;
2727
}

t/niceslice.t

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use strict;
22
use warnings;
33
use Test::More;
4+
use Test::PDL;
45
use PDL::LiteF;
56
#BEGIN { $PDL::NiceSlice::debug = $PDL::NiceSlice::debug_filter = 1 }
67
require PDL::NiceSlice;
@@ -42,44 +43,42 @@ $pb = translate_and_run '$pa->((5));';
4243
cmp_ok($pb->at, '==', 5);
4344

4445
$pb = translate_and_run '$pa(($c(1)->at(0)));';
45-
is $pb->getndims, 0;
46-
ok(all $pb == 6);
46+
is_pdl $pb, pdl(6);
4747

4848
# the latest versions should do the 'at' automatically
4949
$pb = translate_and_run '$pa(($c(1)));';
50-
is $pb->getndims, 0;
51-
ok(all $pb == 6);
50+
is_pdl $pb, pdl(6);
5251

5352
$c = translate_and_run '$pa(:);';
54-
ok ($c->getdim(0) == 10 && all $c == $pa);
53+
is_pdl $c, $pa;
5554

5655
$pb = translate_and_run '$pa($idx);';
57-
ok(all $pb == $idx);
56+
is_pdl $pb, $idx;
5857

5958
# use 1-el ndarrays as indices
6059
my $cmp = pdl(2,4,6);
6160
$pb = translate_and_run '$pa($rg(0):$rg(1):$rg(2));';
62-
ok(all $pb == $cmp);
61+
is_pdl $pb, $cmp;
6362

6463
# mix ranges and index ndarrays
6564
$pa = sequence 5,5;
6665
$idx = pdl 2,3,0;
6766
$cmp = $pa->slice('-1:0')->dice_axis(1,$idx);
6867
translate_and_run '$pb = $pa(-1:0,$idx);';
69-
ok(all $pb == $cmp);
68+
is_pdl $pb, $cmp;
7069

7170
#
7271
# modifiers
7372
#
7473

7574
$pa = sequence 10;
7675
$pb = translate_and_run '$pa($pa<3;?)' ;
77-
ok(all $pb == pdl(0,1,2));
76+
is_pdl $pb, pdl(0,1,2);
7877

7978
# flat modifier
8079
$pa = sequence 3,3;
8180
$pb = translate_and_run '$pa(0:-2;_);';
82-
ok(all $pb == sequence 8);
81+
is_pdl $pb, sequence 8;
8382

8483
# where modifier cannot be mixed with other modifiers
8584
$pa = sequence 10;
@@ -89,28 +88,28 @@ $pb = translate_and_run '$pa($pa<3;?_)', qr/more than 1/;
8988
$pa = sequence 3,3;
9089
$pb = translate_and_run '$pa(0;-|)';
9190
eval {$pb++};
92-
ok($pb->dim(0) == 3 && all $pb == 3*sequence(3)+1) or diag $pb;
91+
is_pdl $pb, 3*sequence(3)+1;
9392
ok($pa->at(0,0) == 0) or diag $pa;
9493

95-
# do we ignore whitspace correctly?
94+
# do we ignore whitespace correctly?
9695
$c = translate_and_run '$pa(0; - | )';
97-
ok (all $c == $pb-1);
96+
is_pdl $c, $pb-1;
9897

9998
# empty modifier block
10099
$pa = sequence 10;
101100
$pb = translate_and_run '$pa(0; )';
102-
ok ($pb == $pa->at(0));
101+
is $pb, $pa->at(0);
103102

104103
# modifiers repeated
105104
$pb = translate_and_run '$pa(0;-||)', qr/twice or more/;
106105

107106
$pa = sequence(3);
108107
translate_and_run 'my $x = 1 / 2; $pa = $pa((2)); $x =~ /\./;';
109-
is $pa.'', '2', '/ not treated as starting a regex';
108+
is_pdl $pa, pdl(2), '/ not treated as starting a regex';
110109

111110
$pa = sequence(3);
112111
translate_and_run 'my $x = (0.5 + 0.5) / 2; $pa = $pa((2)); $x =~ /\./;';
113-
is $pa.'', '2', '/ not treated as starting a regex even after paren';
112+
is_pdl $pa, pdl(2), '/ not treated as starting a regex even after paren';
114113

115114
# foreach/for blocking
116115

t/pic-rim.t

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use warnings;
33
use PDL::LiteF;
44
use PDL::IO::Pic;
55
use Test::More;
6+
use Test::PDL;
67
use File::Temp qw(tempdir);
78
use File::Spec;
89

@@ -24,11 +25,7 @@ sub test_pdl {
2425
rim($out2, $file, {FORMAT => $fmt});
2526
my $out3 = PDL->rpic($file, {FORMAT => $fmt});
2627
if ($expect_reorder) { $_ = $_->mv(-1,0) for $out1, $out2 }
27-
eval {ok all($out1 == $in), "\$out1 & \$in are the same $orig_info"};
28-
is $@, '', $orig_info;
29-
eval {ok all($out2 == $in), "\$out2 & \$in are the same $orig_info"};
30-
is $@, '', $orig_info;
31-
eval {ok all($out3 == $in), "\$out3 & \$in are the same $orig_info"}
32-
or diag "in=$in\nout1=$out1";
33-
is $@, '', $orig_info;
28+
is_pdl $out1, $in, "\$out1 & \$in are the same $orig_info";
29+
is_pdl $out2, $in, "\$out2 & \$in are the same $orig_info";
30+
is_pdl $out3, $in, "\$out3 & \$in are the same $orig_info";
3431
}

t/pic_16bit.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use strict;
22
use warnings;
33
use Test::More;
4+
use Test::PDL;
45
use File::Temp qw(tempdir);
56
use File::Spec;
67
use PDL::LiteF;
@@ -20,8 +21,7 @@ sub roundtrip {
2021
$in->wpic($file);
2122
my $got = rpic($file, @extra);
2223
return is_deeply [$got->dims], [$in->dims] if $dimonly;
23-
eval {ok all($in == $got), "$label image save+restore"};
24-
is $@, '', "$label compare worked";
24+
is_pdl $got, $in, {require_equal_types=>0, test_name=>"$label image save+restore"};
2525
}
2626

2727
# test save/restore of 8-bit image

t/ppt-02_non_threaded.t

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use strict;
33
use warnings;
44

55
# Test declaration
6-
use Test::More tests => 9;
6+
use Test::More;
7+
use Test::PDL -atol => 0;
78

89
# Modules needed for actual testing
910
use PDL::LiteF;
@@ -18,23 +19,11 @@ use PDL::Parallel::threads qw(retrieve_pdls);
1819
# something nontrivial across all its bits.
1920
my $data = (sequence(10)+1)->sqrt->share_as('Test::Set1');
2021
my $to_compare = $data;
21-
ok(all($to_compare == $data), 'A ndarray exactly equals itself')
22-
or diag("Original is $data and comparison is $to_compare;\n"
23-
. "original - comparison = " . ($data - $to_compare));
22+
is_pdl $to_compare, $data, 'A ndarray exactly equals itself';
2423

2524
# Now retrieve the value from the "off-site" storage
2625
$to_compare = retrieve_pdls('Test::Set1');
27-
is_deeply([$to_compare->dims], [$data->dims], 'Retrieved dims is correct')
28-
or diag("Original dims are " . join(', ', $data->dims)
29-
. " and retrieved dims are " . join', ', $to_compare->dims);
30-
31-
ok($data->type == $to_compare->type, 'Retrieved type is correct')
32-
or diag("Original type is " . $data->type
33-
. " and retrieved type is " . $to_compare->type);
34-
35-
ok(all($to_compare == $data), 'Retrieved value exactly equals original')
36-
or diag("Original is $data and retrieved is $to_compare;\n"
37-
. "original - retrieved = " . ($data - $to_compare));
26+
is_pdl $to_compare, $data, 'Retrieved value exactly equals original';
3827

3928
###########################
4029
# Shared modifications: 2 #
@@ -43,14 +32,10 @@ ok(all($to_compare == $data), 'Retrieved value exactly equals original')
4332
use PDL::NiceSlice;
4433
# Modify the original, see if it is reflected in the retrieved copy
4534
$data(3) .= -10;
46-
ok(all($to_compare == $data), 'Modification to original is reflected in retrieved')
47-
or diag("Original is $data and retrieved is $to_compare;\n"
48-
. "original - retrieved = " . ($data - $to_compare));
35+
is_pdl $to_compare, $data, 'Modification to original is reflected in retrieved';
4936

5037
$to_compare(8) .= -50;
51-
ok(all($to_compare == $data), 'Modification to retrieved is reflected in original')
52-
or diag("Original is $data and retrieved is $to_compare;\n"
53-
. "original - retrieved = " . ($data - $to_compare));
38+
is_pdl $to_compare, $data, 'Modification to retrieved is reflected in original';
5439

5540
###############################
5641
# Undefine doesn't destroy: 3 #
@@ -60,12 +45,13 @@ my $expected = pdl(1, -10, -50); # These need to line up with the
6045
my $idx = pdl(0, 3, 8); # indices and values used/set above
6146

6247
undef($to_compare);
63-
ok(all($data($idx) == $expected), "Undeffing copy doesn't destroy data");
48+
is_pdl $data($idx), $expected, "Undeffing copy doesn't destroy data";
6449

6550
undef($data);
6651
my $new = retrieve_pdls('Test::Set1');
67-
ok(all($new($idx) == $expected), "Can retrieve data even after undefing original");
52+
is_pdl $new($idx), $expected, "Can retrieve data even after undefing original";
6853

6954
PDL::Parallel::threads::free_pdls('Test::Set1');
70-
ok(all($new($idx) == $expected), "Reference counting works");
55+
is_pdl $new($idx), $expected, "Reference counting works";
7156

57+
done_testing;

t/ppt-03_name_munging.t

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ use PDL::LiteF;
77
use PDL::Parallel::threads qw(retrieve_pdls);
88
use Test::More;
99
use Test::Exception;
10+
use Test::PDL;
1011

1112
sequence(20)->sqrt->share_as('test');
1213
my $short_name = retrieve_pdls('test');
1314
my $long_name;
1415
lives_ok { $long_name = retrieve_pdls('My::Foo/test') } 'Retrieving fully '
1516
. 'resolved name does not croak (that is, they exist)';
16-
ok(all($short_name == $long_name), 'Regular names get auto-munged with the '
17-
. 'current package name');
17+
is_pdl $short_name, $long_name, 'Regular names get auto-munged with the '
18+
. 'current package name';
1819

1920
sequence(20)->share_as('??foo');
2021
lives_ok { retrieve_pdls('??foo') } 'Basic retrieval with funny name works';

0 commit comments

Comments
 (0)