Skip to content

Commit

Permalink
t/lvalue.t to actually test all ops in PDL::Lvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Nov 24, 2024
1 parent 79bc427 commit ee8cb20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
7 changes: 1 addition & 6 deletions Basic/lib/PDL/Course.pod
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,6 @@ seem to fit anywhere above.

=over

=item * L<PDL::Delta>

Explains how things changed from PDL 1.x to PDL 2.x

=item * L<PDL::Graphics2D>

Supposed to be a uniform interface to plotting 2D graphics.
Expand All @@ -422,7 +418,7 @@ Supposed to be a uniform interface to plotting 2D graphics.
Covers data flow, a cool feature to be sure, but from what I can tell
it is not currently supported.

=item * L<PDL::Lvalues>
=item * L<PDL::Lvalue>

PDL started before Perl 5.6, which introduce subs that could return
lvalues. I'm pretty sure that this module has been rolled into the core
Expand Down Expand Up @@ -458,4 +454,3 @@ distribute and/or modify this document under the same terms as the
current Perl license.

See: http://dev.perl.org/licenses/

25 changes: 16 additions & 9 deletions Basic/t/lvalue.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@ use Test::More;
use Test::Exception;

use PDL::LiteF;
use PDL::Dbg;
use PDL::Lvalue;

ok (PDL::Lvalue->subs('slice'),"slice is an lvalue sub");
my @lv_subs = map [$_], qw(
dice flat indexND broadcast nslice_if_pdl px range reorder reshape
sever slice indexNDb mslice
);
push @lv_subs, map [$_, 1], qw(clump dummy index unbroadcast);
push @lv_subs, map [$_, pdl 1], qw(where whereND);
push @lv_subs, map [$_, 0, 1], qw(diagonal);
push @lv_subs, map [$_, 0, 0], qw(dice_axis index2d mv xchg);
push @lv_subs, map [$_, pdl([0]), undef, undef], qw(rangeb);

my $pa = sequence 10;
lives_ok {
$pa->slice("") .= 0;
} "lvalue slice ran OK";
my $pa = sequence 3,3;
for (@lv_subs) {
my ($name, @args) = @$_;
no warnings 'uninitialized';
lives_ok { $pa->$name(@args) .= 0 } "lvalue @$_ ran OK";
}

is($pa->max, 0, "lvalue slice modified values");

lives_ok {
$pa->broadcast(0) .= 1;
} "lvalue broadcast ran OK";

done_testing;

0 comments on commit ee8cb20

Please sign in to comment.