[libmath-prime-util-perl] 16/29: Add more test coverage
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:48:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.27
in repository libmath-prime-util-perl.
commit cac18f0cf0a47b883f81f1add7f11a79eff6839d
Author: Dana Jacobsen <dana at acm.org>
Date: Wed May 15 16:59:44 2013 -0700
Add more test coverage
---
TODO | 9 +++----
aks.c | 2 ++
lib/Math/Prime/Util/PP.pm | 14 +++++++----
t/10-isprime.t | 1 -
t/11-primes.t | 1 -
t/12-nextprime.t | 1 -
t/13-primecount.t | 11 +++++----
t/14-nthprime.t | 10 ++++++--
t/15-probprime.t | 1 -
t/16-randomprime.t | 2 +-
t/17-pseudoprime.t | 14 ++++++-----
t/18-functions.t | 2 --
t/19-moebius.t | 2 +-
t/22-aks-prime.t | 2 +-
t/30-relations.t | 3 ---
t/31-threading.t | 2 +-
t/50-factoring.t | 2 +-
t/80-pp.t | 60 ++++++++++++++++++++++++++++++++++++++++++++---
t/81-bignum.t | 2 +-
19 files changed, 101 insertions(+), 40 deletions(-)
diff --git a/TODO b/TODO
index 0ed5c9c..f9e3def 100644
--- a/TODO
+++ b/TODO
@@ -24,9 +24,6 @@
- An assembler version of mulmod for i386 would be _really_ helpful for
all the non-x86-64 Intel machines.
-- Dynamically use a mulmodadd in PP aks, just like the new C code does.
- This will mean it'll work for full-size native ints.
-
- More efficient Mertens. The current version has poor growth.
- More efficient totient segment. Do we really need primes to n/2?
@@ -39,5 +36,9 @@
- Big features:
- LMO prime count
- - ECPP primality proof
- QS factoring
+
+- Test coverage:
+ PP miller-rabin with bigint
+ PP ecm_factor stage 2
+ PP primality_proof_bls75 that needs to find factors
diff --git a/aks.c b/aks.c
index 0eb9580..ba86e69 100644
--- a/aks.c
+++ b/aks.c
@@ -97,6 +97,7 @@ static UV order(UV r, UV n, UV limit) {
return j;
}
+#if 0
static void poly_print(UV* poly, UV r)
{
int i;
@@ -107,6 +108,7 @@ static void poly_print(UV* poly, UV r)
if (poly[0] != 0) printf("%lu", poly[0]);
printf("\n");
}
+#endif
static void poly_mod_mul(UV* px, UV* py, UV* res, UV r, UV mod)
{
diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index ba22c69..86ae28b 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -803,8 +803,8 @@ sub _jacobi {
($n, $m) = ($m, $n);
$j = -$j if ($n % 4) == 3 && ($m % 4) == 3;
$n = $n % $m;
- $n = int($n->bstr) if $n <= ~0 && ref($n) eq 'Math::BigInt';
- $m = int($m->bstr) if $m <= ~0 && ref($m) eq 'Math::BigInt';
+ $n = int($n->bstr) if ref($n) eq 'Math::BigInt' && $n <= ''.~0;
+ $m = int($m->bstr) if ref($m) eq 'Math::BigInt' && $m <= ''.~0;
}
while ($n != 0) {
while (($n % 2) == 0) {
@@ -1110,7 +1110,7 @@ sub _basic_factor {
}
}
}
- $_[0] = int($_[0]->bstr) if $_[0] <= ~0;
+ $_[0] = int($_[0]->bstr) if $_[0] <= ''.~0;
}
if ( ($_[0] > 1) && _is_prime7($_[0]) ) {
@@ -1203,7 +1203,7 @@ sub factor {
while (@nstack) {
$n = pop @nstack;
# Don't use bignum on $n if it has gotten small enough.
- $n = int($n->bstr) if ref($n) eq 'Math::BigInt' && $n <= ~0;
+ $n = int($n->bstr) if ref($n) eq 'Math::BigInt' && $n <= ''.~0;
#print "Looking at $n with stack ", join(",", at nstack), "\n";
while ( ($n >= (31*31)) && !_is_prime7($n) ) {
my @ftry;
@@ -1722,6 +1722,7 @@ sub ecm_factor {
$f = Math::BigInt::bgcd( $z, $n ) if $f == 1;
next if $f == $n;
return _found_factor($f,$n, "ECM B1=$B1 curve $curve", @factors) if $f != 1;
+ $b = Math::BigInt->new("$b") unless ref($b) eq 'Math::BigInt';
$u = $b->copy->bmodinv($n);
$a = (($a*$u) - 2) % $n;
@@ -1921,7 +1922,7 @@ sub primality_proof_bls75 {
my $m = pop @nstack;
# Don't use bignum if it has gotten small enough.
- $m = int($m->bstr) if ref($m) eq 'Math::BigInt' && $m <= ~0;
+ $m = int($m->bstr) if ref($m) eq 'Math::BigInt' && $m <= ''.~0;
# Try to find factors of m, using the default set of factor subs.
my @ftry;
$_holf_r = 1;
@@ -1987,6 +1988,9 @@ sub primality_proof_bls75 {
}
push @fac_proofs, (scalar @$fproof == 1) ? $fproof->[0] : $fproof;
}
+ # Put n, B back to non-bigints if possible.
+ $n = int($n->bstr) if ref($n) eq 'Math::BigInt' && $n <= ''.~0;
+ $B = int($B->bstr) if ref($B) eq 'Math::BigInt' && $B <= ''.~0;
if ($theorem == 5) {
return (2, [$n, "n-1", [@fac_proofs], [@as]]);
} else {
diff --git a/t/10-isprime.t b/t/10-isprime.t
index a3366a4..a3fb361 100644
--- a/t/10-isprime.t
+++ b/t/10-isprime.t
@@ -6,7 +6,6 @@ use Test::More;
use Math::Prime::Util qw/is_prime/;
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
my $broken64 = (18446744073709550592 == ~0);
my @small_primes = qw/
diff --git a/t/11-primes.t b/t/11-primes.t
index 23a3434..0de176d 100644
--- a/t/11-primes.t
+++ b/t/11-primes.t
@@ -6,7 +6,6 @@ use Test::More;
use Math::Prime::Util qw/primes prime_count/;
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
plan tests => 12+3 + 12 + 1 + 19 + ($use64 ? 1 : 0) + 1 + 13*5;
diff --git a/t/12-nextprime.t b/t/12-nextprime.t
index 69a1156..35a1f21 100644
--- a/t/12-nextprime.t
+++ b/t/12-nextprime.t
@@ -6,7 +6,6 @@ use Test::More;
use Math::Prime::Util qw/next_prime prev_prime/;
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
plan tests => 2 + 3*2 + 6 + 2 + 148 + 148 + 1;
diff --git a/t/13-primecount.t b/t/13-primecount.t
index 09fe825..160da98 100644
--- a/t/13-primecount.t
+++ b/t/13-primecount.t
@@ -7,7 +7,7 @@ use Math::Prime::Util qw/prime_count prime_count_lower prime_count_upper prime_c
my $isxs = Math::Prime::Util::prime_get_config->{'xs'};
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
+my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
# Powers of 2: http://oeis.org/A007053/b007053.txt
# Powers of 10: http://oeis.org/A006880/b006880.txt
@@ -157,10 +157,11 @@ sub parse_range {
# Make sure each specific algorithm isn't broken.
SKIP: {
skip "Not XS -- skipping direct primecount tests", 4 unless $isxs;
- is(Math::Prime::Util::_XS_lehmer_pi (3456789), 247352, "XS Lehmer count");
- is(Math::Prime::Util::_XS_meissel_pi (3456789), 247352, "XS Meissel count");
- is(Math::Prime::Util::_XS_legendre_pi(3456789), 247352, "XS Legendre count");
- is(Math::Prime::Util::_XS_prime_count(3456789), 247352, "XS sieve count");
+ # This has to be above lehmer.c's SIEVE_LIMIT or nothing happens.
+ is(Math::Prime::Util::_XS_lehmer_pi (66123456), 3903023, "XS Lehmer count");
+ is(Math::Prime::Util::_XS_meissel_pi (66123456), 3903023, "XS Meissel count");
+ is(Math::Prime::Util::_XS_legendre_pi(66123456), 3903023, "XS Legendre count");
+ is(Math::Prime::Util::_XS_prime_count(66123456), 3903023, "XS sieve count");
}
is(Math::Prime::Util::PP::_lehmer_pi (3456789), 247352, "PP Lehmer count");
is(Math::Prime::Util::PP::_sieve_prime_count(3456789), 247352, "PP sieve count");
diff --git a/t/14-nthprime.t b/t/14-nthprime.t
index 55bca37..217920b 100644
--- a/t/14-nthprime.t
+++ b/t/14-nthprime.t
@@ -6,7 +6,7 @@ use Test::More;
use Math::Prime::Util qw/primes nth_prime nth_prime_lower nth_prime_upper nth_prime_approx/;
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
+my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
my $broken64 = (18446744073709550592 == ~0);
my $nsmallprimes = 1000;
@@ -58,7 +58,8 @@ plan tests => 0 + 2*scalar(keys %pivals32)
+ scalar(keys %nthprimes_small)
+ $use64 * 3 * scalar(keys %nthprimes64)
+ 4
- + 3;
+ + 3
+ + (($extra && $use64) ? 1 : 0);
while (my($n, $pin) = each (%pivals32)) {
@@ -113,3 +114,8 @@ like($@, qr/overflow/, "nth_prime_approx($overindex) overflows");
eval { nth_prime($overindex); };
like($@, qr/overflow/, "nth_prime($overindex) overflows");
+
+if ($extra && $use64) {
+ # Test an nth prime value that uses the binary-search-on-R(n) algorithm
+ is( nth_prime(21234567890), 551990503367, "nth_prime(21234567890)" );
+}
diff --git a/t/15-probprime.t b/t/15-probprime.t
index b622726..a4cd594 100644
--- a/t/15-probprime.t
+++ b/t/15-probprime.t
@@ -6,7 +6,6 @@ use Test::More;
use Math::Prime::Util qw/is_prob_prime/;
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
my $broken64 = (18446744073709550592 == ~0);
my @small_primes = qw/
diff --git a/t/16-randomprime.t b/t/16-randomprime.t
index 2641a54..0c577d2 100644
--- a/t/16-randomprime.t
+++ b/t/16-randomprime.t
@@ -11,7 +11,7 @@ use Math::Prime::Util qw/random_prime random_ndigit_prime random_nbit_prime
prime_set_config/;
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
+my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
my $broken64 = (18446744073709550592 == ~0);
my $maxbits = $use64 ? 64 : 32;
diff --git a/t/17-pseudoprime.t b/t/17-pseudoprime.t
index 01e21ca..126a106 100644
--- a/t/17-pseudoprime.t
+++ b/t/17-pseudoprime.t
@@ -6,7 +6,7 @@ use Test::More;
use Math::Prime::Util qw/is_prime is_strong_pseudoprime is_strong_lucas_pseudoprime/;
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
+my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
# small primes
my @sp = qw/2 3 5 7 11 13 17 19 23 29 31 37/;
@@ -140,11 +140,13 @@ for my $n (@small_lucas_trials) {
# Verify MR base 2-3 for many small numbers (up to phi2)
if ($extra) {
my $mr2fail = 0;
- for (2 .. 1373652) {
- if (is_prime($_)) {
- if (!is_strong_pseudoprime($_,2,3)) { $mr2fail = $_; last; }
- } else {
- if (is_strong_pseudoprime($_,2,3)) { $mr2fail = $_; last; }
+ foreach my $i (1 .. 50000) {
+ my $n = int(rand(1373652)) + 1;
+ my $isp23 = !!is_strong_pseudoprime($n,2,3);
+ my $prime = !!is_prime($n);
+ if ($isp23 != $prime) {
+ $mr2fail = $n;
+ last;
}
}
is($mr2fail, 0, "is_strong_pseudoprime bases 2,3 matches is_prime to 1,373,652");
diff --git a/t/18-functions.t b/t/18-functions.t
index 4cef078..e4dd417 100644
--- a/t/18-functions.t
+++ b/t/18-functions.t
@@ -7,8 +7,6 @@ use Math::Prime::Util qw/
prime_count ExponentialIntegral LogarithmicIntegral RiemannR RiemannZeta
/;
-my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
my $infinity = 20**20**20;
plan tests => 3 + 6 + 1 + 16 + 11 + 9 + 6;
diff --git a/t/19-moebius.t b/t/19-moebius.t
index 5353ed8..e1a870a 100644
--- a/t/19-moebius.t
+++ b/t/19-moebius.t
@@ -7,7 +7,7 @@ use Math::Prime::Util
qw/moebius mertens euler_phi jordan_totient divisor_sum exp_mangoldt
chebyshev_theta chebyshev_psi/;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
+my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
my $broken64 = (18446744073709550592 == ~0);
$use64 = 0 if $broken64;
diff --git a/t/22-aks-prime.t b/t/22-aks-prime.t
index 717d544..1987766 100644
--- a/t/22-aks-prime.t
+++ b/t/22-aks-prime.t
@@ -6,7 +6,7 @@ use Test::More;
use Math::Prime::Util qw/is_aks_prime/;
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
+my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
my $ispp = !Math::Prime::Util::prime_get_config->{xs};
my $broken64 = (18446744073709550592 == ~0);
diff --git a/t/30-relations.t b/t/30-relations.t
index 282bc3f..a31ab64 100644
--- a/t/30-relations.t
+++ b/t/30-relations.t
@@ -12,9 +12,6 @@ use Math::Prime::Util qw/primes
my @trials = qw/1 2 3 4 5 6 7 17 57 89 102 1337 8573 84763 784357 1000001 2573622/;
-my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
-
plan tests => 5 * scalar @trials;
my $last = 0;
diff --git a/t/31-threading.t b/t/31-threading.t
index 06b6356..7c1315a 100644
--- a/t/31-threading.t
+++ b/t/31-threading.t
@@ -18,7 +18,7 @@ BEGIN {
use Test::More 'tests' => 9;
use Math::Prime::Util ":all";
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
+my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
my $is_win32 = ($Config{osname} eq 'MSWin32') ? 1 : 0;
# threads are memory hogs, so we want few of them. But for testing purposes,
diff --git a/t/50-factoring.t b/t/50-factoring.t
index 86fded8..3073555 100644
--- a/t/50-factoring.t
+++ b/t/50-factoring.t
@@ -6,7 +6,7 @@ use Test::More;
use Math::Prime::Util qw/factor all_factors is_prime/;
my $use64 = Math::Prime::Util::prime_get_config->{'maxbits'} > 32;
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
+my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
if ($use64) {
diff --git a/t/80-pp.t b/t/80-pp.t
index fe4e85e..ec07338 100644
--- a/t/80-pp.t
+++ b/t/80-pp.t
@@ -4,7 +4,7 @@ use warnings;
# This is a subset of our tests. You really should run the whole test suite
# on the PP code. What this will do is basic regression testing.
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
+my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
my $use64 = ~0 > 4294967295;
use Test::More;
@@ -36,6 +36,7 @@ my @composites = qw/
9439201 17236801 23382529 34657141 56052361 146843929
341 561 645 1105 1387 1729 1905 2047 2465 2701 2821 3277 4033 4369 4371
4681 5461 6601 7957 8321 52633 88357
+66066 173645446 7500135 115501463
/;
# pseudoprimes to various small prime bases
@@ -214,6 +215,14 @@ my %rvals = (
10000000000 => 455050683.30684692446315,
18446744073709551615 => 4.25656284014012122706963685602e17,
);
+my %rzvals = (
+ 2 => 0.6449340668482264364724151666,
+ 2.5 => 0.3414872572509171797567696934,
+ 4.5 => 0.0547075107614542640229672890,
+ 7 => 0.0083492773819228268397975498,
+ 8.5 => 0.0028592508824156277133439825,
+ 20.6 => 0.0000006293391573578212882457,
+);
plan tests => 1 +
@@ -223,14 +232,17 @@ plan tests => 1 +
scalar(keys %pivals_small) + scalar(keys %pi_intervals) +
2*scalar(keys %pivals_small) + scalar(keys %nthprimes_small) +
4 + scalar(keys %pseudoprimes) +
- scalar(keys %eivals) + scalar(keys %livals) + scalar(keys %rvals) +
+ scalar(keys %eivals) + scalar(keys %livals) + scalar(keys %rvals) + scalar(keys %rzvals) +
+ ($extra ? 2 : 0) + # Bigfloat RiemannZeta
1 + 1 + # factor
- 8 + 4*3 + # factoring subs
+ 10 + 7*3 + # factoring subs
10 + # AKS
+ 2 + # Lucas and BLS75 primality proofs
1;
use Math::Prime::Util qw/primes prime_count_approx prime_count_lower/;
use Math::BigInt try => 'GMP';
+use Math::BigFloat;
require_ok 'Math::Prime::Util::PP';
# This function skips some setup
undef *primes;
@@ -250,6 +262,7 @@ require_ok 'Math::Prime::Util::PP';
*factor = \&Math::Prime::Util::PP::factor;
*RiemannR = \&Math::Prime::Util::PP::RiemannR;
+ *RiemannZeta = \&Math::Prime::Util::PP::RiemannZeta;
*LogarithmicIntegral = \&Math::Prime::Util::PP::LogarithmicIntegral;
*ExponentialIntegral = \&Math::Prime::Util::PP::ExponentialIntegral;
@@ -375,6 +388,16 @@ while (my($n, $lin) = each (%livals)) {
while (my($n, $rin) = each (%rvals)) {
cmp_closeto( RiemannR($n), $rin, 0.00000001 * abs($rin), "R($n) ~= $rin");
}
+while (my($n, $zin) = each (%rzvals)) {
+ cmp_closeto( RiemannZeta($n), $zin, 0.00000001 * abs($zin), "Zeta($n) ~= $zin");
+}
+if ($extra) {
+ my ($n, $zin);
+ ($n, $zin) = (4.5, $rzvals{4.5});
+ cmp_closeto( RiemannZeta(Math::BigFloat->new($n)), $zin, 0.00000001 * abs($zin), "Zeta($n) ~= $zin");
+ ($n, $zin) = (20.6, $rzvals{20.6});
+ cmp_closeto( RiemannZeta(Math::BigFloat->new($n)), $zin, 0.00000001 * abs($zin), "Zeta($n) ~= $zin");
+}
###############################################################################
@@ -423,6 +446,9 @@ while (my($n, $rin) = each (%rvals)) {
is_deeply( [ sort {$a<=>$b} Math::Prime::Util::PP::holf_factor(403) ],
[ 13, 31 ],
"holf(403)" );
+ is_deeply( [ sort {$a<=>$b} Math::Prime::Util::PP::fermat_factor(403) ],
+ [ 13, 31 ],
+ "fermat(403)" );
is_deeply( [ sort {$a<=>$b} Math::Prime::Util::PP::prho_factor(403) ],
[ 13, 31 ],
"prho(403)" );
@@ -438,6 +464,9 @@ while (my($n, $rin) = each (%rvals)) {
is_deeply( [ sort {$a<=>$b} Math::Prime::Util::PP::pbrent_factor(851981) ],
[ 13, 65537 ],
"pbrent(851981)" );
+ is_deeply( [ sort {$a<=>$b} Math::Prime::Util::PP::ecm_factor(851981) ],
+ [ 13, 65537 ],
+ "ecm(851981)" );
my $n64 = $use64 ? 55834573561 : Math::BigInt->new("55834573561");
is_deeply( [ sort {$a<=>$b} Math::Prime::Util::PP::prho_factor($n64) ],
[ 13, 4294967197 ],
@@ -464,6 +493,24 @@ while (my($n, $rin) = each (%rvals)) {
is(scalar @nfac, 2, "pminus1 finds a factor of 18686551294184381720251");
is($nfac[0] * $nfac[1], $nbig, "pminus1 found a correct factor");
ok($nfac[0] != 1 && $nfac[1] != 1, "pminus1 didn't return a degenerate factor");
+ @nfac = sort {$a<=>$b} Math::Prime::Util::PP::ecm_factor($nbig);
+ is(scalar @nfac, 2, "ecm finds a factor of 18686551294184381720251");
+ is($nfac[0] * $nfac[1], $nbig, "ecm found a correct factor");
+ ok($nfac[0] != 1 && $nfac[1] != 1, "ecm didn't return a degenerate factor");
+
+ $nbig = Math::BigInt->new("73786976930493367637");
+ # Check stage 2 p-1. Fast with Math::BigInt::GMP, slow without.
+ SKIP: {
+ skip "Skipping p-1 stage 2 tests", 3 unless $extra;
+ @nfac = sort {$a<=>$b} Math::Prime::Util::PP::pminus1_factor($nbig, 27000, 35000);
+ is(scalar @nfac, 2, "pminus1 finds a factor of 73786976930493367637");
+ is($nfac[0] * $nfac[1], $nbig, "pminus1 found a correct factor");
+ ok($nfac[0] != 1 && $nfac[1] != 1, "pminus1 didn't return a degenerate factor");
+ }
+ @nfac = sort {$a<=>$b} Math::Prime::Util::PP::fermat_factor($nbig);
+ is(scalar @nfac, 2, "fermat finds a factor of 73786976930493367637");
+ is($nfac[0] * $nfac[1], $nbig, "fermat found a correct factor");
+ ok($nfac[0] != 1 && $nfac[1] != 1, "fermat didn't return a degenerate factor");
}
##### AKS primality test. Be very careful with performance.
@@ -481,6 +528,13 @@ SKIP: {
is( is_aks_prime(74513), 0, "AKS: 74513 is composite (failed anr test)" );
}
+is_deeply( [Math::Prime::Util::PP::primality_proof_lucas(100003)],
+ [2, [100003, "Pratt", [2, 3, 7, 2381], 2]],
+ "primality_proof_lucas(100003)" );
+is_deeply( [Math::Prime::Util::PP::primality_proof_bls75(100000007)],
+ [2, [100000007, "n-1", [2, 491, 101833], [5, 2, 2]]],
+ "primality_proof_bls75(100000007)" );
+
is( $_, 'this should not change', "Nobody clobbered \$_" );
###############################################################################
diff --git a/t/81-bignum.t b/t/81-bignum.t
index dc41837..63e2d8d 100644
--- a/t/81-bignum.t
+++ b/t/81-bignum.t
@@ -9,7 +9,7 @@ use warnings;
# a small memory leak. So running the test suite through valgrind will show
# some small leaks in this test, which has nothing to do with the module.
-my $extra = defined $ENV{RELEASE_TESTING} && $ENV{RELEASE_TESTING};
+my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
my $broken64 = (18446744073709550592 == ~0);
use Test::More;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git
More information about the Pkg-perl-cvs-commits
mailing list