summaryrefslogtreecommitdiff
path: root/lib/Math/BigInt/t
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-03-20 21:20:50 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-03-20 21:20:50 +0000
commita87115f0a1b74f765307464de281024d76c71ad6 (patch)
tree51f85b871e1453b41fd88749d09bfb38f8c94f96 /lib/Math/BigInt/t
parentfdac53cdf7b8b7030448d0e63e6537e85a7a19df (diff)
downloadperl-a87115f0a1b74f765307464de281024d76c71ad6.tar.gz
Upgrade to Math::BigInt 1.75, by Tels
p4raw-id: //depot/perl@24048
Diffstat (limited to 'lib/Math/BigInt/t')
-rw-r--r--lib/Math/BigInt/t/bare_mbi.t2
-rw-r--r--lib/Math/BigInt/t/bigintpm.inc2
-rwxr-xr-xlib/Math/BigInt/t/bigintpm.t2
-rw-r--r--lib/Math/BigInt/t/fallback.t20
-rw-r--r--lib/Math/BigInt/t/mbi_rand.t28
-rwxr-xr-xlib/Math/BigInt/t/sub_mbi.t2
6 files changed, 38 insertions, 18 deletions
diff --git a/lib/Math/BigInt/t/bare_mbi.t b/lib/Math/BigInt/t/bare_mbi.t
index bf08a90f34..b171e9382f 100644
--- a/lib/Math/BigInt/t/bare_mbi.t
+++ b/lib/Math/BigInt/t/bare_mbi.t
@@ -26,7 +26,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 3012;
+ plan tests => 3014;
}
use Math::BigInt lib => 'BareCalc';
diff --git a/lib/Math/BigInt/t/bigintpm.inc b/lib/Math/BigInt/t/bigintpm.inc
index 2a2bfe11e9..82d0cb2484 100644
--- a/lib/Math/BigInt/t/bigintpm.inc
+++ b/lib/Math/BigInt/t/bigintpm.inc
@@ -1633,6 +1633,8 @@ inf:0:inf
9999999_9999999_9999999_9999999:100_0000000_0000000_0000000:99999
9999999_9999999_9999999_9999999:10_0000000_0000000_0000000:999999
9999999_9999999_9999999_9999999:1_0000000_0000000_0000000:9999999
+# bug with shortcut in Calc 0.44
+949418181818187070707070707070707070:181818181853535353535353535353535353:5
&bmodinv
# format: number:modulus:result
# bmodinv Data errors
diff --git a/lib/Math/BigInt/t/bigintpm.t b/lib/Math/BigInt/t/bigintpm.t
index 16f4d32a30..9923256a89 100755
--- a/lib/Math/BigInt/t/bigintpm.t
+++ b/lib/Math/BigInt/t/bigintpm.t
@@ -10,7 +10,7 @@ BEGIN
my $location = $0; $location =~ s/bigintpm.t//;
unshift @INC, $location; # to locate the testing files
chdir 't' if -d 't';
- plan tests => 3012;
+ plan tests => 3014;
}
use Math::BigInt;
diff --git a/lib/Math/BigInt/t/fallback.t b/lib/Math/BigInt/t/fallback.t
index e348d9240d..00f1dfd74b 100644
--- a/lib/Math/BigInt/t/fallback.t
+++ b/lib/Math/BigInt/t/fallback.t
@@ -28,11 +28,11 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 8;
+ plan tests => 12;
}
# The tests below test that cos(BigInt) = cos(Scalar) which is DWIM, but not
-# exactly right, ideally cos(BigInt) should truncate to int() and cos(BigFLoat)
+# exactly right, ideally cos(BigInt) should truncate to int() and cos(BigFloat)
# should calculate the result to X digits accuracy. For now, this is better
# than die()ing...
@@ -46,10 +46,16 @@ ok (sin($bi), sin(1));
ok (exp($bi), exp(1));
ok (atan2($bi,$bi), atan2(1,1));
-my $bf = Math::BigInt->new(1);
+my $bf = Math::BigInt->new(0);
-ok (cos($bf), cos(1));
-ok (sin($bf), sin(1));
-ok (exp($bf), exp(1));
-ok (atan2($bf,$bf), atan2(1,1));
+ok (cos($bf), cos(0));
+ok (sin($bf), sin(0));
+ok (exp($bf), exp(0));
+ok (atan2($bi,$bf), atan2(1,0));
+ok (atan2($bf,$bi), atan2(0,1));
+
+my $bone = Math::BigInt->new(1);
+ok (cos($bone), cos(1));
+ok (sin($bone), sin(1));
+ok (exp($bone), exp(1));
diff --git a/lib/Math/BigInt/t/mbi_rand.t b/lib/Math/BigInt/t/mbi_rand.t
index dd280515f9..d24920f68b 100644
--- a/lib/Math/BigInt/t/mbi_rand.t
+++ b/lib/Math/BigInt/t/mbi_rand.t
@@ -28,6 +28,12 @@ my $length = 128;
my $seed = ($#ARGV == 0) ? $ARGV[0] : int(rand(1165537));
print "# seed: $seed\n"; srand($seed);
+print "# lib: ", Math::BigInt->config()->{lib},"\n";
+if (Math::BigInt->config()->{lib} =~ /::Calc/)
+ {
+ print "# base len: ", scalar Math::BigInt::Calc->_base_len(),"\n";
+ }
+
my ($A,$B,$As,$Bs,$ADB,$AMB,$la,$lb);
my $two = Math::BigInt->new(2);
for (my $i = 0; $i < $count; $i++)
@@ -46,9 +52,9 @@ for (my $i = 0; $i < $count; $i++)
$As =~ s/^0+//; $Bs =~ s/^0+//;
$As = $As || '0'; $Bs = $Bs || '0';
- # print "# As $As\n# Bs $Bs\n";
+# print "# As $As\n# Bs $Bs\n";
$A = $c->new($As); $B = $c->new($Bs);
- # print "# A $A\n# B $B\n";
+ print "# A $A\n# B $B\n";
if ($A->is_zero() || $B->is_zero())
{
for (1..4) { ok (1,1); } next;
@@ -59,22 +65,28 @@ for (my $i = 0; $i < $count; $i++)
# $X = ($A/$B)*$B + 2 * ($A % $B) - ($A % $B);
($ADB,$AMB) = $A->copy()->bdiv($B);
-# print "# ($A / $B, $A % $B ) = $ADB $AMB\n";
+ print "# ($A / $B, $A % $B ) = $ADB $AMB\n";
print "# seed $seed, ". join(' ',Math::BigInt::Calc->_base_len()),"\n".
"# tried $ADB * $B + $two*$AMB - $AMB\n"
unless ok ($ADB*$B+$two*$AMB-$AMB,$As);
- print "# seed: $seed, \$ADB * \$B / \$B = ", $ADB * $B / $B, " != $ADB (\$B=$B)\n"
- unless ok ($ADB*$B/$B,$ADB);
+ if (ok ($ADB*$B/$B,$ADB))
+ {
+ print "# seed: $seed, \$ADB * \$B / \$B = ", $ADB * $B / $B, " != $ADB (\$B=$B)\n";
+ if (Math::BigInt->config()->{lib} =~ /::Calc/)
+ {
+ print "# ADB->[-1]: ", $ADB->{value}->[-1], " B->[-1]: ", $B->{value}->[-1],"\n";
+ }
+ }
# swap 'em and try this, too
# $X = ($B/$A)*$A + $B % $A;
($ADB,$AMB) = $B->copy()->bdiv($A);
- #print "check: $ADB $AMB";
+ # print "check: $ADB $AMB";
print "# seed $seed, ". join(' ',Math::BigInt::Calc->_base_len()),"\n".
"# tried $ADB * $A + $two*$AMB - $AMB\n"
unless ok ($ADB*$A+$two*$AMB-$AMB,$Bs);
-# print " +$two * $AMB = ",$ADB * $A + $two * $AMB,"\n";
-# print " -$AMB = ",$ADB * $A + $two * $AMB - $AMB,"\n";
+ print "# +$two * $AMB = ",$ADB * $A + $two * $AMB,"\n";
+ print "# -$AMB = ",$ADB * $A + $two * $AMB - $AMB,"\n";
print "# seed $seed, \$ADB * \$A / \$A = ", $ADB * $A / $A, " != $ADB (\$A=$A)\n"
unless ok ($ADB*$A/$A,$ADB);
}
diff --git a/lib/Math/BigInt/t/sub_mbi.t b/lib/Math/BigInt/t/sub_mbi.t
index 4d4fc4eada..9346dcd337 100755
--- a/lib/Math/BigInt/t/sub_mbi.t
+++ b/lib/Math/BigInt/t/sub_mbi.t
@@ -26,7 +26,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 3012
+ plan tests => 3014
+ 5; # +5 own tests
}