Skip to content

Commit

Permalink
Version 0.0013
Browse files Browse the repository at this point in the history
- Fix CPAN RT #147612. The "perl Makefile.PL" step would fail if
  Math::GMPz was not installed.

- Add test file t/02gmpcompat.t to verify that the GMP library is
  compatible, i.e., recent enough.
  • Loading branch information
pjacklam committed Sep 21, 2023
1 parent 33527b6 commit e864430
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGES
@@ -1,3 +1,8 @@
0.0013 2023-09-21

* Fix CPAN RT #147612. The "perl Makefile.PL" step would fail if Math::GMPz
was not installed.

0.0012 2023-09-20

* Sync test files with Math-BigInt.
Expand Down
17 changes: 2 additions & 15 deletions Makefile.PL
Expand Up @@ -4,6 +4,8 @@ use strict;
use warnings;
use ExtUtils::MakeMaker;

print "\nThis module requires gmp-5.1.0 (or later)\n\n";

WriteMakefile
(
'NAME' => 'Math::BigInt::GMPz',
Expand Down Expand Up @@ -53,18 +55,3 @@ WriteMakefile
},
},
);

###############################################################################
# It might be that Math::GMPz was built with an newer version of GMP than the
# one that is currently available. Checking Math::GMPz::gmp_v() won't help,
# since it returns the version of GMP used when Math::GMPz was built, not the
# version of GMP that is currently available.

use Math::GMPz 0.36 qw< :mpz >;

eval { my $x = Rmpz_init(); Rmpz_2fac_ui($x, 0); };

# If Rmpz_2fac_ui() is not implemented, Math::GMPz dies with the message:
# "Rmpz_2fac_ui not implemented - gmp-5.1.0 (or later) is needed"

die "gmp-5.1.0 (or later) is needed" if $@;
2 changes: 1 addition & 1 deletion lib/Math/BigInt/GMPz.pm
Expand Up @@ -8,7 +8,7 @@ use Math::BigInt::Lib 1.999801;

our @ISA = qw< Math::BigInt::Lib >;

our $VERSION = '0.0012';
our $VERSION = '0.0013';

use Math::GMPz 0.36 qw< :mpz >;

Expand Down
24 changes: 24 additions & 0 deletions t/02gmpcompat.t
@@ -0,0 +1,24 @@
# -*- mode: perl; -*-

use strict;
use warnings;

use Test::More tests => 2;

#use Math::GMPz 0.36 qw< :mpz >;
BEGIN { use_ok("Math::GMPz", 0.36, ":mpz") }

# We need GMP 5.1.0 or newer for Rmpz_2fac_ui().

# It might be that Math::GMPz was built with a newer version of GMP than the
# one that is currently available. Checking Math::GMPz::gmp_v() won't help,
# since it seems to return the version of GMP used when Math::GMPz was built,
# not the version of GMP that is currently available.

# If Rmpz_2fac_ui() is not implemented, Math::GMPz dies with the message:
# "Rmpz_2fac_ui not implemented - gmp-5.1.0 (or later) is needed"

eval { my $x = Rmpz_init(); Rmpz_2fac_ui($x, 0); };
ok(! $@, "gmp-5.1.0 (or later) is available") or diag <<"EOF"
The version of the GMP library that is used by Math::GMPz is too old.
EOF

0 comments on commit e864430

Please sign in to comment.