From 8f675a64451b3c11c234adeda6be313fb8d03f6c Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Tue, 26 Mar 2002 19:54:48 +0000 Subject: Upgrade to Math::BigInt 1.56, Math::BigRat 0.05, and bignum 0.11, from Tels. p4raw-id: //depot/perl@15523 --- lib/Math/BigInt/t/bare_mbf.t | 4 ---- lib/Math/BigInt/t/bigfltpm.t | 8 ++++++-- lib/Math/BigInt/t/config.t | 2 +- lib/Math/BigInt/t/constant.t | 14 +++++++------- lib/Math/BigInt/t/mbi_rand.t | 8 +++++--- lib/Math/BigInt/t/require.t | 28 +++++++++++++++++++++------- lib/Math/BigInt/t/upgrade.t | 24 ++++++++++++++++++++---- lib/Math/BigInt/t/use.t | 29 ++++++++++++++++++++++++----- lib/Math/BigInt/t/use_lib1.t | 22 +++++++++++++++++++--- lib/Math/BigInt/t/use_lib2.t | 23 ++++++++++++++++++++--- lib/Math/BigInt/t/use_lib3.t | 23 ++++++++++++++++++++--- lib/Math/BigInt/t/use_lib4.t | 23 ++++++++++++++++++++--- lib/Math/BigInt/t/with_sub.t | 43 +++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 206 insertions(+), 45 deletions(-) create mode 100644 lib/Math/BigInt/t/with_sub.t (limited to 'lib/Math/BigInt') diff --git a/lib/Math/BigInt/t/bare_mbf.t b/lib/Math/BigInt/t/bare_mbf.t index abeb8c257c..a160c7cf7e 100644 --- a/lib/Math/BigInt/t/bare_mbf.t +++ b/lib/Math/BigInt/t/bare_mbf.t @@ -29,10 +29,6 @@ BEGIN plan tests => 1601; } -#use Math::BigInt lib => 'BareCalc'; -#use Math::BigFloat; - -# use Math::BigInt; use Math::BigFloat lib => 'BareCalc'; use Math::BigFloat lib => 'BareCalc'; use vars qw ($class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL); diff --git a/lib/Math/BigInt/t/bigfltpm.t b/lib/Math/BigInt/t/bigfltpm.t index a3c0131c15..871365acff 100755 --- a/lib/Math/BigInt/t/bigfltpm.t +++ b/lib/Math/BigInt/t/bigfltpm.t @@ -26,7 +26,8 @@ BEGIN } print "# INC = @INC\n"; - plan tests => 1601; + plan tests => 1601 + + 2; # own tests } use Math::BigInt; @@ -35,5 +36,8 @@ use Math::BigFloat; use vars qw ($class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL); $class = "Math::BigFloat"; $CL = "Math::BigInt::Calc"; - + +ok ($class->config()->{class},$class); +ok ($class->config()->{with},'Math::BigInt'); + require 'bigfltpm.inc'; # all tests here for sharing diff --git a/lib/Math/BigInt/t/config.t b/lib/Math/BigInt/t/config.t index db0c27ef80..da574bf362 100644 --- a/lib/Math/BigInt/t/config.t +++ b/lib/Math/BigInt/t/config.t @@ -22,7 +22,7 @@ my $cfg = Math::BigInt->config(); ok (ref($cfg),'HASH'); ok ($cfg->{lib},'Math::BigInt::Calc'); -ok ($cfg->{lib_version},'0.26'); +ok ($cfg->{lib_version}, $Math::BigInt::Calc::VERSION); ok ($cfg->{class},'Math::BigInt'); ok ($cfg->{upgrade}||'',''); ok ($cfg->{div_scale},40); diff --git a/lib/Math/BigInt/t/constant.t b/lib/Math/BigInt/t/constant.t index 3c9b13fd46..bdc73c785e 100644 --- a/lib/Math/BigInt/t/constant.t +++ b/lib/Math/BigInt/t/constant.t @@ -16,13 +16,13 @@ use Math::BigInt ':constant'; ok (2 ** 255,'57896044618658097711785492504343953926634992332820282019728792003956564819968'); { - no warnings 'portable'; - # hexadecimal constants - ok (0x123456789012345678901234567890, - Math::BigInt->new('0x123456789012345678901234567890')); - # binary constants - ok (0b01010100011001010110110001110011010010010110000101101101, - Math::BigInt->new( + no warnings 'portable'; +# hexadecimal constants +ok (0x123456789012345678901234567890, + Math::BigInt->new('0x123456789012345678901234567890')); +# binary constants +ok (0b01010100011001010110110001110011010010010110000101101101, + Math::BigInt->new( '0b01010100011001010110110001110011010010010110000101101101')); } diff --git a/lib/Math/BigInt/t/mbi_rand.t b/lib/Math/BigInt/t/mbi_rand.t index 1f19c6b82b..aa020dccab 100644 --- a/lib/Math/BigInt/t/mbi_rand.t +++ b/lib/Math/BigInt/t/mbi_rand.t @@ -39,7 +39,7 @@ for (my $i = 0; $i < $count; $i++) while (length($A) < $la) { $A .= int(rand(100)) x int(rand(16)); } while (length($B) < $lb) { $B .= int(rand(100)) x int(rand(16)); } $A = $c->new($A); $B = $c->new($B); - print "# A $A\n# B $B\n"; + # print "# A $A\n# B $B\n"; if ($A->is_zero() || $B->is_zero()) { ok (1,1); ok (1,1); next; @@ -47,10 +47,12 @@ for (my $i = 0; $i < $count; $i++) # check that int(A/B)*B + A % B == A holds for all inputs # $X = ($A/$B)*$B + 2 * ($A % $B) - ($A % $B); ($ADB,$AMB) = $A->copy()->bdiv($B); - ok ($A,$ADB*$B+2*$AMB-$AMB); + print "# ". join(' ',Math::BigInt::Calc->_base_len()),"\n" + unless ok ($ADB*$B+2*$AMB-$AMB,$A); # swap 'em and try this, too # $X = ($B/$A)*$A + $B % $A; ($ADB,$AMB) = $B->copy()->bdiv($A); - ok ($B,$ADB*$A+2*$AMB-$AMB); + print "# ". join(' ',Math::BigInt::Calc->_base_len()),"\n" + unless ok ($ADB*$A+2*$AMB-$AMB,$B); } diff --git a/lib/Math/BigInt/t/require.t b/lib/Math/BigInt/t/require.t index de109f1f96..2775a77a6f 100644 --- a/lib/Math/BigInt/t/require.t +++ b/lib/Math/BigInt/t/require.t @@ -6,19 +6,33 @@ use Test; BEGIN { $| = 1; - chdir 't' if -d 't'; - unshift @INC, '../lib'; # for running manually + # to locate the testing files + my $location = $0; $location =~ s/require.t//i; + if ($ENV{PERL_CORE}) + { + # testing with the core distribution + @INC = qw(../t/lib); + } + unshift @INC, qw(../lib); # to locate the modules + 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 => 1; } -my ($try,$ans,$x); +my ($x); require Math::BigInt; $x = Math::BigInt->new(1); ++$x; -#$try = 'require Math::BigInt; $x = Math::BigInt->new(1); ++$x;'; -#$ans = eval $try || 'undef'; -#print "# For '$try'\n" if (!ok "$ans" , '2' ); - ok ($x||'undef',2); # all tests done diff --git a/lib/Math/BigInt/t/upgrade.t b/lib/Math/BigInt/t/upgrade.t index 5c8cf5fa66..28d2ce1dac 100644 --- a/lib/Math/BigInt/t/upgrade.t +++ b/lib/Math/BigInt/t/upgrade.t @@ -6,10 +6,26 @@ use strict; BEGIN { $| = 1; - unshift @INC, '../lib'; # for running manually - my $location = $0; $location =~ s/upgrade.t//; - unshift @INC, $location; # to locate the testing files - chdir 't' if -d 't'; + # to locate the testing files + my $location = $0; $location =~ s/upgrade.t//i; + if ($ENV{PERL_CORE}) + { + # testing with the core distribution + @INC = qw(../t/lib); + } + unshift @INC, qw(../lib); # to locate the modules + 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 => 2068 + 2; # our own tests } diff --git a/lib/Math/BigInt/t/use.t b/lib/Math/BigInt/t/use.t index c52509839d..1f09f5e43c 100644 --- a/lib/Math/BigInt/t/use.t +++ b/lib/Math/BigInt/t/use.t @@ -1,8 +1,9 @@ #!/usr/bin/perl -w -# use Module(); doesn't call impor() - thanx for cpan test David. M. Town and -# Andreas Marcel Riechert for spotting it. It is fixed by the same code that -# fixes require Math::BigInt, but we make a test to be sure it really works. +# use Module(); doesn't call import() - thanx for cpan testers David. M. Town +# and Andreas Marcel Riechert for spotting it. It is fixed by the same code +# that fixes require Math::BigInt, but we make a test to be sure it really +# works. use strict; use Test; @@ -10,8 +11,26 @@ use Test; BEGIN { $| = 1; - chdir 't' if -d 't'; - unshift @INC, '../lib'; # for running manually + # to locate the testing files + my $location = $0; $location =~ s/use.t//i; + if ($ENV{PERL_CORE}) + { + # testing with the core distribution + @INC = qw(../t/lib); + } + unshift @INC, qw(../lib); # to locate the modules + 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 => 1; } diff --git a/lib/Math/BigInt/t/use_lib1.t b/lib/Math/BigInt/t/use_lib1.t index d737081a57..a6eda82b37 100644 --- a/lib/Math/BigInt/t/use_lib1.t +++ b/lib/Math/BigInt/t/use_lib1.t @@ -9,10 +9,26 @@ use Test; BEGIN { $| = 1; - chdir 't' if -d 't'; - unshift @INC, '../lib'; # for running manually - unshift @INC, 'lib'; + # to locate the testing files + my $location = $0; $location =~ s/use_lib1.t//i; + if ($ENV{PERL_CORE}) + { + # testing with the core distribution + @INC = qw(../t/lib); + } + unshift @INC, qw(../lib); # to locate the modules + 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 => 2; } diff --git a/lib/Math/BigInt/t/use_lib2.t b/lib/Math/BigInt/t/use_lib2.t index 6dd744f298..aa4ba5fbe2 100644 --- a/lib/Math/BigInt/t/use_lib2.t +++ b/lib/Math/BigInt/t/use_lib2.t @@ -9,9 +9,26 @@ use Test; BEGIN { $| = 1; - chdir 't' if -d 't'; - unshift @INC, '../lib'; # for running manually - unshift @INC, 'lib'; + # to locate the testing files + my $location = $0; $location =~ s/use_lib2.t//i; + if ($ENV{PERL_CORE}) + { + # testing with the core distribution + @INC = qw(../t/lib); + } + unshift @INC, qw(../lib); # to locate the modules + 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 => 2; } diff --git a/lib/Math/BigInt/t/use_lib3.t b/lib/Math/BigInt/t/use_lib3.t index 3b43544660..b46b939551 100644 --- a/lib/Math/BigInt/t/use_lib3.t +++ b/lib/Math/BigInt/t/use_lib3.t @@ -9,9 +9,26 @@ use Test; BEGIN { $| = 1; - chdir 't' if -d 't'; - unshift @INC, '../lib'; # for running manually - unshift @INC, 'lib'; + # to locate the testing files + my $location = $0; $location =~ s/use_lib3.t//i; + if ($ENV{PERL_CORE}) + { + # testing with the core distribution + @INC = qw(../t/lib); + } + unshift @INC, qw(../lib); # to locate the modules + 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 => 2; } diff --git a/lib/Math/BigInt/t/use_lib4.t b/lib/Math/BigInt/t/use_lib4.t index 079ba6d05f..bfd85d5f70 100644 --- a/lib/Math/BigInt/t/use_lib4.t +++ b/lib/Math/BigInt/t/use_lib4.t @@ -10,9 +10,26 @@ use Test; BEGIN { $| = 1; - chdir 't' if -d 't'; - unshift @INC, '../lib'; # for running manually - unshift @INC, 'lib'; + # to locate the testing files + my $location = $0; $location =~ s/use_lib4.t//i; + if ($ENV{PERL_CORE}) + { + # testing with the core distribution + @INC = qw(../t/lib); + } + unshift @INC, qw(../lib); # to locate the modules + 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 => 2; } diff --git a/lib/Math/BigInt/t/with_sub.t b/lib/Math/BigInt/t/with_sub.t new file mode 100644 index 0000000000..07aa3c20f8 --- /dev/null +++ b/lib/Math/BigInt/t/with_sub.t @@ -0,0 +1,43 @@ +#!/usr/bin/perl -w + +# Test use Math::BigFloat with => 'Math::BigInt::SomeSubclass'; + +use Test; +use strict; + +BEGIN + { + $| = 1; + # to locate the testing files + my $location = $0; $location =~ s/with_sub.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 => 1601 + + 1; + } + +use Math::BigFloat with => 'Math::BigInt::Subclass'; + +use vars qw ($class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL); +$class = "Math::BigFloat"; +$CL = "Math::BigInt::Calc"; + +ok (Math::BigFloat->config()->{with}, 'Math::BigInt::Subclass'); + +require 'bigfltpm.inc'; # all tests here for sharing -- cgit v1.2.1