Skip to content

Commit bfd2505

Browse files
committed
stop tests mutating inputs by copying
1 parent 9215888 commit bfd2505

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

t/1.t

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ sub fapprox {
1414
sub runtest {
1515
local $Test::Builder::Level = $Test::Builder::Level + 1;
1616
my ($in, $method, $expected, $extra) = @_;
17+
$_ = $_->copy for $in;
1718
($expected, my $expected_cplx) = ref($expected) eq 'ARRAY' ? @$expected : ($expected, $expected);
19+
my @extra = map UNIVERSAL::isa($_, 'PDL') ? $_->copy : $_, @{$extra||[]};
1820
if (defined $expected) {
19-
my ($got) = $in->$method(@{$extra||[]});
21+
my ($got) = $in->$method(@extra);
2022
ok fapprox($got, $expected), $method or diag "got(".ref($got)."): $got\nexpected:$expected";
2123
}
22-
$_ = PDL->topdl($_)->r2C for $in;
23-
my ($got) = $in->$method(map ref() && ref() ne 'CODE' ? $_->r2C : $_, @{$extra||[]});
24+
$_ = $_->r2C for $in;
25+
my ($got) = $in->$method(map ref() && ref() ne 'CODE' ? $_->r2C : $_, @extra);
2426
my @cplx = ref($expected_cplx) eq 'ARRAY' ? @$expected_cplx : $expected_cplx;
2527
my $ok = grep fapprox($got, PDL->topdl($_)->r2C), @cplx;
2628
ok $ok, "native complex $method" or diag "got(".ref($got)."): $got\nexpected:@cplx";

0 commit comments

Comments
 (0)