From d6ad716d88d4432aa000be8e774981f2feafbaf0 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 24 Sep 2010 14:49:06 +0000 Subject: Perl 5.12.2 from CPAN --- .../perl/cpan/Math-Complex/lib/Math/Complex.pm | 81 ++++++---------------- .../perl/cpan/Math-Complex/lib/Math/Trig.pm | 37 ++++++---- gnu/usr.bin/perl/cpan/Math-Complex/t/Complex.t | 42 +++-------- gnu/usr.bin/perl/cpan/Math-Complex/t/Trig.t | 56 ++++++++------- gnu/usr.bin/perl/cpan/Math-Complex/t/underbar.t | 5 +- gnu/usr.bin/perl/cpan/Memoize/t/array_confusion.t | 20 +++--- gnu/usr.bin/perl/cpan/Memoize/t/errors.t | 4 +- gnu/usr.bin/perl/cpan/Memoize/t/speed.t | 7 +- 8 files changed, 98 insertions(+), 154 deletions(-) (limited to 'gnu') diff --git a/gnu/usr.bin/perl/cpan/Math-Complex/lib/Math/Complex.pm b/gnu/usr.bin/perl/cpan/Math-Complex/lib/Math/Complex.pm index 6cab2689bdc..8475a2b5d09 100644 --- a/gnu/usr.bin/perl/cpan/Math-Complex/lib/Math/Complex.pm +++ b/gnu/usr.bin/perl/cpan/Math-Complex/lib/Math/Complex.pm @@ -7,35 +7,16 @@ package Math::Complex; -{ use 5.006; } use strict; -our $VERSION = 1.59_02; +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $Inf $ExpInf); -use Config; +$VERSION = 1.56; -our ($Inf, $ExpInf); -our ($vax_float, $has_inf, $has_nan); +use Config; BEGIN { - $vax_float = (pack("d",1) =~ /^[\x80\x10]\x40/); - $has_inf = !$vax_float; - $has_nan = !$vax_float; - - unless ($has_inf) { - # For example in vax, there is no Inf, - # and just mentioning the DBL_MAX (1.70141183460469229e+38) - # causes SIGFPE. - - # These are pretty useless without a real infinity, - # but setting them makes for less warnings about their - # undefined values. - $Inf = "Inf"; - $ExpInf = "Inf"; - return; - } - - my %DBL_MAX = # These are IEEE 754 maxima. + my %DBL_MAX = ( 4 => '1.70141183460469229e+38', 8 => '1.7976931348623157e+308', @@ -45,7 +26,6 @@ BEGIN { 12 => '1.1897314953572317650857593266280070162E+4932', 16 => '1.1897314953572317650857593266280070162E+4932', ); - my $nvsize = $Config{nvsize} || ($Config{uselongdouble} && $Config{longdblsize}) || $Config{doublesize}; @@ -60,7 +40,7 @@ BEGIN { if ($^O eq 'unicosmk') { $Inf = $DBL_MAX; } else { - local $SIG{FPE} = sub { }; + local $SIG{FPE} = { }; local $!; # We do want an arithmetic overflow, Inf INF inf Infinity. for my $t ( @@ -79,12 +59,12 @@ BEGIN { $Inf = $i; last; } - } + } $Inf = $DBL_MAX unless defined $Inf; # Oh well, close enough. die "Math::Complex: Could not get Infinity" unless $Inf > $BIGGER_THAN_THIS; - $ExpInf = eval 'exp(99999)'; - } + $ExpInf = exp(99999); + } # print "# On this machine, Inf = '$Inf'\n"; } @@ -116,7 +96,7 @@ my $gre = qr'\s*([\+\-]?(?:(?:(?:\d+(?:_\d+)*(?:\.\d*(?:_\d+)*)?|\.\d+(?:_\d+)*) require Exporter; -our @ISA = qw(Exporter); +@ISA = qw(Exporter); my @trig = qw( pi @@ -130,7 +110,7 @@ my @trig = qw( acsch acosech asech acoth acotanh ); -our @EXPORT = (qw( +@EXPORT = (qw( i Re Im rho theta arg sqrt log ln log10 logn cbrt root @@ -141,24 +121,18 @@ our @EXPORT = (qw( my @pi = qw(pi pi2 pi4 pip2 pip4 Inf); -our @EXPORT_OK = @pi; +@EXPORT_OK = @pi; -our %EXPORT_TAGS = ( +%EXPORT_TAGS = ( 'trig' => [@trig], 'pi' => [@pi], ); use overload - '=' => \&_copy, - '+=' => \&_plus, '+' => \&_plus, - '-=' => \&_minus, '-' => \&_minus, - '*=' => \&_multiply, '*' => \&_multiply, - '/=' => \&_divide, '/' => \&_divide, - '**=' => \&_power, '**' => \&_power, '==' => \&_numeq, '<=>' => \&_spaceship, @@ -170,6 +144,7 @@ use overload 'log' => \&log, 'sin' => \&sin, 'cos' => \&cos, + 'tan' => \&tan, 'atan2' => \&atan2, '""' => \&_stringify; @@ -210,9 +185,9 @@ sub _make { if (defined $p) { $p =~ s/^\+//; - $p =~ s/^(-?)inf$/"${1}9**9**9"/e if $has_inf; + $p =~ s/^(-?)inf$/"${1}9**9**9"/e; $q =~ s/^\+//; - $q =~ s/^(-?)inf$/"${1}9**9**9"/e if $has_inf; + $q =~ s/^(-?)inf$/"${1}9**9**9"/e; } return ($p, $q); @@ -235,26 +210,13 @@ sub _emake { if (defined $p) { $p =~ s/^\+//; $q =~ s/^\+//; - $p =~ s/^(-?)inf$/"${1}9**9**9"/e if $has_inf; - $q =~ s/^(-?)inf$/"${1}9**9**9"/e if $has_inf; + $p =~ s/^(-?)inf$/"${1}9**9**9"/e; + $q =~ s/^(-?)inf$/"${1}9**9**9"/e; } return ($p, $q); } -sub _copy { - my $self = shift; - my $clone = {%$self}; - if ($self->{'cartesian'}) { - $clone->{'cartesian'} = [@{$self->{'cartesian'}}]; - } - if ($self->{'polar'}) { - $clone->{'polar'} = [@{$self->{'polar'}}]; - } - bless $clone,__PACKAGE__; - return $clone; -} - # # ->make # @@ -1577,7 +1539,7 @@ sub _stringify_polar { if (defined $format) { $r = sprintf($format, $r); - $theta = sprintf($format, $t) unless defined $theta; + $theta = sprintf($format, $theta) unless defined $theta; } else { $theta = $t unless defined $theta; } @@ -2115,10 +2077,9 @@ L =head1 AUTHORS -Daniel S. Lewart >, -Jarkko Hietaniemi >, -Raphael Manfredi >, -Zefram +Daniel S. Lewart > +Jarkko Hietaniemi > +Raphael Manfredi > =head1 LICENSE diff --git a/gnu/usr.bin/perl/cpan/Math-Complex/lib/Math/Trig.pm b/gnu/usr.bin/perl/cpan/Math-Complex/lib/Math/Trig.pm index 1d9612a41c2..b7767bebccb 100644 --- a/gnu/usr.bin/perl/cpan/Math-Complex/lib/Math/Trig.pm +++ b/gnu/usr.bin/perl/cpan/Math-Complex/lib/Math/Trig.pm @@ -4,18 +4,20 @@ # -- Raphael Manfredi, September 1996 (indirectly: because of Math::Complex) # +require Exporter; package Math::Trig; -{ use 5.006; } +use 5.005; use strict; -use Math::Complex 1.59; +use Math::Complex 1.56; use Math::Complex qw(:trig :pi); -require Exporter; -our @ISA = qw(Exporter); +use vars qw($VERSION $PACKAGE @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); + +@ISA = qw(Exporter); -our $VERSION = 1.23; +$VERSION = 1.20; my @angcnv = qw(rad2deg rad2grad deg2rad deg2grad @@ -23,7 +25,7 @@ my @angcnv = qw(rad2deg rad2grad my @areal = qw(asin_real acos_real); -our @EXPORT = (@{$Math::Complex::EXPORT_TAGS{'trig'}}, +@EXPORT = (@{$Math::Complex::EXPORT_TAGS{'trig'}}, @angcnv, @areal); my @rdlcnv = qw(cartesian_to_cylindrical @@ -44,13 +46,13 @@ my @greatcircle = qw( my @pi = qw(pi pi2 pi4 pip2 pip4); -our @EXPORT_OK = (@rdlcnv, @greatcircle, @pi, 'Inf'); +@EXPORT_OK = (@rdlcnv, @greatcircle, @pi, 'Inf'); # See e.g. the following pages: # http://www.movable-type.co.uk/scripts/LatLong.html # http://williams.best.vwh.net/avform.htm -our %EXPORT_TAGS = ('radial' => [ @rdlcnv ], +%EXPORT_TAGS = ('radial' => [ @rdlcnv ], 'great_circle' => [ @greatcircle ], 'pi' => [ @pi ]); @@ -164,13 +166,19 @@ sub great_circle_distance { sub great_circle_direction { my ( $theta0, $phi0, $theta1, $phi1 ) = @_; + my $distance = great_circle_distance($theta0, $phi0, $theta1, $phi1); + my $lat0 = pip2 - $phi0; my $lat1 = pip2 - $phi1; - return rad2rad(pi2 - - atan2(sin($theta0-$theta1) * cos($lat1), - cos($lat0) * sin($lat1) - - sin($lat0) * cos($lat1) * cos($theta0-$theta1))); + my $direction = + acos_real((sin($lat1) - sin($lat0) * cos($distance)) / + (cos($lat0) * sin($distance))); + + $direction = pi2 - $direction + if sin($theta1 - $theta0) < 0; + + return rad2rad($direction); } *great_circle_bearing = \&great_circle_direction; @@ -747,9 +755,8 @@ L =head1 AUTHORS -Jarkko Hietaniemi >, -Raphael Manfredi >, -Zefram +Jarkko Hietaniemi > and +Raphael Manfredi >. =head1 LICENSE diff --git a/gnu/usr.bin/perl/cpan/Math-Complex/t/Complex.t b/gnu/usr.bin/perl/cpan/Math-Complex/t/Complex.t index c4fd96f8bd4..687d6220df5 100755 --- a/gnu/usr.bin/perl/cpan/Math-Complex/t/Complex.t +++ b/gnu/usr.bin/perl/cpan/Math-Complex/t/Complex.t @@ -6,20 +6,20 @@ # -- Jarkko Hietaniemi since Mar 1997 # -- Daniel S. Lewart since Sep 1997 -use strict; -use warnings; +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + #@INC = '../lib'; + } +} use Math::Complex 1.54; -# they are used later in the test and not exported by Math::Complex -*_stringify_cartesian = \&Math::Complex::_stringify_cartesian; -*_stringify_polar = \&Math::Complex::_stringify_polar; +use vars qw($VERSION); -our $vax_float = (pack("d",1) =~ /^[\x80\x10]\x40/); -our $has_inf = !$vax_float; +$VERSION = 1.92; my ($args, $op, $target, $test, $test_set, $try, $val, $zvalue, @set, @val); -my ($bad, $z); $test = 0; $| = 1; @@ -34,15 +34,6 @@ if ($^O eq 'unicos') { # For some reason root() produces very inaccurate } # cos(), sin(), cosh(), sinh(). The division # of doubles is the current suspect. -$test++; -push @script, "{ my \$t=$test; ".q{ - my $a = Math::Complex->new(1); - my $b = $a; - $a += 2; - print "not " unless "$a" eq "3" && "$b" eq "1"; - print "ok $t\n"; -}."}"; - while () { s/^\s+//; next if $_ eq '' || /^\#/; @@ -126,13 +117,8 @@ my $pii = cplx(0, pi); my $pip2 = cplx(pi/2, 0); my $pip4 = cplx(pi/4, 0); my $zero = cplx(0, 0); -'; - -if ($has_inf) { - $constants .= <<'EOF'; my $inf = 9**9**9; -EOF -} +'; push(@script, $constants); @@ -301,15 +287,6 @@ EOS print "not " unless "\$j" =~ /^\\[1,2\\.09439510\\d+\\]\$/; print "ok $test\n"; - \$j->display_format('style' => 'polar', 'format' => "%.4g"); -EOS - - $test++; - push @script, <display_format('style' => 'cartesian', 'format' => '(%.5g)'); EOS @@ -721,7 +698,6 @@ __END__ [1, pi/3]:"[1,pi/3]" [6, -2*pi/3]:"[6,-2pi/3]" [0.5, -9*pi/11]:"[0.5,-9pi/11]" -[1, 0.5]:"[1, 0.5]" { (4,3); [3,2]; (-3,4); (0,2); [2,1] } diff --git a/gnu/usr.bin/perl/cpan/Math-Complex/t/Trig.t b/gnu/usr.bin/perl/cpan/Math-Complex/t/Trig.t index a9a12556b65..ae0b0fd1d63 100755 --- a/gnu/usr.bin/perl/cpan/Math-Complex/t/Trig.t +++ b/gnu/usr.bin/perl/cpan/Math-Complex/t/Trig.t @@ -1,4 +1,4 @@ -#!./perl +#!./perl # # Regression tests for the Math::Trig package @@ -8,21 +8,34 @@ # # -- Jarkko Hietaniemi, April 1997 -use strict; -use warnings; -use Test::More tests => 153; +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + #@INC = '../lib'; + } +} + +BEGIN { + eval { require Test::More }; + if ($@) { + # We are willing to lose testing in e.g. 5.00504. + print "1..0 # No Test::More, skipping\n"; + exit(0); + } else { + import Test::More; + } +} + +plan(tests => 153); use Math::Trig 1.18; use Math::Trig 1.18 qw(:pi Inf); -our $vax_float = (pack("d",1) =~ /^[\x80\x10]\x40/); -our $has_inf = !$vax_float; - my $pip2 = pi / 2; use strict; -our($x, $y, $z); +use vars qw($x $y $z); my $eps = 1e-11; @@ -30,7 +43,7 @@ if ($^O eq 'unicos') { # See lib/Math/Complex.pm and t/lib/complex.t. $eps = 1e-10; } -sub near { +sub near ($$;$) { my $e = defined $_[2] ? $_[2] : $eps; my $d = $_[1] ? abs($_[0]/$_[1] - 1) : abs($_[0]); print "# near? $_[0] $_[1] : $d : $e\n"; @@ -294,14 +307,9 @@ use Math::Trig ':radial'; ok(near($dst1, $dst2)); } -SKIP: { -# With netbsd-vax (or any vax) there is neither Inf, nor 1e40. -skip("different float range", 42) if $vax_float; -skip("no inf", 42) unless $has_inf; - print "# Infinity\n"; -my $BigDouble = eval '1e40'; +my $BigDouble = 1e40; # E.g. netbsd-alpha core dumps on Inf arith without this. local $SIG{FPE} = sub { }; @@ -328,17 +336,17 @@ ok(-Inf() / $BigDouble == -Inf()); print "# sinh/sech/cosh/csch/tanh/coth unto infinity\n"; -ok(near(sinh(100), eval '1.3441e+43', 1e-3)); -ok(near(sech(100), eval '7.4402e-44', 1e-3)); -ok(near(cosh(100), eval '1.3441e+43', 1e-3)); -ok(near(csch(100), eval '7.4402e-44', 1e-3)); +ok(near(sinh(100), 1.3441e+43, 1e-3)); +ok(near(sech(100), 7.4402e-44, 1e-3)); +ok(near(cosh(100), 1.3441e+43, 1e-3)); +ok(near(csch(100), 7.4402e-44, 1e-3)); ok(near(tanh(100), 1)); ok(near(coth(100), 1)); -ok(near(sinh(-100), eval '-1.3441e+43', 1e-3)); -ok(near(sech(-100), eval ' 7.4402e-44', 1e-3)); -ok(near(cosh(-100), eval ' 1.3441e+43', 1e-3)); -ok(near(csch(-100), eval '-7.4402e-44', 1e-3)); +ok(near(sinh(-100), -1.3441e+43, 1e-3)); +ok(near(sech(-100), 7.4402e-44, 1e-3)); +ok(near(cosh(-100), 1.3441e+43, 1e-3)); +ok(near(csch(-100), -7.4402e-44, 1e-3)); ok(near(tanh(-100), -1)); ok(near(coth(-100), -1)); @@ -356,8 +364,6 @@ cmp_ok(csch(-1e5), '==', 0); cmp_ok(tanh(-1e5), '==', -1); cmp_ok(coth(-1e5), '==', -1); -} - print "# great_circle_distance with small angles\n"; for my $e (qw(1e-2 1e-3 1e-4 1e-5)) { diff --git a/gnu/usr.bin/perl/cpan/Math-Complex/t/underbar.t b/gnu/usr.bin/perl/cpan/Math-Complex/t/underbar.t index 809e8805a05..643e86655c5 100755 --- a/gnu/usr.bin/perl/cpan/Math-Complex/t/underbar.t +++ b/gnu/usr.bin/perl/cpan/Math-Complex/t/underbar.t @@ -5,13 +5,12 @@ use Test::More; -use strict; -use warnings; - my @f = qw(abs cos exp log sin sqrt); plan tests => scalar @f; +use strict; + use Math::Complex; my %CORE; diff --git a/gnu/usr.bin/perl/cpan/Memoize/t/array_confusion.t b/gnu/usr.bin/perl/cpan/Memoize/t/array_confusion.t index 4ad6c960ef7..44847c36b77 100755 --- a/gnu/usr.bin/perl/cpan/Memoize/t/array_confusion.t +++ b/gnu/usr.bin/perl/cpan/Memoize/t/array_confusion.t @@ -2,7 +2,6 @@ use lib '..'; use Memoize 'memoize', 'unmemoize'; -use Test::More; sub reff { return [1,2,3]; @@ -13,20 +12,20 @@ sub listf { return (1,2,3); } -sub f17 { return 17 } - -plan tests => 7; +print "1..6\n"; memoize 'reff', LIST_CACHE => 'MERGE'; +print "ok 1\n"; memoize 'listf'; +print "ok 2\n"; $s = reff(); @a = reff(); -is(scalar(@a), 1, "reff list context"); +print @a == 1 ? "ok 3\n" : "not ok 3\n"; $s = listf(); @a = listf(); -is(scalar(@a), 3, "listf list context"); +print @a == 3 ? "ok 4\n" : "not ok 4\n"; unmemoize 'reff'; memoize 'reff', LIST_CACHE => 'MERGE'; @@ -35,13 +34,10 @@ memoize 'listf'; @a = reff(); $s = reff(); -is(scalar @a, 1, "reff list context"); +print @a == 1 ? "ok 5\n" : "not ok 5\n"; @a = listf(); $s = listf(); -is(scalar @a, 3, "listf list context"); +print @a == 3 ? "ok 6\n" : "not ok 6\n"; + -memoize 'f17', SCALAR_CACHE => 'MERGE'; -is(f17(), 17, "f17 first call"); -is(f17(), 17, "f17 second call"); -is(scalar(f17()), 17, "f17 scalar context call"); diff --git a/gnu/usr.bin/perl/cpan/Memoize/t/errors.t b/gnu/usr.bin/perl/cpan/Memoize/t/errors.t index 90bc29826b8..43e77b910cf 100755 --- a/gnu/usr.bin/perl/cpan/Memoize/t/errors.t +++ b/gnu/usr.bin/perl/cpan/Memoize/t/errors.t @@ -21,7 +21,7 @@ $n = 4; my $dummyfile = './dummydb'; use Fcntl; my %args = ( DB_File => [], - GDBM_File => [$dummyfile, \&GDBM_File::GDBM_NEWDB, 0666], + GDBM_File => [$dummyfile, 2, 0666], ODBM_File => [$dummyfile, O_RDWR|O_CREAT, 0666], NDBM_File => [$dummyfile, O_RDWR|O_CREAT, 0666], SDBM_File => [$dummyfile, O_RDWR|O_CREAT, 0666], @@ -29,7 +29,7 @@ my %args = ( DB_File => [], for $mod (qw(DB_File GDBM_File SDBM_File ODBM_File NDBM_File)) { eval { require "$mod.pm"; - tie my %cache => $mod, map { (ref($_) eq 'CODE') ? &$_ : $_ } @{$args{$mod}}; + tie my %cache => $mod, @{$args{$mod}}; memoize(sub {}, LIST_CACHE => [HASH => \%cache ]); }; print $@ =~ /can only store scalars/ diff --git a/gnu/usr.bin/perl/cpan/Memoize/t/speed.t b/gnu/usr.bin/perl/cpan/Memoize/t/speed.t index c4b838192d8..6d219065736 100755 --- a/gnu/usr.bin/perl/cpan/Memoize/t/speed.t +++ b/gnu/usr.bin/perl/cpan/Memoize/t/speed.t @@ -56,7 +56,7 @@ $N = 1; $ELAPSED = 0; -my $LONG_RUN = 11; +my $LONG_RUN = 10; while (1) { my $start = time; @@ -88,11 +88,10 @@ $COUNT=0; $start = time; $RESULT2 = fib($N); $ELAPSED2 = time - $start + .001; # prevent division by 0 errors + print (($RESULT == $RESULT2) ? "ok 1\n" : "not ok 1\n"); # If it's not ten times as fast, something is seriously wrong. -print "# ELAPSED2=$ELAPSED2 seconds.\n"; print (($ELAPSED/$ELAPSED2 > 10) ? "ok 2\n" : "not ok 2\n"); - # If it called the function more than $N times, it wasn't memoized properly print (($COUNT > $N) ? "ok 3\n" : "not ok 3\n"); @@ -101,8 +100,8 @@ $COUNT = 0; $start = time; $RESULT2 = fib($N); $ELAPSED2 = time - $start + .001; # prevent division by 0 errors + print (($RESULT == $RESULT2) ? "ok 4\n" : "not ok 4\n"); -print "# ELAPSED2=$ELAPSED2 seconds.\n"; print (($ELAPSED/$ELAPSED2 > 10) ? "ok 5\n" : "not ok 5\n"); # This time it shouldn't have called the function at all. print ($COUNT == 0 ? "ok 6\n" : "not ok 6\n"); -- cgit v1.2.3