This is an automated email from the git hooks/post-receive script. ppm-guest pushed a commit to annotated tag v0.33 in repository libmath-prime-util-perl.
commit 9fd83d718136fca8097cf6368169dba95692c0f6 Author: Dana Jacobsen <d...@acm.org> Date: Mon Nov 18 15:46:03 2013 -0800 Make all tests run with 5.6.2 (with lots of skipping) --- Changes | 6 ++++++ Makefile.PL | 15 +++++++++++++++ lib/Math/Prime/Util.pm | 14 ++++---------- lib/Math/Prime/Util/PP.pm | 4 ++-- t/11-primes.t | 1 + t/16-randomprime.t | 28 ++++++++++----------------- t/17-pseudoprime.t | 11 ++++++----- t/19-moebius.t | 3 +-- t/20-primorial.t | 17 ++-------------- t/22-aks-prime.t | 1 - t/23-primality-proofs.t | 23 +++++++++++++--------- t/32-iterators.t | 26 ++++++++++++++----------- t/80-pp.t | 5 ++++- t/81-bignum.t | 49 +++++++++++++++++++++++------------------------ 14 files changed, 104 insertions(+), 99 deletions(-) diff --git a/Changes b/Changes index a427f30..02cafac 100644 --- a/Changes +++ b/Changes @@ -41,6 +41,12 @@ Revision history for Perl module Math::Prime::Util - chebyshev_theta and chebyshev_psi use segmented sieves. + - More aggressive pruning of tests with 64-bit Perl 5.6. I'd like to + just kill support for systems that can't even add two numbers + correctly, but too many other modules want 5.6 support, and lots of + our functionality *does* work (e.g. primes, prime count, etc.). + + 0.32 2013-10-13 [ADDED] diff --git a/Makefile.PL b/Makefile.PL index d3b6859..02ce49a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,5 +1,20 @@ use ExtUtils::MakeMaker; +my $broken64 = (18446744073709550592 == ~0); +if ($broken64) { + warn <<EOW; + +Your Perl has a broken 64-bit implementation. +Arithmetic operations on numbers larger than 2^53 are wrong. + +Much core functionality will work, but some functions, especially +random primes, will not work for large inputs. + +I highly recommend upgrading to a newer version of Perl. + +EOW +} + WriteMakefile1( NAME => 'Math::Prime::Util', ABSTRACT => 'Utilities related to prime numbers, including fast sieves and factoring', diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm index 3369053..0b87da1 100644 --- a/lib/Math/Prime/Util.pm +++ b/lib/Math/Prime/Util.pm @@ -640,6 +640,8 @@ sub primes { #my $range = $high - $low + 1; my $oddrange = (($high - $low) >> 1) + 1; + croak "Large random primes not supported on old Perl" if $] < 5.008 && $_Config{'maxbits'} > 32 && $oddrange > 4294967295; + # If $low is large (e.g. >10 digits) and $range is small (say ~10k), it # would be fastest to call primes in the range and randomly pick one. I'm # not implementing it now because it seems like a rare case. @@ -860,7 +862,6 @@ sub primes { if $digits <= 6 && int(10**$digits) <= $_XS_MAXVAL; my $bigdigits = $digits >= $_Config{'maxdigits'}; - croak "Large random primes not supported on old Perl" if $] < 5.008 && $_Config{'maxbits'} > 32 && !$bigdigits && $digits > 15; if ($bigdigits && $_Config{'nobigint'}) { _validate_positive_integer($digits, 1, $_Config{'maxdigits'}); # Special case for nobigint and threshold digits @@ -1044,8 +1045,7 @@ sub primes { sub random_maurer_prime { my $k = shift; _validate_num($k, 2) || _validate_positive_integer($k, 2); - if ($k <= $_Config{'maxbits'}) { - croak "Random Maurer not supported on old Perl" if $k > 49 && $] < 5.008 && $_Config{'maxbits'} > 32; + if ($k <= $_Config{'maxbits'} && $] >= 5.008) { return random_nbit_prime($k); } my ($n, $cert) = random_maurer_prime_with_cert($k); @@ -1057,16 +1057,10 @@ sub primes { sub random_maurer_prime_with_cert { my($k) = @_; _validate_num($k, 2) || _validate_positive_integer($k, 2); - if ($] < 5.008 && $_Config{'maxbits'} > 32) { - if ($k <= 49) { - my $n = random_nbit_prime($k); - return ($n, "[MPU - Primality Certificate]\nVersion 1.0\n\nProof for:\nN $n\n\nType Small\nN $n\n"); - } - croak "Random Maurer not supported on old Perl"; - } # Results for random_nbit_prime are proven for all native bit sizes. my $p0 = $_Config{'maxbits'}; + $p0 = 49 if $] < 5.008 && $_Config{'maxbits'} > 49; if ($k <= $p0) { my $n = random_nbit_prime($k); diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm index d17d383..505e421 100644 --- a/lib/Math/Prime/Util/PP.pm +++ b/lib/Math/Prime/Util/PP.pm @@ -1195,16 +1195,16 @@ sub is_frobenius_underwood_pseudoprime { my $fa = $ZERO + 1; my $fb = $ZERO + 2; - my ($x, $t, $np1, $len, $na) = (0, -1, $n+1, 1, undef); + my ($x, $t, $np1, $na) = (0, -1, $n+1, undef); while ( _jacobi($t, $n) != -1 ) { $x++; $t = $x*$x - 4; } + my $len = length($np1->as_bin) - 2; my $result = $x+$x+5; my $multiplier = $x+2; $result %= $n if $result > $n; $multiplier %= $n if $multiplier > $n; - { my $v = $np1; $len++ while ($v >>= 1); } foreach my $bit (reverse 0 .. $len-2) { $na = $fa * (($fa*$x) + ($fb+$fb)); $fb = ( ($fb + $fa) * ($fb - $fa) ) % $n; diff --git a/t/11-primes.t b/t/11-primes.t index 0de176d..6a532c2 100644 --- a/t/11-primes.t +++ b/t/11-primes.t @@ -6,6 +6,7 @@ use Test::More; use Math::Prime::Util qw/primes prime_count/; my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32; +$use64 = 0 if 18446744073709550592 == ~0; plan tests => 12+3 + 12 + 1 + 19 + ($use64 ? 1 : 0) + 1 + 13*5; diff --git a/t/16-randomprime.t b/t/16-randomprime.t index 4ca0986..96f8bf7 100644 --- a/t/16-randomprime.t +++ b/t/16-randomprime.t @@ -11,8 +11,8 @@ use Math::Prime::Util qw/random_prime random_ndigit_prime random_nbit_prime is_prime prime_set_config/; my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32; -my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING}; my $broken64 = (18446744073709550592 == ~0); +my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING}; my $maxbits = $use64 ? 64 : 32; my @random_to = (2, 3, 4, 5, 6, 7, 8, 9, 100, 1000, 1000000, 4294967295); @@ -23,6 +23,13 @@ push @random_nbit_tests, (34) if $use64; my @random_ndigit_tests = (1 .. ($use64 ? 20 : 10)); +if ($use64 && $broken64) { + diag "Skipping some values for with broken 64-bit Perl\n"; + @random_ndigit_tests = grep { $_ < 10 } @random_ndigit_tests; + @random_nbit_tests = grep { $_ < 50 } @random_nbit_tests; +} + + my %ranges = ( "2 to 20" => [2,19], "3 to 7" => [3,7], @@ -139,28 +146,12 @@ foreach my $high (@random_to) { ok($inrange, "All returned values for $high were in the range" ); } -SKIP: { - if ($use64 && $broken64) { - my $num_ndigit_tests = scalar @random_ndigit_tests; - @random_ndigit_tests = grep { $_ < 15 } @random_ndigit_tests; - my $nskip = $num_ndigit_tests - scalar @random_ndigit_tests; - skip "Skipping random 15+ digit primes on broken 64-bit Perl", $nskip; - } -} foreach my $digits ( @random_ndigit_tests ) { my $n = random_ndigit_prime($digits); ok ( length($n) == $digits && is_prime($n), "$digits-digit random prime is in range and prime"); } -SKIP: { - if ($use64 && $broken64) { - my $num_nbit_tests = scalar @random_nbit_tests; - @random_nbit_tests = grep { $_ < 50 } @random_nbit_tests; - my $nskip = $num_nbit_tests - scalar @random_nbit_tests; - skip "Skipping random 50+ bit primes on broken 64-bit Perl", 2*$nskip; - } -} foreach my $bits ( @random_nbit_tests ) { check_bits( random_nbit_prime($bits), $bits, "nbit" ); check_bits( random_maurer_prime($bits), $bits, "Maurer" ); @@ -195,7 +186,8 @@ is( random_ndigit_prime(9), 980824987, "random 9-digit with custom irand" ); && $n <= Math::BigInt->new(2)->bpow(80), "random 80-bit prime is in range" ); } -{ +SKIP: { + skip "Skipping 30-digit random prime with broken 64-bit Perl", 2 if $broken64; my $n = random_ndigit_prime(30); is( ref($n), 'Math::BigInt', "random 30-digit prime returns a BigInt" ); ok( $n >= Math::BigInt->new(10)->bpow(29) diff --git a/t/17-pseudoprime.t b/t/17-pseudoprime.t index 0cc9456..311c0d1 100644 --- a/t/17-pseudoprime.t +++ b/t/17-pseudoprime.t @@ -215,7 +215,8 @@ while (my($params, $expect) = each (%lucas_sequences)) { is_deeply( [lucas_sequence_to_native(split(' ', $params))], $expect, "Lucas sequence $params" ); } -{ +SKIP: { + skip "Old Perl+bigint segfaults in F-U code",1+2*$use64 if $] < 5.008; my $fufail = 0; foreach my $i (1 .. 100) { my $n = 2*int(rand(1000000000)) + 1; @@ -227,8 +228,8 @@ while (my($params, $expect) = each (%lucas_sequences)) { } } is($fufail, 0, "is_frobenius_underwood_pseudoprime matches is_prime"); -} -if ($use64) { - is( is_frobenius_underwood_pseudoprime(2727480595375747), 1, "frobenius with 52-bit prime" ); - is( is_frobenius_underwood_pseudoprime(10099386070337), 0, "frobenius with 44-bit lucas pseudoprime" ); + if ($use64) { + is( is_frobenius_underwood_pseudoprime(2727480595375747), 1, "frobenius with 52-bit prime" ); + is( is_frobenius_underwood_pseudoprime(10099386070337), 0, "frobenius with 44-bit lucas pseudoprime" ); + } } diff --git a/t/19-moebius.t b/t/19-moebius.t index 772ceb2..941b2ff 100644 --- a/t/19-moebius.t +++ b/t/19-moebius.t @@ -10,8 +10,7 @@ use Math::Prime::Util my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING}; my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32; my $usexs = Math::Prime::Util::prime_get_config->{'xs'}; -my $broken64 = (18446744073709550592 == ~0); -$use64 = 0 if $broken64; +$use64 = 0 if $use64 && 18446744073709550592 == ~0; my @moeb_vals = (qw/ 1 -1 -1 0 -1 1 -1 0 0 1 -1 0 -1 1 1 0 -1 0 -1 0 /); my %mertens = ( diff --git a/t/20-primorial.t b/t/20-primorial.t index 4a59722..c575c85 100644 --- a/t/20-primorial.t +++ b/t/20-primorial.t @@ -41,10 +41,7 @@ my @pn_primorials = qw/ 31610054640417607788145206291543662493274686990 /; -my @small_primorials = grep { $_ <= ~0 } @pn_primorials; - plan tests => 0 - + 2 * (scalar @small_primorials) + 2 * (scalar @pn_primorials) + 2; @@ -65,20 +62,10 @@ sub nth_prime { $small_primes[$n-1]; } -# First we test native numbers -foreach my $n (0 .. $#small_primorials) { - SKIP: { - skip "Broken 64-bit again...", 2 if $broken64 && $n >= 14 && $n <= 15; - is( primorial(nth_prime($n)), $pn_primorials[$n], "primorial(nth($n))" ); - is( pn_primorial($n), $pn_primorials[$n], "pn_primorial($n)" ); - } -} - -# Then load up BigInt and make sure everything works for big numbers -require Math::BigInt; foreach my $n (0 .. $#pn_primorials) { SKIP: { - skip "Broken 64-bit again...", 2 if $broken64 && $n >= 14 && $n <= 15; + skip "Primorials for 14,15 are broken when Perl is borked", 2 + if $broken64 && $n >= 14 && $n <= 15; is( primorial(nth_prime($n)), $pn_primorials[$n], "primorial(nth($n))" ); is( pn_primorial($n), $pn_primorials[$n], "pn_primorial($n)" ); } diff --git a/t/22-aks-prime.t b/t/22-aks-prime.t index 1987766..58089aa 100644 --- a/t/22-aks-prime.t +++ b/t/22-aks-prime.t @@ -8,7 +8,6 @@ use Math::Prime::Util qw/is_aks_prime/; my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32; my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING}; my $ispp = !Math::Prime::Util::prime_get_config->{xs}; -my $broken64 = (18446744073709550592 == ~0); plan tests => 6 # range + 1 # small number diff --git a/t/23-primality-proofs.t b/t/23-primality-proofs.t index 9915d3a..9eb5f49 100644 --- a/t/23-primality-proofs.t +++ b/t/23-primality-proofs.t @@ -54,10 +54,10 @@ is( is_provable_prime(1490266103), 2, "1490266103 is provably prime" ); foreach my $p (@plist) { - ok( is_prime($p), "$p is prime" ); SKIP: { - skip "Broken 64-bit causes trial factor to barf", 5 + skip "Broken 64-bit causes trial factor to barf", 6 if $broken64 && $p > 2**48; + ok( is_prime($p), "$p is prime" ); skip "These take a long time on non-64-bit. Skipping", 5 if !$use64 && !$extra && $p =~ /^(6778|9800)/; my($isp, $cert) = is_provable_prime_with_cert($p); @@ -95,6 +95,7 @@ SKIP: { SKIP: { skip "Skipping 2**607-1 verification without Math::BigInt::GMP", 1 unless Math::BigInt->config()->{lib} eq 'Math::BigInt::GMP'; + skip "Skipping 2**607-1 verification on broken Perl", 1 if $broken64; my @proof = ('531137992816767098689588206552468627329593117727031923199444138200403559860852242739162502265229285668889329486246501015346579337652707239409519978766587351943831270835393219031728127', 'n-1', [ 2,3,7,607,'112102729', '341117531003194129', '7432339208719', ['845100400152152934331135470251', 'n-1', @@ -117,7 +118,8 @@ SKIP: { ], 14 ); ok( verify_prime(@proof), "simple Lucas/Pratt proof verified" ); } -{ +SKIP: { + skip "Skipping n-1 verification on broken Perl", 1 if $broken64; my @proof = ('3364125245431456304736426076174232972735419017865223025179282077503701', 'n-1', [2,5,127, ['28432789963853652887491983185920687231739655787', 'n-1', [ 2,3,163,650933, [ '44662634059309451871488121651101494489', 'n-1', @@ -261,8 +263,10 @@ is( verify_prime([1490266103, "ECPP", [694361, 694358, 0, 695162, [26737, "n-1", [2],[2]], [348008, 638945]]]), 0, "ECPP non-prime last q" ); -my $header = "[MPU - Primality Certificate]\nVersion 1.0\nProof for:"; -{ +SKIP: { + skip "Skipping additional verifications on broken Perl", 3 if $broken64; + my $header = "[MPU - Primality Certificate]\nVersion 1.0\nProof for:"; + { my $cert = join "\n", $header, "N 2297612322987260054928384863", "Type Pocklington", @@ -270,8 +274,8 @@ my $header = "[MPU - Primality Certificate]\nVersion 1.0\nProof for:"; "Q 16501461106821092981", "A 5"; is( verify_prime($cert), 1, "Verify Pocklington"); -} -{ + } + { my $cert = join "\n", $header, "N 5659942549665396263282978117", "Type BLS15", @@ -280,8 +284,8 @@ my $header = "[MPU - Primality Certificate]\nVersion 1.0\nProof for:"; "LP 2", "LQ 3"; is( verify_prime($cert), 1, "Verify BLS15"); -} -{ + } + { my $cert = join "\n", $header, "N 43055019307158602560279", "Type ECPP3", @@ -292,4 +296,5 @@ my $header = "[MPU - Primality Certificate]\nVersion 1.0\nProof for:"; "B 4", "T 1"; is( verify_prime($cert), 1, "Verify ECPP3"); + } } diff --git a/t/32-iterators.t b/t/32-iterators.t index ec7779c..3ef3a42 100644 --- a/t/32-iterators.t +++ b/t/32-iterators.t @@ -9,6 +9,7 @@ use Math::BigInt try => "GMP,Pari"; use Math::BigFloat; my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32; +my $broken64 = (18446744073709550592 == ~0); plan tests => 8 # forprimes errors + 12 + 5 # forprimes simple @@ -160,17 +161,20 @@ ok(!eval { prime_iterator_object(4.5); }, "iterator 4.5"); $it->rewind->next->next->next->prev; is( $it->value(), 5, "iterator object rewind and move returns 5"); # Validate that it automatically handles bigint range traversal. - my $top_prime = prev_prime(~0); - my $big_prime = next_prime(Math::BigInt->new(''.~0)); - ok( $big_prime > ~0, "internal check, next_prime on big int works"); - $it->rewind($top_prime); - is( $it->value(), $top_prime, "iterator object can rewind to $top_prime"); - $it->next; - is( $it->value(), $big_prime, "iterator object next is $big_prime"); - $it->rewind(~0); - is( $it->value(), $big_prime, "iterator object rewound to ~0 is $big_prime"); - $it->prev; - is( $it->value(), $top_prime, "iterator object prev goes back to $top_prime"); + SKIP: { + skip "Skipping bigint traversals on a Perl that can't add correctly",5 if $broken64; + my $top_prime = prev_prime(~0); + my $big_prime = next_prime(Math::BigInt->new(''.~0)); + ok( $big_prime > ~0, "internal check, next_prime on big int works"); + $it->rewind($top_prime); + is( $it->value(), $top_prime, "iterator object can rewind to $top_prime"); + $it->next; + is( $it->value(), $big_prime, "iterator object next is $big_prime"); + $it->rewind(~0); + is( $it->value(), $big_prime, "iterator object rewound to ~0 is $big_prime"); + $it->prev; + is( $it->value(), $top_prime, "iterator object prev goes back to $top_prime"); + } # Validation for the Math::NumSeq compatiblity stuff $it->rewind; diff --git a/t/80-pp.t b/t/80-pp.t index 788c532..91b678f 100644 --- a/t/80-pp.t +++ b/t/80-pp.t @@ -608,7 +608,10 @@ is_deeply( [Math::Prime::Util::PrimalityProving::primality_proof_bls75(271410578 is( miller_rabin( $n, 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47), 1, "168790877523676911809192454171451 looks prime with bases 2..52" ); is( miller_rabin( $n, 53), 0, "168790877523676911809192454171451 found composite with base 53" ); is ( is_strong_lucas_pseudoprime($n), 0, "168790877523676911809192454171451 is not a strong Lucas pseudoprime" ); - is ( is_frobenius_underwood_pseudoprime($n), 0, "168790877523676911809192454171451 is not a Frobenius pseudoprime" ); + SKIP: { + skip "Old Perl+bigint segfaults in F-U code", 1 if $] < 5.008; + is ( is_frobenius_underwood_pseudoprime($n), 0, "168790877523676911809192454171451 is not a Frobenius pseudoprime" ); + } } { diff --git a/t/81-bignum.t b/t/81-bignum.t index f84b3e8..3802bb0 100644 --- a/t/81-bignum.t +++ b/t/81-bignum.t @@ -47,6 +47,7 @@ my %pseudoprimes = ( '564132928021909221014087501701' => [ qw/2 3 5 7 11 13 17 19 23 29 31 37 325 9375/ ], #'1543267864443420616877677640751301' => [ qw/2 3 5 7 11 13 17 19 23 29 31 37 61 325 9375/ ], ); +delete $pseudoprimes{'3825123056546413051'} if $broken64; my $num_pseudoprime_tests = 0; foreach my $psrp (keys %pseudoprimes) { push @composites, $psrp; @@ -183,13 +184,10 @@ is( prime_count(877777777777777777777752, 877777777777777777777872), 2, "prime_c ############################################################################### while (my($psrp, $baseref) = each (%pseudoprimes)) { - SKIP: { - skip "Your 64-bit Perl is broken, skipping pseudoprime tests for $psrp", 1 if $broken64 && $psrp == 3825123056546413051; - my $baselist = join(",", @$baseref); - my @expmr = map { (0!=1) } @$baseref; - my @gotmr = map { is_strong_pseudoprime($psrp, $_) } @$baseref; - is_deeply(\@gotmr, \@expmr, "$psrp is a strong pseudoprime to bases $baselist"); - } + my $baselist = join(",", @$baseref); + my @expmr = map { (0!=1) } @$baseref; + my @gotmr = map { is_strong_pseudoprime($psrp, $_) } @$baseref; + is_deeply(\@gotmr, \@expmr, "$psrp is a strong pseudoprime to bases $baselist"); } ############################################################################### @@ -203,7 +201,7 @@ if ($extra) { ############################################################################### SKIP: { - skip "Your 64-bit Perl is broken, skipping bignum factoring tests", scalar(keys %factors) + scalar(keys %allfactors) if $broken64; + skip "Your 64-bit Perl is broken, skipping bignum factoring tests", 2*scalar(keys %factors) + scalar(keys %allfactors) if $broken64; while (my($n, $factors) = each(%factors)) { is_deeply( [factor($n)], $factors, "factor($n)" ); is_deeply( [factor_exp($n)], [linear_to_exp(@$factors)], "factor_exp($n)" ); @@ -216,7 +214,7 @@ SKIP: { ############################################################################### SKIP: { - skip "Your 64-bit Perl is broken, skipping moebius,euler_phi,divsum tests", 10 if $broken64; + skip "Your 64-bit Perl is broken, skipping moebius, totient, etc.", 10 if $broken64; my $n; $n = 618970019642690137449562110; is( moebius($n), -1, "moebius($n)" ); @@ -248,15 +246,19 @@ is( liouville(10571644062695614514374497899), 1, "liouville(a x b x c x d) = 1" my $randprime; -$randprime = random_prime(147573952590750158861, 340282366920939067930896100764782952647); -cmp_ok( $randprime, '>=', 147573952590750158861, "random range prime isn't too small"); -cmp_ok( $randprime, '<=', 340282366920939067930896100764782952647, "random range prime isn't too big"); -ok( is_prime($randprime), "random range prime is prime"); +SKIP: { + skip "Skipping large random prime tests on broken 64-bit Perl", 6 if $broken64; -$randprime = random_ndigit_prime(25); -cmp_ok( $randprime, '>', 10**24, "random 25-digit prime isn't too small"); -cmp_ok( $randprime, '<', 10**25, "random 25-digit prime isn't too big"); -ok( is_prime($randprime), "random 25-digit prime is prime"); + $randprime = random_prime(147573952590750158861, 340282366920939067930896100764782952647); + cmp_ok( $randprime, '>=', 147573952590750158861, "random range prime isn't too small"); + cmp_ok( $randprime, '<=', 340282366920939067930896100764782952647, "random range prime isn't too big"); + ok( is_prime($randprime), "random range prime is prime"); + + $randprime = random_ndigit_prime(25); + cmp_ok( $randprime, '>', 10**24, "random 25-digit prime isn't too small"); + cmp_ok( $randprime, '<', 10**25, "random 25-digit prime isn't too big"); + ok( is_prime($randprime), "random 25-digit prime is prime"); +} $randprime = random_nbit_prime(80); cmp_ok( $randprime, '>', 2**79, "random 80-bit prime isn't too small"); @@ -268,19 +270,16 @@ cmp_ok( $randprime, '>', 2**255, "random 256-bit strong prime isn't too small"); cmp_ok( $randprime, '<', 2**256, "random 256-bit strong prime isn't too big"); ok( is_prime($randprime), "random 80-bit strong prime is prime"); -SKIP: { - skip "Your 64-bit Perl is broken, skipping maurer prime", 3 if $broken64; - $randprime = random_maurer_prime(80); - cmp_ok( $randprime, '>', 2**79, "random 80-bit Maurer prime isn't too small"); - cmp_ok( $randprime, '<', 2**80, "random 80-bit Maurer prime isn't too big"); - ok( is_prime($randprime), "random 80-bit Maurer prime is prime"); -} +$randprime = random_maurer_prime(80); +cmp_ok( $randprime, '>', 2**79, "random 80-bit Maurer prime isn't too small"); +cmp_ok( $randprime, '<', 2**80, "random 80-bit Maurer prime isn't too big"); +ok( is_prime($randprime), "random 80-bit Maurer prime is prime"); ############################################################################### $randprime = random_nbit_prime(80); is( miller_rabin_random( $randprime, 20 ), 1, "80-bit prime passes Miller-Rabin with 20 random bases" ); -$randprime += 2 while is_prime($randprime); +do { $randprime += 2 } while is_prime($randprime); is( miller_rabin_random( $randprime, 40 ), "0", "80-bit composite fails Miller-Rabin with 40 random bases" ); ############################################################################### -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits