Skip to content

Commit 5e27cbe

Browse files
committed
switch from Test::More/Test::Most/Test::Fatal/etc to Test2::V0
1 parent aa2ed6a commit 5e27cbe

File tree

10 files changed

+92
-126
lines changed

10 files changed

+92
-126
lines changed

cpanfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ on 'test' => sub {
6969
requires "Test2::Tools::PDL" => "0";
7070
requires "Test2::Tools::Warnings" => "0";
7171
requires "Test2::V0" => "0";
72-
requires "Test::Fatal" => "0";
7372
requires "Test::File::ShareDir" => "0";
74-
requires "Test::More" => "0";
75-
requires "Test::Most" => "0";
7673
};
7774

7875
on 'configure' => sub {

t/basic.t

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use Test::Most tests => 16;
1+
#!perl
22

3-
use strict;
4-
use warnings;
3+
use Data::Frame::Setup;
4+
5+
use Test2::V0;
56

67
use Data::Frame;
7-
use PDL;
8+
use PDL::Core qw(pdl);
89

910
my $a = pdl(1, 2, 3, 4);
1011
my $b = $a >= 2;
@@ -28,37 +29,42 @@ is($df_hash->number_of_columns, 3);
2829
is($df_array->number_of_rows, 4);
2930
is($df_hash->number_of_rows, 4);
3031

31-
is_deeply( $df_array->column_names, [ qw/z y x/ ] );
32-
is_deeply( $df_hash->column_names, [ qw/a b c/ ] );
32+
is( $df_array->column_names, [ qw/z y x/ ] );
33+
is( $df_hash->column_names, [ qw/a b c/ ] );
3334

3435
is( $df_hash->column('c')->number_of_rows, 4);
35-
is_deeply( $df_hash->column('c')->unpdl, $c);
36+
is( $df_hash->column('c')->unpdl, $c);
3637

37-
throws_ok { $df_hash->add_column( c => [1, 2, 3, 4] ) }
38-
qr/column.*already exists/,
39-
'exception for adding existing column';
38+
like(
39+
dies { $df_hash->add_column( c => [ 1, 2, 3, 4 ] ) },
40+
qr/column.*already exists/,
41+
'exception for adding existing column'
42+
);
4043

4144
$df_array->column_names(qw/a b c/);
42-
is_deeply( $df_array->column_names, [ qw/a b c/ ], 'renaming columns works' );
45+
is( $df_array->column_names, [ qw/a b c/ ], 'renaming columns works' );
4346

44-
is_deeply( $df_array->row_names->unpdl, [ 0..3 ] );
47+
is( $df_array->row_names->unpdl, [ 0..3 ] );
4548

46-
throws_ok
47-
{ $df_array->column_names(qw/a b c d/); }
48-
qr/incorrect number of column names/,
49-
'setting more columns than exist';
49+
like(
50+
dies { $df_array->column_names(qw/a b c d/); },
51+
qr/incorrect number of column names/,
52+
'setting more columns than exist'
53+
);
5054

5155
is( $df_hash->nth_column(0)->number_of_rows, 4);
5256
is( $df_hash->nth_column(-1)->number_of_rows, 4);
5357

54-
throws_ok
55-
{ $df_hash->nth_column(3) }
56-
qr/index out of bounds/,
57-
'out of bounds column access';
58-
59-
throws_ok
60-
{ $df_hash->column('m') }
61-
qr/column.*does not exist/,
62-
'non-existent column';
58+
like(
59+
dies { $df_hash->nth_column(3) },
60+
qr/index out of bounds/,
61+
'out of bounds column access'
62+
);
63+
64+
like(
65+
dies { $df_hash->column('m') },
66+
qr/column.*does not exist/,
67+
'non-existent column'
68+
);
6369

6470
done_testing;

t/failures.t

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#!/usr/bin/env perl
22

3-
use strict; use warnings;
4-
use Test::More;
3+
use Data::Frame::Setup;
54

6-
use Data::Frame;
7-
use Test::Fatal;
8-
9-
use PDL::Factor;
5+
use Test2::V0;
106

7+
use Data::Frame;
8+
use PDL::Factor ();
119

1210
subtest 'Data::Frame throws exception objects' => sub {
1311

@@ -22,34 +20,31 @@ subtest 'Data::Frame throws exception objects' => sub {
2220
],
2321
);
2422

23+
isa_ok( dies { $a == $b }, 'failure::columns::mismatch' );
2524

26-
isa_ok( exception { $a == $b }, 'failure::columns::mismatch' );
25+
isa_ok( dies { $a->column_names(qw/a b/) }, 'failure::columns::length' );
2726

28-
isa_ok( exception { $a->column_names(qw/a b/) }, 'failure::columns::length' );
27+
isa_ok( dies { $a->row_names(qw/a b/) }, 'failure::rows::length' );
28+
isa_ok( dies { $a->row_names(qw/a b b/) }, 'failure::rows::unique' );
2929

30-
isa_ok( exception { $a->row_names(qw/a b/) }, 'failure::rows::length' );
31-
isa_ok( exception { $a->row_names(qw/a b b/) }, 'failure::rows::unique' );
32-
33-
isa_ok( exception { $a->column('ape') }, 'failure::column::exists' );
30+
isa_ok( dies { $a->column('ape') }, 'failure::column::exists' );
3431

3532
#isa_ok( exception { $a->nth_column }, 'failure::index' );
36-
isa_ok( exception { $a->nth_column(5) }, 'failure::index::exists' );
33+
isa_ok( dies { $a->nth_column(5) }, 'failure::index::exists' );
3734

38-
isa_ok( exception { $a->add_column(1) }, 'failure::column::name::string' );
39-
isa_ok( exception { $a->add_column(c => [1..4]) }, 'failure::rows::length' );
40-
isa_ok( exception { $a->add_column('x') }, 'failure::column::exists' );
35+
isa_ok( dies { $a->add_column(1) }, 'failure::column::name::string' );
36+
isa_ok( dies { $a->add_column(c => [1..4]) }, 'failure::rows::length' );
37+
isa_ok( dies { $a->add_column('x') }, 'failure::column::exists' );
4138

42-
isa_ok( exception { $a->add_columns(x => [1..3], 'y') }, 'failure::columns::unbalanced' );
39+
isa_ok( dies { $a->add_columns(x => [1..3], 'y') }, 'failure::columns::unbalanced' );
4340
};
4441

4542
subtest 'PDL::Factor throws exception objects' => sub {
4643
my $a = PDL::Factor->new(['b'], levels => [qw/a b c/],);
4744
my $b = PDL::Factor->new(['b'], levels => [qw/c b a/],);
4845

49-
isa_ok( exception { $a == $b }, 'failure::levels::mismatch' );
50-
51-
52-
isa_ok( exception { $a->levels(qw/a b c d/) }, 'failure::levels::number' );
46+
isa_ok( dies { $a == $b }, 'failure::levels::mismatch' );
47+
isa_ok( dies { $a->levels(qw/a b c d/) }, 'failure::levels::number' );
5348
};
5449
done_testing;
5550

t/pdl-factor.t

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use Test::Most tests => 16;
1+
#!perl
22

3-
use strict;
4-
use warnings;
3+
use Data::Frame::Setup;
54

6-
use PDL::Factor;
5+
use Test2::V0;
6+
7+
use PDL::Factor ();
78

89
my $data = [ qw[ a b c a b ] ];
910
my $f = PDL::Factor->new( $data );
@@ -12,7 +13,7 @@ is( $f->nelem, 5 );
1213

1314
is( $f->number_of_levels, 3 );
1415

15-
cmp_set( $f->levels, [qw/a b c/] );
16+
is( $f->levels, [qw/a b c/] );
1617

1718
is( "$f", "[ a b c a b ]", 'stringify' );
1819

@@ -21,51 +22,32 @@ is( "@{[ $f->uniq ]}", "[ a b c ]" );
2122
# set levels
2223
my $f_set_levels = PDL::Factor->new( $data );
2324
$f_set_levels->levels(qw/z y x/);
24-
is_deeply( $f_set_levels->levels, [qw/z y x/] );
25+
is( $f_set_levels->levels, [qw/z y x/] );
2526

26-
throws_ok
27-
{ $f_set_levels->levels(qw/z y/); }
28-
qr/incorrect number of levels/,
29-
'setting too few levels';
27+
like(
28+
dies { $f_set_levels->levels(qw/z y/); },
29+
qr/incorrect number of levels/,
30+
'setting too few levels'
31+
);
3032

3133
EQUALITY: {
3234
my $another_f = PDL::Factor->new( $data );
3335
my $g = PDL::Factor->new( [ qw[a b a a c ] ] );
3436
my $h = PDL::Factor->new( [ qw[x y z x y ] ] );
3537

36-
#use DDP; &p( $f!=$g );
3738
ok( ($f == $another_f)->all, 'factor data is equal' );
3839
ok( !( ($f == $g)->all ) , 'factor data is not equal' );
3940
ok( ($f != $g)->any, 'factor data is not equal' );
4041

41-
throws_ok( sub { $f == $h; },
42-
qr/level sets of factors are different/,
43-
'error: different level sets' );
42+
like(
43+
dies { $f == $h; },
44+
qr/level sets of factors are different/,
45+
'error: different level sets'
46+
);
4447
ok( ($f->{PDL} == $h->{PDL})->all, 'but the internal values are the same');
4548
}
4649

47-
TODO: { # CLONING
48-
todo_skip "need to implement cloning", 3;
49-
50-
my $copy_of_f_0 = $f->copy;
51-
my $copy_of_f_1 = PDL::Factor->new( $f );
52-
53-
is_deeply($copy_of_f_0->levels, $f->levels);
54-
55-
ok( $f == $copy_of_f_0 );
56-
57-
ok( $copy_of_f_0 == $copy_of_f_1 );
58-
59-
note $copy_of_f_0->PDL::Core::string;
60-
61-
# table( iris$Species )
62-
# row.names( table( iris$Species ) )
63-
# table( iris$Species ) / length( iris$Species )
64-
# <http://www.cyclismo.org/tutorial/R/types.html>
65-
}
66-
6750
subtest 'max width' => sub {
68-
plan tests => 4;
6951
my $width_data = [ qw[ a b cde fghi ] ];
7052
my $width_factor = PDL::Factor->new($width_data);
7153
is( $width_factor->element_stringify_max_width, 4 );

t/pdl-stringifiable-ext.t

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
use Test::Most tests => 7;
1+
#!perl
22

3-
use strict;
4-
use warnings;
3+
use Data::Frame::Setup;
54

6-
use PDL;
5+
use Test2::V0;
6+
7+
use PDL::Basic qw(sequence);
8+
use PDL::Core qw(pdl);
79
use PDL::StringfiableExtension;
810

911
is( sequence(10)->element_stringify_max_width, 1 );
@@ -28,7 +30,6 @@ for (@each) {
2830
}
2931

3032
subtest 'lengths' => sub {
31-
plan tests => 3 * @each;
3233
for my $data (@each) {
3334
note $data->{val};
3435
is( pdl($data->{val})->element_stringify_max_width, $data->{zerodim} );

t/pdl-sv.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use Test::Most tests => 7;
1+
#!perl
22

3-
use strict;
4-
use warnings;
3+
use Data::Frame::Setup;
54

6-
use PDL::SV;
5+
use Test2::V0;
76

7+
use PDL::SV ();
88
use Math::BigInt;
99

1010
my $data = [ Math::BigInt->new('4'), Math::BigInt->new('3'), Math::BigInt->new('20'), Math::BigInt->new('2'), ];

t/rlike-TODO.t

Lines changed: 0 additions & 18 deletions
This file was deleted.

t/rlike.t

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use Test::Most tests => 6;
1+
#!perl
22

3-
use strict;
4-
use warnings;
3+
use Data::Frame::Setup;
4+
5+
use Test2::V0;
56

67
use Data::Frame::Rlike;
7-
use PDL;
8+
use PDL::Basic qw(sequence);
89

910
my $N = 42;
1011
my $first_x = 0;

t/subset.t

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use Test::Most;
1+
#!perl
22

3-
use strict;
4-
use warnings;
3+
use Data::Frame::Setup;
4+
5+
use Test2::V0;
56

67
use Data::Frame;
7-
use PDL;
8+
use PDL::Core qw(pdl);
89

910
my $a = pdl( 1, 2, 3, 4 );
1011
my $b = $a >= 2;
@@ -36,13 +37,13 @@ subtest number_of_rows => sub {
3637

3738
subtest subset => sub {
3839
my $df_subset = $df->subset( sub { $_->('z') > 2 } );
39-
is_deeply( $df_subset->row_names->unpdl, [ 2 .. 3 ] );
40+
is( $df_subset->row_names->unpdl, [ 2 .. 3 ] );
4041

4142
my $df_subset_autoload = $df->subset( sub { $_->z > 2 } );
42-
is_deeply( $df_subset_autoload->row_names->unpdl, [ 2 .. 3 ] );
43+
is( $df_subset_autoload->row_names->unpdl, [ 2 .. 3 ] );
4344

4445
my $df_subset_further = $df_subset->subset( sub { $_->('z') == 3 } );
45-
is_deeply( $df_subset_further->row_names->unpdl, [2] );
46+
is( $df_subset_further->row_names->unpdl, [2] );
4647
};
4748

4849
done_testing;

t/traits.t

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use Test::Most tests => 2;
1+
#!perl
22

3-
use strict;
4-
use warnings;
3+
use Data::Frame::Setup;
4+
5+
use Test2::V0;
56

67
use Data::Frame;
7-
use PDL;
8+
use PDL::Basic qw(sequence);
89

910
my $N = 5;
1011
my $colspec = [ x => sequence($N), y => 3 * sequence($N) ];

0 commit comments

Comments
 (0)