diff --git a/t/core.t b/t/core.t index 931b984c1..337320abe 100644 --- a/t/core.t +++ b/t/core.t @@ -1,6 +1,7 @@ use strict; use warnings; use Test::More; +use Test::Exception; use PDL::LiteF; use Config; use PDL::Types; @@ -144,6 +145,22 @@ ok all(tapprox((5*sequence(5))->maximum_n_ind(3), pdl(4,3,2))), 'named dim'; # pptest for dim with fixed value ok all(tapprox(crossp([1..3],[4..6]), pdl(-3,6,-3))), 'named dim=3'; +subtest 'dim compatibility' => sub { + for ( + [\&append, [pdl(1), pdl(2), zeroes(1)], 2, qr/dim has size 1/, 'output => [1]; required [2]. output too small'], + [\&append, [pdl(1), pdl(2), zeroes(3,1)], 2, qr/dim has size 3/, 'output => [3,1]; required [2]. output too small'], + [\&append, [pdl(1), pdl(2), null], 2, [ 1, 2 ], 'output => null; required [2]'], + ) { + my ($func, $args, $exp_index, $exp, $label) = @$_; + if (ref $exp eq 'Regexp') { + throws_ok { $func->( @$args ) } $exp, $label; + } else { + $func->( @$args ); + is_deeply( $args->[$exp_index]->unpdl, $exp, $label ); + } + } +}; + # test topdl { package # hide from PAUSE diff --git a/t/primitive-append.t b/t/primitive-append.t index 42c351022..f49a31708 100644 --- a/t/primitive-append.t +++ b/t/primitive-append.t @@ -1,7 +1,6 @@ use strict; use warnings; use Test::More; -use Test::Exception; use PDL::LiteF; is_deeply( @@ -24,28 +23,6 @@ subtest 'append(null, null, $output)' => sub { is_deeply( $output->unpdl, [0], q{user's ndarray is unchanged} ); }; -subtest 'output ndarray has different shape' => sub { - - subtest 'output => [1]; required [2]. output too small' => sub { - my $output = zeroes(1); - throws_ok { append( pdl(1), pdl(2), $output ) } - qr/dim has size 1/; - }; - - subtest 'output => [3,1]; required [2]' => sub { - my $output = zeroes(3,1); - throws_ok { append( pdl(1), pdl(2), $output ) } - qr/dim has size 3/; - }; - - subtest 'output => null; required [2]' => sub { - my $output = null; - append( pdl(1), pdl(2), $output ); - is_deeply( $output->unpdl, [ 1, 2 ], q{full append } ); - }; - -}; - subtest types => sub { is( append( zeroes( float, 2, 0 ), zeroes( 3, 0 ) )->type,