Browse files

Windows portability fixes and converted PowInt to Test::Class

  • Loading branch information...
1 parent 0447a62 commit d159acc36be4941bf356e5f941987252bb7a14ad @leto committed Aug 12, 2008
Showing with 60 additions and 51 deletions.
  1. +1 −0 .gitignore
  2. +6 −7 Build.PL
  3. +2 −0 MANIFEST
  4. +1 −0 MANIFEST.SKIP
  5. +1 −1 lib/Math/GSL.pm
  6. +47 −0 lib/Math/GSL/PowInt/Test.pm
  7. +2 −43 t/PowInt.t
View
1 .gitignore
@@ -13,3 +13,4 @@ lib/Math/GSL/[A-z0-9]*\.pm
Makefile
*.data
foo*
+tags
View
13 Build.PL
@@ -120,24 +120,23 @@ sub compile_swig {
copy($from,$to);
return $c_file;
}
+sub _is_windows { $^O =~ /MSWin32/i }
-# From Base.pm but modified for a SWIG conventions.
-# We just pass a $obj_file parameter
-# SWIG objects have a get created with _wrap added. For example
-# perlcdio.swg produces perlcdio_wrap.c, and perlcdio_wrap.o.
-# But the shared object is still perlcdio.so.
-# Also we modified the die to report the full file name.
+# Windows fixes courtesy of <sisyphus@cpan.org>
sub link_c {
my ($self, $to, $file_base, $obj_file) = @_;
my ($cf, $p) = ($self->{config}, $self->{properties}); # For convenience
- my $lib_file = catfile($to, File::Basename::basename("$file_base.so"));
+ my $lib_file = catfile($to, File::Basename::basename("$file_base.$Config{dlext}"));
$self->add_to_cleanup($lib_file);
my $objects = $p->{objects} || [];
unless ($self->up_to_date([$obj_file, @$objects], $lib_file)) {
my @linker_flags = $self->split_like_shell($p->{extra_linker_flags});
+
+ push @linker_flags, $Config{archlib} . '/CORE/' . $Config{libperl} if _is_windows();
+
my @lddlflags = $self->split_like_shell($cf->{lddlflags});
my @shrp = $self->split_like_shell($cf->{shrpenv});
my @ld = $self->split_like_shell($cf->{ld}) || "gcc";
View
2 MANIFEST
@@ -75,6 +75,7 @@ lib/Math/GSL/Diff.pm
lib/Math/GSL/Eigen.pm
lib/Math/GSL/Eigen/Test.pm
lib/Math/GSL/Errno.pm
+lib/Math/GSL/Errno/Test.pm
lib/Math/GSL/FFT.pm
lib/Math/GSL/FFT/Test.pm
lib/Math/GSL/Fit.pm
@@ -109,6 +110,7 @@ lib/Math/GSL/Permutation/Test.pm
lib/Math/GSL/Poly.pm
lib/Math/GSL/Poly/Test.pm
lib/Math/GSL/PowInt.pm
+lib/Math/GSL/PowInt/Test.pm
lib/Math/GSL/QRNG.pm
lib/Math/GSL/QRNG/Test.pm
lib/Math/GSL/Randist.pm
View
1 MANIFEST.SKIP
@@ -10,3 +10,4 @@ blib/*
.*core
foo*
.*\.gz
+^tags
View
2 lib/Math/GSL.pm
@@ -160,7 +160,7 @@ the Summer of Code happen each year. You rock.
=head1 DEDICATION
-This Perl module is dedicated in the memory of Nick Ing-Simmons.
+This Perl module is dedicated in memory of Nick Ing-Simmons.
=head1 COPYRIGHT & LICENSE
View
47 lib/Math/GSL/PowInt/Test.pm
@@ -0,0 +1,47 @@
+package Math::GSL::PowInt::Test;
+use base q{Test::Class};
+use Test::More;
+use Math::GSL::PowInt qw/:all/;
+use Math::GSL qw/:all/;
+use Data::Dumper;
+use strict;
+
+sub _is_windows() { $^O =~ /MSWin32/i }
+sub make_fixture : Test(setup) {
+}
+
+sub teardown : Test(teardown) {
+}
+
+sub TEST_BASIC: Tests {
+ my %results = (
+ 'gsl_pow_2(3.14)' => (3.14)**2,
+ 'gsl_pow_2(3)' => 3 ** 2,
+ 'gsl_pow_2(0)' => 0 ** 2,
+ 'gsl_pow_2(-1)' => (-1) ** 2,
+ 'gsl_pow_3(4)' => 4 ** 3,
+ 'gsl_pow_4(5)' => 5 ** 4,
+ 'gsl_pow_5(6)' => 6 ** 5,
+ 'gsl_pow_6(7)' => 7 ** 6,
+ 'gsl_pow_7(8)' => 8 ** 7,
+ 'gsl_pow_8(-4)' => (-4) ** 8,
+ 'gsl_pow_9(4)' => 4 ** 9,
+ 'gsl_pow_int(5,10)'=> 5 ** 10,
+ );
+ verify(\%results, 'Math::GSL::PowInt');
+}
+
+# libc is scary on Windows
+sub TEST_NAN_INF : Tests {
+ my $self = shift;
+ my %results = (
+ q{gsl_pow_2('nan')} => 'nan',
+ q{gsl_pow_2('inf')} => 'inf',
+ );
+ if (_is_windows()) {
+ $self->builder->skip('skipping nan/inf checking on windows');
+ } else {
+ verify(\%results,'Math::GSL::PowInt');
+ }
+}
+42;
View
45 t/PowInt.t
@@ -1,43 +1,2 @@
-use Test::More 'no_plan';
-use Math::GSL qw/:all/;
-use Math::GSL::PowInt qw/:all/;
-use Data::Dumper;
-use strict;
-use warnings;
-use Test::Exception;
-
-
-{
- ok( gsl_pow_4(2) == gsl_pow_2(4) , q{%EXPORT_TAGS works} );
-}
-{
- # SWIG takes care of arg checking, but it's still nice to check
- dies_ok( sub { gsl_pow_2() } , 'Invalid gsl_pow args');
- dies_ok( sub { gsl_pow_2(1,2) } , 'Invalid gsl_pow args');
- dies_ok( sub { gsl_pow_2( () ) } , 'Invalid gsl_pow args');
- dies_ok( sub { gsl_pow_2(qw(1 2)) } ,'Invalid gsl_pow args');
-}
-{
- ok_similar( [ map { eval $_ } (
- 'gsl_pow_2(3.14)' ,
- 'gsl_pow_2(3)' ,
- 'gsl_pow_2(0)' ,
- 'gsl_pow_2(-1)' ,
- 'gsl_pow_3(4)' ,
- 'gsl_pow_4(5)' ,
- 'gsl_pow_5(6)' ,
- 'gsl_pow_6(7)' ,
- 'gsl_pow_7(8)' ,
- 'gsl_pow_8(-4)' ,
- 'gsl_pow_9(4)' ,
- q{gsl_pow_2('nan')} ,
- q{gsl_pow_2('inf')} ,
- 'gsl_pow_int(5,10)' ,
- ) ], [
- (3.14) ** 2, 3 ** 2, 0 ** 2, (-1) ** 2, 4 ** 3, 5 ** 4, 6 ** 5, 7 ** 6,
- 8 ** 7, (-4) ** 8, 4 ** 9, q{nan}, q{inf}, 5 ** 10,
- ],
- "basic power tests",
- );
-
-}
+use Math::GSL::PowInt::Test;
+Test::Class->runtests;

0 comments on commit d159acc

Please sign in to comment.