summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndy Dougherty <doughera@lafayette.edu>2002-05-31 11:52:34 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2002-05-31 18:52:26 +0000
commitf95ec2936187b64684ea63374979a80ef302c908 (patch)
treef0bab8f4a2a6af99460186f175fc8b8bc4633943 /lib
parent9d8ddb6ab7d965c3ca8acc711c559e645d0d8e0d (diff)
downloadperl-f95ec2936187b64684ea63374979a80ef302c908.tar.gz
RE: [doughera@lafayette.edu: [PATCH] Math/BigInt/t/mbi_rand.t pr
Message-ID: Pine.SOL.4.10.10205311550480.19295-100000@maxwell.phys.lafayette.edu> p4raw-id: //depot/perl@16933
Diffstat (limited to 'lib')
-rw-r--r--lib/Math/BigInt/t/mbi_rand.t8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Math/BigInt/t/mbi_rand.t b/lib/Math/BigInt/t/mbi_rand.t
index 69be2d4ac4..b6d59ea6f6 100644
--- a/lib/Math/BigInt/t/mbi_rand.t
+++ b/lib/Math/BigInt/t/mbi_rand.t
@@ -25,7 +25,8 @@ my $length = 128;
# If you get a failure here, please re-run the test with the printed seed
# value as input: perl t/mbi_rand.t seed
-my $seed = int(rand(65537)); print "# seed: $seed\n"; srand($seed);
+my $seed = ($#ARGV == 0) ? $ARGV[0] : int(rand(65537));
+print "# seed: $seed\n"; srand($seed);
my ($A,$B,$As,$Bs,$ADB,$AMB,$la,$lb);
my $two = Math::BigInt->new(2);
@@ -40,8 +41,12 @@ for (my $i = 0; $i < $count; $i++)
# together digits, we would end up with "1272398823211223" etc.
while (length($As) < $la) { $As .= int(rand(100)) x int(rand(16)); }
while (length($Bs) < $lb) { $Bs .= int(rand(100)) x int(rand(16)); }
+ # Strip leading zeros, but don't let As and Bs end up empty.
$As =~ s/^0+//; $Bs =~ s/^0+//;
+ $As = '0' if $As eq '';
+ $Bs = '0' if $Bs eq '';
$A = $c->new($As); $B = $c->new($Bs);
+ # print "# As $As\n# Bs $Bs\n";
# print "# A $A\n# B $B\n";
if ($A->is_zero() || $B->is_zero())
{
@@ -59,3 +64,4 @@ for (my $i = 0; $i < $count; $i++)
unless ok ($ADB*$A+$two*$AMB-$AMB,$Bs);
}
+