Skip to content

Commit

Permalink
Convert t/callext.t to Test::More
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Apr 11, 2015
1 parent c8a96dd commit 3cc8646
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ support for 2-D graphics (via PLplot) and 3-D graphics

Convert from Test to Test::More
* bess.t
* callext.t
* conv.t
* diskcache.t
* erf.t
Expand Down
23 changes: 12 additions & 11 deletions t/callext.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ END { unlink 't/callext.pdb';}; # In case we build a 2nd time,
# Example of how to use callext() - also see callext.c

use strict;
use Test;
use warnings;
use Test::More;
use Config;

BEGIN { plan tests => 1;
}
use PDL;
use PDL::CallExt;

use PDL::Core ':Internal'; # For topdl()
use PDL::Core::Dev;
use Config;
use File::Spec;

Expand All @@ -29,26 +27,29 @@ sub tapprox {

# Create the filenames
my $cfile = File::Spec->catfile('t', 'callext.c');
# include the pdlsimple.h that's in blib.
my $inc = File::Spec->catdir('blib', 'lib', 'PDL', 'Core');
my $out = File::Spec->catfile('t', 'callext.'.$Config{dlext});

# Compile the code

my @cleanup = ();
END { unlink @cleanup; }
push @cleanup, File::Spec->catfile('t', 'callext'.$Config{obj_ext}), $out;
callext_cc($cfile, qq{"-I$inc"}, '', $out);
eval { callext_cc($cfile, PDL_INCLUDE(), '', $out) };

SKIP: {
is $@, '', 'callext_cc no error' or skip 'callext_cc failed', 1;
my $y = sequence(5,4)+2; # Create PDL
my $x = $y*20+100; # Another

my $try = loglog($x,$y);
my $correct = log(float($x))/log(float($y));

print "Try = $try\n";
print "Correct = $correct\n";
ok( tapprox($try, $correct) );
note "Try = $try\n";
note "Correct = $correct\n";
ok tapprox($try, $correct), 'tapprox';
}

done_testing;

# Return log $x to base $y using callext() routine -
# perl wrapper makes this nice and easy to use.
Expand Down

0 comments on commit 3cc8646

Please sign in to comment.