Skip to content

Commit

Permalink
Update bignum to CPAN version 0.64
Browse files Browse the repository at this point in the history
    [DELTA]

 * Fix CPAN RT #140470. The pragmas ignored user-specified backend libraries.
   Add tests to verify the fix.

 * Add missing documentation.
  • Loading branch information
atoomic committed Jan 20, 2022
1 parent ac1fab1 commit 3ac7c91
Show file tree
Hide file tree
Showing 17 changed files with 348 additions and 47 deletions.
7 changes: 7 additions & 0 deletions MANIFEST
Expand Up @@ -145,6 +145,7 @@ cpan/AutoLoader/lib/AutoLoader.pm Autoloader base class
cpan/AutoLoader/lib/AutoSplit.pm Split up autoload functions
cpan/AutoLoader/t/01AutoLoader.t See if AutoLoader works
cpan/AutoLoader/t/02AutoSplit.t See if AutoSplit works
cpan/bignum/gentest/backend.sh
cpan/bignum/gentest/scope-nested-const.sh
cpan/bignum/gentest/scope-nested-hex-oct.sh
cpan/bignum/lib/bigint.pm bigint
Expand All @@ -153,6 +154,12 @@ cpan/bignum/lib/bigrat.pm bigrat
cpan/bignum/lib/Math/BigFloat/Trace.pm bignum tracing
cpan/bignum/lib/Math/BigInt/Trace.pm bignum tracing
cpan/bignum/lib/Math/BigRat/Trace.pm
cpan/bignum/t/backend-gmp-bigint.t
cpan/bignum/t/backend-gmp-bignum.t
cpan/bignum/t/backend-gmp-bigrat.t
cpan/bignum/t/backend-pari-bigint.t
cpan/bignum/t/backend-pari-bignum.t
cpan/bignum/t/backend-pari-bigrat.t
cpan/bignum/t/bigexp.t See if bignum works
cpan/bignum/t/bigint.t See if bigint works
cpan/bignum/t/bignum.t See if bignum works
Expand Down
2 changes: 1 addition & 1 deletion Porting/Maintainers.pl
Expand Up @@ -186,7 +186,7 @@ package Maintainers;
},

'bignum' => {
'DISTRIBUTION' => 'PJACKLAM/bignum-0.63.tar.gz',
'DISTRIBUTION' => 'PJACKLAM/bignum-0.64.tar.gz',
'FILES' => q[cpan/bignum],
'EXCLUDED' => [
qr{^xt/},
Expand Down
52 changes: 52 additions & 0 deletions cpan/bignum/gentest/backend.sh
@@ -0,0 +1,52 @@
#!/bin/bash -u

modules=(
bigint
bignum
bigrat
)

backends=(
#FastCalc
GMP
Pari
#GMPz
#BitVect
#LTM
)

dirname=$( dirname -- "$0" ) || exit
cd "$dirname" || exit

gitroot=$( git rev-parse --show-toplevel ) || exit
cd "$gitroot" || exit

for backend in ${backends[@]}; do
for module in ${modules[@]}; do
file=t/backend-${backend,,}-$module.t
cat <<EOF >$file
# -*- mode: perl; -*-
use strict;
use warnings;
use Test::More;
BEGIN {
eval { require Math::BigInt::$backend; };
if (\$@) {
plan skip_all => "Math::BigInt::$backend not installed";
} else {
plan tests => "1";
}
}
use $module only => "$backend";
my \$x = 1;
is(\$x -> config("lib"), "Math::BigInt::$backend",
"backend is Math::BigInt::$backend");
EOF
echo "Wrote '$file'"
done
done
56 changes: 44 additions & 12 deletions cpan/bignum/gentest/scope-nested-const.sh
Expand Up @@ -10,6 +10,21 @@ eval 'exec ${PERL-perl} -Sx "$0" ${1+"$@"}'
use strict;
use warnings;

use File::Basename;

my $outfile = "t/scope-nested-hex-oct.t";

my $dirname = dirname(__FILE__);
chdir $dirname
or die "$dirname: chdir failed: $!";

chomp(my $gitroot = `git rev-parse --show-toplevel`);
chdir $gitroot
or die "$gitroot: chdir failed: $!";

open my($fh), ">", $outfile
or die "$outfile: can't open file for writing: $!";

use Algorithm::Combinatorics 'permutations';

my $data = [
Expand All @@ -18,13 +33,17 @@ my $data = [
['bigrat', 'Math::BigRat' ],
];

print <<"EOF";
#!perl
print $fh <<'EOF' or die "$outfile: print failed: $!";
# -*- mode: perl; -*-
use strict;
use warnings;
use Test::More tests => 48;
use Test::More;
plan skip_all => 'Need at least Perl v5.10.1' if $] < "5.010001";
plan tests => 96;
EOF

my $iter = permutations([0, 1, 2]);
Expand All @@ -37,42 +56,55 @@ while (my $idxs = $iter -> next()) {
my $p2 = $data -> [ $idxs -> [2] ][0];
my $c2 = $data -> [ $idxs -> [2] ][1];

print <<"EOF";
print $fh <<"EOF" or die "$outfile: print failed: $!";
note "\\n$p0 -> $p1 -> $p2\\n\\n";
{
note "use $p0;";
use $p0;
is(ref(1), "$c0");
is(ref(hex("1")), "$c0", 'ref(hex("1"))');
is(ref(oct("1")), "$c0", 'ref(oct("1"))');
{
note "use $p1;";
use $p1;
is(ref(1), "$c1");
is(ref(hex("1")), "$c1", 'ref(hex("1"))');
is(ref(oct("1")), "$c1", 'ref(oct("1"))');
{
note "use $p2;";
use $p2;
is(ref(1), "$c2");
is(ref(hex("1")), "$c2", 'ref(hex("1"))');
is(ref(oct("1")), "$c2", 'ref(oct("1"))');
note "no $p2;";
no $p2;
is(ref(1), "");
is(ref(hex("1")), "", 'ref(hex("1"))');
is(ref(oct("1")), "", 'ref(oct("1"))');
}
is(ref(1), "$c1");
is(ref(hex("1")), "$c1", 'ref(hex("1"))');
is(ref(oct("1")), "$c1", 'ref(oct("1"))');
note "no $p1;";
no $p1;
is(ref(1), "");
is(ref(hex("1")), "", 'ref(hex("1"))');
is(ref(oct("1")), "", 'ref(oct("1"))');
}
is(ref(1), "$c0");
is(ref(hex("1")), "$c0", 'ref(hex("1"))');
is(ref(oct("1")), "$c0", 'ref(oct("1"))');
note "no $p0;";
no $p0;
is(ref(1), "");
is(ref(hex("1")), "", 'ref(hex("1"))');
is(ref(oct("1")), "", 'ref(oct("1"))');
}
EOF
}

close($fh)
or die "$outfile: can't close file after writing: $!";

print "Wrote '$outfile'\n";
32 changes: 28 additions & 4 deletions cpan/bignum/gentest/scope-nested-hex-oct.sh
Expand Up @@ -10,6 +10,21 @@ eval 'exec ${PERL-perl} -Sx "$0" ${1+"$@"}'
use strict;
use warnings;

use File::Basename;

my $outfile = "t/scope-nested-hex-oct.t";

my $dirname = dirname(__FILE__);
chdir $dirname
or die "$dirname: chdir failed: $!";

chomp(my $gitroot = `git rev-parse --show-toplevel`);
chdir $gitroot
or die "$gitroot: chdir failed: $!";

open my($fh), ">", $outfile
or die "$outfile: can't open file for writing: $!";

use Algorithm::Combinatorics 'permutations';

my $data = [
Expand All @@ -18,13 +33,17 @@ my $data = [
['bigrat', 'Math::BigRat' ],
];

print <<"EOF";
#!perl
print $fh <<'EOF' or die "$outfile: print failed: $!";
# -*- mode: perl; -*-
use strict;
use warnings;
use Test::More tests => 96;
use Test::More;
plan skip_all => 'Need at least Perl v5.10.1' if $] < "5.010001";
plan tests => 96;
EOF

my $iter = permutations([0, 1, 2]);
Expand All @@ -37,7 +56,7 @@ while (my $idxs = $iter -> next()) {
my $p2 = $data -> [ $idxs -> [2] ][0];
my $c2 = $data -> [ $idxs -> [2] ][1];

print <<"EOF";
print $fh <<"EOF" or die "$outfile: print failed: $!";
note "\\n$p0 -> $p1 -> $p2\\n\\n";
Expand Down Expand Up @@ -84,3 +103,8 @@ note "\\n$p0 -> $p1 -> $p2\\n\\n";
}
EOF
}

close($fh)
or die "$outfile: can't close file after writing: $!";

print "Wrote '$outfile'\n";
2 changes: 1 addition & 1 deletion cpan/bignum/lib/Math/BigFloat/Trace.pm
Expand Up @@ -10,7 +10,7 @@ use Math::BigFloat;

our @ISA = qw(Exporter Math::BigFloat);

our $VERSION = '0.63';
our $VERSION = '0.64';

use overload; # inherit overload from Math::BigFloat

Expand Down
2 changes: 1 addition & 1 deletion cpan/bignum/lib/Math/BigInt/Trace.pm
Expand Up @@ -10,7 +10,7 @@ use Math::BigInt;

our @ISA = qw(Exporter Math::BigInt);

our $VERSION = '0.63';
our $VERSION = '0.64';

use overload; # inherit overload from Math::BigInt

Expand Down
2 changes: 1 addition & 1 deletion cpan/bignum/lib/Math/BigRat/Trace.pm
Expand Up @@ -10,7 +10,7 @@ use Math::BigRat;

our @ISA = qw(Exporter Math::BigRat);

our $VERSION = '0.63';
our $VERSION = '0.64';

use overload; # inherit overload from Math::BigRat

Expand Down
38 changes: 29 additions & 9 deletions cpan/bignum/lib/bigint.pm
Expand Up @@ -5,15 +5,14 @@ use warnings;

use Carp qw< carp croak >;

our $VERSION = '0.63';
our $VERSION = '0.64';

use Exporter;
our @ISA = qw( Exporter );
our @EXPORT_OK = qw( PI e bpi bexp hex oct );
our @EXPORT = qw( inf NaN );

use overload;
use Math::BigInt;

my $obj_class = "Math::BigInt";

Expand Down Expand Up @@ -303,35 +302,35 @@ sub import {
# Upgrading.

if ($param eq 'upgrade') {
$class -> upgrade(shift);
push @import, 'upgrade', shift();
next;
}

# Downgrading.

if ($param eq 'downgrade') {
$class -> downgrade(shift);
push @import, 'downgrade', shift();
next;
}

# Accuracy.

if ($param =~ /^a(ccuracy)?$/) {
$class -> accuracy(shift);
push @import, 'accuracy', shift();
next;
}

# Precision.

if ($param =~ /^p(recision)?$/) {
$class -> precision(shift);
push @import, 'precision', shift();
next;
}

# Rounding mode.

if ($param eq 'round_mode') {
$class -> round_mode(shift);
push @import, 'round_mode', shift();
next;
}

Expand Down Expand Up @@ -363,6 +362,8 @@ sub import {
croak("Unknown option '$param'");
}

eval "require $obj_class";
die $@ if $@;
$obj_class -> import(@import);

if ($ver) {
Expand Down Expand Up @@ -713,10 +714,29 @@ Example:
# perl -Mbigint=bpi -wle 'print bpi(80)'
=item accuracy()
Set or get the accuracy.
=item precision()
Set or get the precision.
=item round_mode()
Set or get the rounding mode.
=item div_scale()
Set or get the division scale.
=item upgrade()
Return the class that numbers are upgraded to, is in fact returning
C<Math::BigInt-E<gt>upgrade()>.
Return the class that numbers are upgraded to, if any.
=item downgrade()
Return the class that numbers are downgraded to, if any.
=item in_effect()
Expand Down

0 comments on commit 3ac7c91

Please sign in to comment.