[libmath-prime-util-perl] 09/16: Add tests for is_provable_prime

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:46:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.19
in repository libmath-prime-util-perl.

commit 6c2179583347c1f03b6097990827a3d1f32b9456
Author: Dana Jacobsen <dana at acm.org>
Date:   Fri Jan 18 00:24:17 2013 -0800

    Add tests for is_provable_prime
---
 Changes          |  2 ++
 TODO             |  1 -
 t/22-aks-prime.t | 10 ++++++----
 t/81-bignum.t    | 13 ++++++++++++-
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/Changes b/Changes
index 2830592..c30fc93 100644
--- a/Changes
+++ b/Changes
@@ -6,6 +6,8 @@ Revision history for Perl extension Math::Prime::Util.
 
     - Fixed some issues when using bignum and Calc BigInt backend.
 
+    - Added tests for bigint is_provable_prime.
+
 0.18  14 January 2012
 
     - Add random_strong_prime.
diff --git a/TODO b/TODO
index e6c364e..f960009 100644
--- a/TODO
+++ b/TODO
@@ -34,7 +34,6 @@
 
 - Tests for:
 
-   is_provable_prime
    RiemannZeta
    RiemannR
 
diff --git a/t/22-aks-prime.t b/t/22-aks-prime.t
index 9d1811a..717d544 100644
--- a/t/22-aks-prime.t
+++ b/t/22-aks-prime.t
@@ -35,10 +35,12 @@ is( is_aks_prime(877), 1, "is_aks_prime(877) is true" );
 #diag "Unfortunately these tests are very slow.";
 
 SKIP: {
-  # If we're pure Perl, then this is definitely too slow.  If we have 64-bit
-  # available in the compiler (e.g. uint64_t) , this can still be quite fast.
-  # However for pretty much everyone else, this is just unreasonably slow
-  # for a standard test suite.
+  # If we're pure Perl, then this is definitely too slow.
+  # Arguably we should check to see if they have the GMP code.
+  skip "Skipping PP AKS on PP -- just too slow.", 1 if $ispp;
+  # If we have 64-bit available in the compiler (e.g. uint64_t), this can
+  # still be quite fast.  However for pretty much everyone else, this is
+  # just far too slow for running in a test suite.
   skip "Skipping PP AKS on 32-bit -- just too slow.", 1 if !$use64;
   # The first number that makes it past the sqrt test to actually run.
   is( is_aks_prime(69197), 1, "is_aks_prime(69197) is true" );
diff --git a/t/81-bignum.t b/t/81-bignum.t
index 7fcc956..9f88a51 100644
--- a/t/81-bignum.t
+++ b/t/81-bignum.t
@@ -27,6 +27,12 @@ my @composites = qw/
 87777777777777777777777795475 890745785790123461234805903467891234681234
 /;
 
+# Primes where n-1 is easy to factor, so we finish quickly.
+my @proveprimes = qw/
+65635624165761929287 1162566711635022452267983 77123077103005189615466924501
+3991617775553178702574451996736229 273952953553395851092382714516720001799
+/;
+
 # pseudoprimes to various small prime bases
 # These must not be themselves prime, as we're going to primality test them.
 my %pseudoprimes = (
@@ -59,7 +65,7 @@ my %allfactors = (
 );
 
 plan tests =>  0
-             + 2*(@primes + @composites)
+             + 2*(@primes + @composites + @proveprimes)
              + 1   # primes
              + 2   # next/prev prime
              + 1   # primecount large base small range
@@ -96,6 +102,7 @@ use Math::Prime::Util qw/
   prime_count
   nth_prime
   is_prime
+  is_provable_prime
   next_prime
   prev_prime
   is_strong_pseudoprime
@@ -129,6 +136,10 @@ foreach my $n (@composites) {
   ok( !is_prime($n), "$n is not prime" );
   ok( !is_prob_prime($n), "$n is not probably prime");
 }
+foreach my $n (@proveprimes) {
+  ok( is_prime($n), "$n is prime" );
+  ok( is_provable_prime($n), "$n is provably prime" );
+}
 
 ###############################################################################
 

-- 
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