Skip to content

Commit

Permalink
Merge pull request #453 from PDLPorters/rehab_primitive-tests
Browse files Browse the repository at this point in the history
Reorganize and modlarize tests in t/primitive.t
  • Loading branch information
djerius committed Sep 13, 2023
2 parents 4f12de9 + 30b43e2 commit 457ff25
Show file tree
Hide file tree
Showing 16 changed files with 1,760 additions and 1,191 deletions.
16 changes: 14 additions & 2 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ Demos/earth-interp.pl
Demos/earth.txt
Demos/General.pm
Demos/Makefile.PL
Demos/t/demos.t
Demos/Sound.pm
Demos/t/demos.t
Demos/Transform_demo.pm
Demos/TriD/test4.p
Demos/TriD/test5.p
Expand Down Expand Up @@ -708,6 +708,7 @@ t/croak.t
t/func.pdl
t/inline-with.t
t/inlinepdlpp.t
t/lib/My/Test/Primitive.pm
t/lvalue.t
t/math.t
t/matrix.t
Expand All @@ -719,7 +720,18 @@ t/pdl_from_string.t
t/pdlchar.t
t/pp_croaking.t
t/pp_line_numbers.t
t/primitive.t
t/primitive/append.t
t/primitive/clip.t
t/primitive/interpolate.t
t/primitive/matmult.t
t/primitive/misc.t
t/primitive/random.t
t/primitive/selector.t
t/primitive/setops.t
t/primitive/stats.t
t/primitive/Ufunc.t
t/primitive/vector.t
t/primitive/vsearch.t
t/pthread.t
t/reduce.t
t/scope.t
Expand Down
2 changes: 2 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ my %makefile_hash = (
'IPC::Cmd' => '0.72',
'Test::Exception' => 0,
'Test::Warn' => 0, # for t/pptest.t
'Test::Lib' => 0.003,
'Test2::V0' => 0.000155,
},
BUILD_REQUIRES => {
'ExtUtils::MakeMaker' => 0,
Expand Down
29 changes: 29 additions & 0 deletions t/lib/My/Test/Primitive.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! perl

use strict;
use warnings;
use Test2::V0 '!float';
use PDL::LiteF;

use Exporter 'import';
our @EXPORT = qw( tapprox );

sub tapprox {
my ( $x, $y ) = @_;
$_ = pdl($_) for $x, $y;
if ( ( my $dims_x = join( ',', $x->dims ) ) ne
( my $dims_y = join( ',', $y->dims ) ) )
{
diag "APPROX: $x $y\n";
diag "UNEQDIM: |$dims_x| |$dims_y|\n";
return 0;
}
return 1 if $x->isempty and $y->isempty;
my $d = max( abs( $x - $y ) );
if ( $d >= 0.01 ) {
diag "got=$x expected=$y\n";
}
$d < 0.01;
}

1;
Loading

0 comments on commit 457ff25

Please sign in to comment.