From: Andy Dougherty Date: Fri, 31 May 2002 15:52:34 +0000 (-0400) Subject: RE: [doughera@lafayette.edu: [PATCH] Math/BigInt/t/mbi_rand.t pr X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f95ec2936187b64684ea63374979a80ef302c908;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/lib/Math/BigInt/t/mbi_rand.t b/lib/Math/BigInt/t/mbi_rand.t index 69be2d4..b6d59ea 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); } +