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

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

commit e86068b2f482fbd54d4345e88e6d308daf44feed
Author: Dana Jacobsen <d...@acm.org>
Date:   Fri Jan 10 17:16:51 2014 -0800

    Call Math::BigInt importer only if it hasn't been loaded already
---
 lib/Math/Prime/Util.pm                   |  9 ++++-
 lib/Math/Prime/Util/ECAffinePoint.pm     |  6 ++-
 lib/Math/Prime/Util/ECProjectivePoint.pm |  6 ++-
 lib/Math/Prime/Util/PP.pm                |  6 ++-
 lib/Math/Prime/Util/PrimalityProving.pm  |  6 ++-
 lib/Math/Prime/Util/PrimeIterator.pm     |  1 -
 lib/Math/Prime/Util/ZetaBigFloat.pm      |  8 +++-
 t/23-primality-proofs.t                  |  5 ---
 t/80-pp.t                                |  2 +-
 t/81-bignum.t                            |  2 +-
 t/94-weaken.t                            | 68 ++++++++++++++++++++++++++++++++
 11 files changed, 104 insertions(+), 15 deletions(-)

diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index 9a7a1ff..b74c021 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -2,13 +2,20 @@ package Math::Prime::Util;
 use strict;
 use warnings;
 use Carp qw/croak confess carp/;
-use Math::BigInt try=>"GMP,Pari";
 
 BEGIN {
   $Math::Prime::Util::AUTHORITY = 'cpan:DANAJ';
   $Math::Prime::Util::VERSION = '0.36';
 }
 
+BEGIN {
+  # If they have used Math::BigInt already, make sure we don't change the
+  # back end.  If they have not, try to get one of the fast ones.
+  do { require Math::BigInt;  Math::BigInt->import(try=>"GMP,Pari"); }
+    unless defined $Math::BigInt::VERSION;
+}
+
+
 # parent is cleaner, and in the Perl 5.10.1 / 5.12.0 core, but not earlier.
 # use parent qw( Exporter );
 use base qw( Exporter );
diff --git a/lib/Math/Prime/Util/ECAffinePoint.pm 
b/lib/Math/Prime/Util/ECAffinePoint.pm
index 22e6cb6..9683ffc 100644
--- a/lib/Math/Prime/Util/ECAffinePoint.pm
+++ b/lib/Math/Prime/Util/ECAffinePoint.pm
@@ -2,13 +2,17 @@ package Math::Prime::Util::ECAffinePoint;
 use strict;
 use warnings;
 use Carp qw/carp croak confess/;
-use Math::BigInt try=>"GMP,Pari";
 
 BEGIN {
   $Math::Prime::Util::ECAffinePoint::AUTHORITY = 'cpan:DANAJ';
   $Math::Prime::Util::ECAffinePoint::VERSION = '0.36';
 }
 
+BEGIN {
+  do { require Math::BigInt;  Math::BigInt->import(try=>"GMP,Pari"); }
+    unless defined $Math::BigInt::VERSION;
+}
+
 # Pure perl (with Math::BigInt) manipulation of Elliptic Curves
 # in affine coordinates.  Should be split into a point class.
 
diff --git a/lib/Math/Prime/Util/ECProjectivePoint.pm 
b/lib/Math/Prime/Util/ECProjectivePoint.pm
index f6343c0..568d6f8 100644
--- a/lib/Math/Prime/Util/ECProjectivePoint.pm
+++ b/lib/Math/Prime/Util/ECProjectivePoint.pm
@@ -2,13 +2,17 @@ package Math::Prime::Util::ECProjectivePoint;
 use strict;
 use warnings;
 use Carp qw/carp croak confess/;
-use Math::BigInt try=>"GMP,Pari";
 
 BEGIN {
   $Math::Prime::Util::ECProjectivePoint::AUTHORITY = 'cpan:DANAJ';
   $Math::Prime::Util::ECProjectivePoint::VERSION = '0.36';
 }
 
+BEGIN {
+  do { require Math::BigInt;  Math::BigInt->import(try=>"GMP,Pari"); }
+    unless defined $Math::BigInt::VERSION;
+}
+
 # Pure perl (with Math::BigInt) manipulation of Elliptic Curves
 # in projective coordinates.
 
diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index ca5eebd..b1bdead 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -2,13 +2,17 @@ package Math::Prime::Util::PP;
 use strict;
 use warnings;
 use Carp qw/carp croak confess/;
-use Math::BigInt try=>"GMP,Pari";
 
 BEGIN {
   $Math::Prime::Util::PP::AUTHORITY = 'cpan:DANAJ';
   $Math::Prime::Util::PP::VERSION = '0.36';
 }
 
+BEGIN {
+  do { require Math::BigInt;  Math::BigInt->import(try=>"GMP,Pari"); }
+    unless defined $Math::BigInt::VERSION;
+}
+
 # The Pure Perl versions of all the Math::Prime::Util routines.
 #
 # Some of these will be relatively similar in performance, some will be
diff --git a/lib/Math/Prime/Util/PrimalityProving.pm 
b/lib/Math/Prime/Util/PrimalityProving.pm
index 69aebf4..1e2cfd5 100644
--- a/lib/Math/Prime/Util/PrimalityProving.pm
+++ b/lib/Math/Prime/Util/PrimalityProving.pm
@@ -2,7 +2,6 @@ package Math::Prime::Util::PrimalityProving;
 use strict;
 use warnings;
 use Carp qw/carp croak confess/;
-use Math::BigInt try=>"GMP,Pari";
 use Math::Prime::Util qw/is_prob_prime is_strong_pseudoprime
                          is_provable_prime_with_cert
                          lucas_sequence
@@ -15,6 +14,11 @@ BEGIN {
   $Math::Prime::Util::PrimalityProving::VERSION = '0.36';
 }
 
+BEGIN {
+  do { require Math::BigInt;  Math::BigInt->import(try=>"GMP,Pari"); }
+    unless defined $Math::BigInt::VERSION;
+}
+
 my $_smallval = Math::BigInt->new("18446744073709551615");
 
 
diff --git a/lib/Math/Prime/Util/PrimeIterator.pm 
b/lib/Math/Prime/Util/PrimeIterator.pm
index 4573c34..6a4c2a7 100644
--- a/lib/Math/Prime/Util/PrimeIterator.pm
+++ b/lib/Math/Prime/Util/PrimeIterator.pm
@@ -13,7 +13,6 @@ our %EXPORT_TAGS = (all => [ @EXPORT_OK ]);
 
 
 use Math::Prime::Util qw/next_prime prev_prime is_prime prime_count nth_prime/;
-use Math::BigInt try => "GMP,Pari";
 
 # We're going to use a scalar rather than a hash because there is currently
 # only one data object (the current value) and this makes it little faster.
diff --git a/lib/Math/Prime/Util/ZetaBigFloat.pm 
b/lib/Math/Prime/Util/ZetaBigFloat.pm
index b87792c..9b2e075 100644
--- a/lib/Math/Prime/Util/ZetaBigFloat.pm
+++ b/lib/Math/Prime/Util/ZetaBigFloat.pm
@@ -7,8 +7,12 @@ BEGIN {
   $Math::Prime::Util::ZetaBigFloat::VERSION = '0.36';
 }
 
-use Math::BigInt try => "GMP,Pari";
-use Math::BigFloat;
+BEGIN {
+  do { require Math::BigInt;  Math::BigInt->import(try=>"GMP,Pari"); }
+    unless defined $Math::BigInt::VERSION;
+  use Math::BigFloat;
+}
+
 
 # Riemann Zeta($k) for integer $k.
 # So many terms and digits are used so we can quickly do bignum R.
diff --git a/t/23-primality-proofs.t b/t/23-primality-proofs.t
index cdc5912..d5f2191 100644
--- a/t/23-primality-proofs.t
+++ b/t/23-primality-proofs.t
@@ -7,7 +7,6 @@ use Math::Prime::Util qw/is_prime is_provable_prime 
is_provable_prime_with_cert
                          prime_certificate verify_prime
                          prime_get_config prime_set_config
                         /;
-use Math::BigInt try => 'GMP';
 
 my $use_test_warn;
 BEGIN {
@@ -42,10 +41,6 @@ if ($extra || prime_get_config->{'gmp'}) {
 #push @plist, 
'531137992816767098689588206552468627329593117727031923199444138200403559860852242739162502265229285668889329486246501015346579337652707239409519978766587351943831270835393219031728127'
 #             if $extra && prime_get_config->{'gmp'};
 
-@plist = sort { $a<=>$b }
-         map { $_ > ~0 ? Math::BigInt->new("$_") : $_ }
-         @plist;
-
 plan tests => 0
             + 2  # is_provable_prime
             + 6 * scalar(@plist)
diff --git a/t/80-pp.t b/t/80-pp.t
index 9294d1a..b744b5e 100644
--- a/t/80-pp.t
+++ b/t/80-pp.t
@@ -271,7 +271,7 @@ use Math::Prime::Util qw/primes prime_count_approx 
prime_count_lower
                          exp_mangoldt chebyshev_theta chebyshev_psi
                          is_prob_prime
                         /;
-use Math::BigInt try => 'GMP';
+use Math::BigInt;
 use Math::BigFloat;
 require_ok 'Math::Prime::Util::PP';
 require_ok 'Math::Prime::Util::PrimalityProving';
diff --git a/t/81-bignum.t b/t/81-bignum.t
index a636b09..6d90652 100644
--- a/t/81-bignum.t
+++ b/t/81-bignum.t
@@ -85,7 +85,7 @@ plan tests =>  0
              + 1;
 
 # Using GMP makes these tests run about 2x faster on some machines
-use bigint try => 'GMP';   #  <--------------- large numbers ahead!  > 2^64
+use bigint try => 'GMP,Pari'; #  <--------------- large numbers ahead!  > 2^64
 use Math::BigFloat;
 
 use Math::Prime::Util qw/
diff --git a/t/94-weaken.t b/t/94-weaken.t
new file mode 100644
index 0000000..6c9c20f
--- /dev/null
+++ b/t/94-weaken.t
@@ -0,0 +1,68 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+BEGIN {
+  unless ($ENV{RELEASE_TESTING}) {
+    require Test::More;
+    Test::More::plan(skip_all => 'these tests are for release candidate 
testing');
+  }
+}
+
+#---------------------------------------------------------------------
+
+
+use Test::More;
+eval "use Test::Weaken";
+plan skip_all => "Test::Weaken required for testing leaks" if $@;
+
+use Math::Prime::Util qw/prime_iterator primes factor moebius/;
+use Math::Prime::Util::PrimeIterator;
+
+my $leaks;
+
+$leaks = Test::Weaken::leaks(
+  { constructor => sub {
+      my $it = prime_iterator(100);
+      return \$it;
+    }
+  });
+ok(!$leaks, "Prime iterator doesn't leak");
+
+$leaks = Test::Weaken::leaks(
+  { constructor => sub {
+      my $it = Math::Prime::Util::PrimeIterator->new(100);
+      return \$it;
+    }
+  });
+ok(!$leaks, "Prime iterator object doesn't leak");
+
+$leaks = Test::Weaken::leaks(
+  { constructor => sub {
+      my $it = prime_iterator("1000000000000000000000000");
+      my $p = $it->();
+      return \$it;
+    }
+  });
+ok(!$leaks, "Prime iterator object doesn't leak");
+
+$leaks = Test::Weaken::leaks(
+  sub {
+    my $primes = primes(66000);
+    return $primes
+  });
+ok(!$leaks, "primes array doesn't leak");
+
+$leaks = Test::Weaken::leaks(
+  sub {
+    return [factor(2938424874)];
+  });
+ok(!$leaks, "factor array doesn't leak");
+
+$leaks = Test::Weaken::leaks(
+  sub {
+    return [moebius(500,1000)];
+  });
+ok(!$leaks, "moebius range doesn't leak");
+
+done_testing();

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

Reply via email to