From: Nick Ing-Simmons Date: Tue, 26 Feb 2002 13:48:55 +0000 (+0000) Subject: Integrate mainline X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2cdc9b22730c34a34c3c15d3c3097510ac4ecd5d;p=p5sagit%2Fp5-mst-13.2.git Integrate mainline p4raw-id: //depot/perlio@14885 --- 2cdc9b22730c34a34c3c15d3c3097510ac4ecd5d diff --cc lib/Math/BigInt/t/bare_mbf.t index 0000000,78668c3..2e669f8 mode 000000,100644..100644 --- a/lib/Math/BigInt/t/bare_mbf.t +++ b/lib/Math/BigInt/t/bare_mbf.t @@@ -1,0 -1,39 +1,39 @@@ + #!/usr/bin/perl -w + + use Test; + use strict; + + BEGIN + { + $| = 1; + # to locate the testing files + my $location = $0; $location =~ s/bare_mbf.t//i; + if ($ENV{PERL_CORE}) + { + # testing with the core distribution + @INC = qw(../t/lib); + } + unshift @INC, '../lib'; + if (-d 't') + { + chdir 't'; + require File::Spec; + unshift @INC, File::Spec->catdir(File::Spec->updir, $location); + } + else + { + unshift @INC, $location; + } + print "# INC = @INC\n"; + - plan tests => 1586; ++ plan tests => 1585; + } + + use Math::BigInt lib => 'BareCalc'; + use Math::BigFloat; + + use vars qw ($class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL); + $class = "Math::BigFloat"; + $CL = "Math::BigInt::BareCalc"; + + require 'bigfltpm.inc'; # all tests here for sharing diff --cc lib/Math/BigInt/t/config.t index 0000000,4ff46de..5c660a7 mode 000000,100644..100644 --- a/lib/Math/BigInt/t/config.t +++ b/lib/Math/BigInt/t/config.t @@@ -1,0 -1,36 +1,36 @@@ + #!/usr/bin/perl -w + + use strict; + use Test; + + BEGIN + { + $| = 1; + chdir 't' if -d 't'; + unshift @INC, '../lib'; # for running manually + plan tests => 10; + } + + # test whether Math::BigInt constant works + + use Math::BigInt; + + ok (Math::BigInt->can('config')); + + my $cfg = Math::BigInt->config(); + + ok (ref($cfg),'HASH'); + + ok ($cfg->{lib},'Math::BigInt::Calc'); -ok ($cfg->{lib_version},'0.23'); ++ok ($cfg->{lib_version},'0.22'); + ok ($cfg->{class},'Math::BigInt'); + ok ($cfg->{upgrade}||'',''); + ok ($cfg->{div_scale},40); + + ok ($cfg->{precision}||0,0); # should test for undef + ok ($cfg->{accuracy}||0,0); + + ok ($cfg->{round_mode},'even'); + + # all tests done + diff --cc lib/Math/BigInt/t/inf_nan.t index 0000000,b62ae1c..38ebe03 mode 000000,100644..100644 --- a/lib/Math/BigInt/t/inf_nan.t +++ b/lib/Math/BigInt/t/inf_nan.t @@@ -1,0 -1,270 +1,255 @@@ + #!/usr/bin/perl -w + -# test inf/NaN handling all in one place -# Thanx to Jarkko for the excellent explanations and the tables - + use Test; + use strict; + + BEGIN + { - $| = 1; # 7 values 6 groups 4 oprators 2 classes - plan tests => 7 * 6 * 4 * 2; ++ $| = 1; ++ plan tests => 7*6*4; + chdir 't' if -d 't'; + unshift @INC, '../lib'; + } + + use Math::BigInt; -use Math::BigFloat; + + my (@args,$x,$y,$z); + + # + + foreach (qw/ + -inf:-inf:-inf + -1:-inf:-inf + -0:-inf:-inf + 0:-inf:-inf + 1:-inf:-inf + inf:-inf:NaN + NaN:-inf:NaN + + -inf:-1:-inf + -1:-1:-2 + -0:-1:-1 + 0:-1:-1 + 1:-1:0 + inf:-1:inf + NaN:-1:NaN + + -inf:0:-inf + -1:0:-1 + -0:0:0 + 0:0:0 + 1:0:1 + inf:0:inf + NaN:0:NaN + + -inf:1:-inf + -1:1:0 + -0:1:1 + 0:1:1 + 1:1:2 + inf:1:inf + NaN:1:NaN + + -inf:inf:NaN + -1:inf:inf + -0:inf:inf + 0:inf:inf + 1:inf:inf + inf:inf:inf + NaN:inf:NaN + + -inf:NaN:NaN + -1:NaN:NaN + -0:NaN:NaN + 0:NaN:NaN + 1:NaN:NaN + inf:NaN:NaN + NaN:NaN:NaN + /) + { + @args = split /:/,$_; - for my $class (qw/Math::BigInt Math::BigFloat/) - { - $x = $class->new($args[0]); - $y = $class->new($args[1]); - $args[2] = '0' if $args[2] eq '-0'; # BigInt/Float hasn't got -0 - print "# $class $args[0] + $args[1] should be $args[2] but is $x\n", - if !ok ($x->badd($y)->bstr(),$args[2]); - } ++ $x = Math::BigInt->new($args[0]); ++ $y = Math::BigInt->new($args[1]); ++ $args[2] = '0' if $args[2] eq '-0'; # BigInt hasn't got -0 ++ print "# $args[0] + $args[1] should be $args[2] but is ",$x->bstr(),"\n" ++ if !ok ($x->badd($y)->bstr(),$args[2]); + } + + # - + foreach (qw/ + -inf:-inf:NaN + -1:-inf:inf + -0:-inf:inf + 0:-inf:inf + 1:-inf:inf + inf:-inf:inf + NaN:-inf:NaN + + -inf:-1:-inf + -1:-1:0 + -0:-1:1 + 0:-1:1 + 1:-1:2 + inf:-1:inf + NaN:-1:NaN + + -inf:0:-inf + -1:0:-1 + -0:0:-0 + 0:0:0 + 1:0:1 + inf:0:inf + NaN:0:NaN + + -inf:1:-inf + -1:1:-2 + -0:1:-1 + 0:1:-1 + 1:1:0 + inf:1:inf + NaN:1:NaN + + -inf:inf:-inf + -1:inf:-inf + -0:inf:-inf + 0:inf:-inf + 1:inf:-inf + inf:inf:NaN + NaN:inf:NaN + + -inf:NaN:NaN + -1:NaN:NaN + -0:NaN:NaN + 0:NaN:NaN + 1:NaN:NaN + inf:NaN:NaN + NaN:NaN:NaN + /) + { + @args = split /:/,$_; - for my $class (qw/Math::BigInt Math::BigFloat/) - { - $x = $class->new($args[0]); - $y = $class->new($args[1]); - $args[2] = '0' if $args[2] eq '-0'; # BigInt/Float hasn't got -0 - print "# $class $args[0] - $args[1] should be $args[2] but is $x\n" - if !ok ($x->bsub($y)->bstr(),$args[2]); - } ++ $x = Math::BigInt->new($args[0]); ++ $y = Math::BigInt->new($args[1]); ++ $args[2] = '0' if $args[2] eq '-0'; # BigInt hasn't got -0 ++ print "# $args[0] - $args[1] should be $args[2] but is $x\n" ++ if !ok ($x->bsub($y)->bstr(),$args[2]); + } + + # * + foreach (qw/ + -inf:-inf:inf + -1:-inf:inf + -0:-inf:NaN + 0:-inf:NaN + 1:-inf:-inf + inf:-inf:-inf + NaN:-inf:NaN + + -inf:-1:inf + -1:-1:1 + -0:-1:0 + 0:-1:-0 + 1:-1:-1 + inf:-1:-inf + NaN:-1:NaN + + -inf:0:NaN + -1:0:-0 + -0:0:-0 + 0:0:0 + 1:0:0 + inf:0:NaN + NaN:0:NaN + + -inf:1:-inf + -1:1:-1 + -0:1:-0 + 0:1:0 + 1:1:1 + inf:1:inf + NaN:1:NaN + + -inf:inf:-inf + -1:inf:-inf + -0:inf:NaN + 0:inf:NaN + 1:inf:inf + inf:inf:inf + NaN:inf:NaN + + -inf:NaN:NaN + -1:NaN:NaN + -0:NaN:NaN + 0:NaN:NaN + 1:NaN:NaN + inf:NaN:NaN + NaN:NaN:NaN + /) + { + @args = split /:/,$_; - for my $class (qw/Math::BigInt Math::BigFloat/) - { - $x = $class->new($args[0]); - $y = $class->new($args[1]); - $args[2] = '0' if $args[2] eq '-0'; # BigInt/Float hasn't got -0 - $args[2] = '0' if $args[2] eq '-0'; # BigInt hasn't got -0 - print "# $class $args[0] * $args[1] should be $args[2] but is $x\n" - if !ok ($x->bmul($y)->bstr(),$args[2]); - } ++ $x = Math::BigInt->new($args[0]); ++ $y = Math::BigInt->new($args[1]); ++ $args[2] = '0' if $args[2] eq '-0'; # BigInt hasn't got -0 ++ print "# $args[0] * $args[1] should be $args[2] but is $x\n" ++ if !ok ($x->bmul($y)->bstr(),$args[2]); + } + + # / + foreach (qw/ + -inf:-inf:NaN + -1:-inf:0 + -0:-inf:0 + 0:-inf:-0 + 1:-inf:-0 + inf:-inf:NaN + NaN:-inf:NaN + + -inf:-1:inf + -1:-1:1 + -0:-1:0 + 0:-1:-0 + 1:-1:-1 + inf:-1:-inf + NaN:-1:NaN + + -inf:0:-inf + -1:0:-inf + -0:0:NaN + 0:0:NaN + 1:0:inf + inf:0:inf + NaN:0:NaN + + -inf:1:-inf + -1:1:-1 + -0:1:-0 + 0:1:0 + 1:1:1 + inf:1:inf + NaN:1:NaN + + -inf:inf:NaN + -1:inf:-0 + -0:inf:-0 + 0:inf:0 + 1:inf:0 + inf:inf:NaN + NaN:inf:NaN + + -inf:NaN:NaN + -1:NaN:NaN + -0:NaN:NaN + 0:NaN:NaN + 1:NaN:NaN + inf:NaN:NaN + NaN:NaN:NaN + /) + { + @args = split /:/,$_; - for my $class (qw/Math::BigInt Math::BigFloat/) - { - $x = $class->new($args[0]); - $y = $class->new($args[1]); - $args[2] = '0' if $args[2] eq '-0'; # BigInt/Float hasn't got -0 - print "# $class $args[0] / $args[1] should be $args[2] but is $x\n" - if !ok ($x->bdiv($y)->bstr(),$args[2]); - } ++ $x = Math::BigInt->new($args[0]); ++ $y = Math::BigInt->new($args[1]); ++ $args[2] = '0' if $args[2] eq '-0'; # BigInt hasn't got -0 ++ print "# $args[0] / $args[1] should be $args[2] but is $x\n" ++ if !ok ($x->bdiv($y)->bstr(),$args[2]); ++ + } + ++