Skip to content

Commit 9bfb09e

Browse files
committed
Update bignum to CPAN version 0.64
[DELTA] * Fix CPAN RT #140470. The pragmas ignored user-specified backend libraries. Add tests to verify the fix. * Add missing documentation.
1 parent 6790b41 commit 9bfb09e

17 files changed

+348
-47
lines changed

MANIFEST

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ cpan/AutoLoader/lib/AutoLoader.pm Autoloader base class
145145
cpan/AutoLoader/lib/AutoSplit.pm Split up autoload functions
146146
cpan/AutoLoader/t/01AutoLoader.t See if AutoLoader works
147147
cpan/AutoLoader/t/02AutoSplit.t See if AutoSplit works
148+
cpan/bignum/gentest/backend.sh
148149
cpan/bignum/gentest/scope-nested-const.sh
149150
cpan/bignum/gentest/scope-nested-hex-oct.sh
150151
cpan/bignum/lib/bigint.pm bigint
@@ -153,6 +154,12 @@ cpan/bignum/lib/bigrat.pm bigrat
153154
cpan/bignum/lib/Math/BigFloat/Trace.pm bignum tracing
154155
cpan/bignum/lib/Math/BigInt/Trace.pm bignum tracing
155156
cpan/bignum/lib/Math/BigRat/Trace.pm
157+
cpan/bignum/t/backend-gmp-bigint.t
158+
cpan/bignum/t/backend-gmp-bignum.t
159+
cpan/bignum/t/backend-gmp-bigrat.t
160+
cpan/bignum/t/backend-pari-bigint.t
161+
cpan/bignum/t/backend-pari-bignum.t
162+
cpan/bignum/t/backend-pari-bigrat.t
156163
cpan/bignum/t/bigexp.t See if bignum works
157164
cpan/bignum/t/bigint.t See if bigint works
158165
cpan/bignum/t/bignum.t See if bignum works

Porting/Maintainers.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ package Maintainers;
186186
},
187187

188188
'bignum' => {
189-
'DISTRIBUTION' => 'PJACKLAM/bignum-0.63.tar.gz',
189+
'DISTRIBUTION' => 'PJACKLAM/bignum-0.64.tar.gz',
190190
'FILES' => q[cpan/bignum],
191191
'EXCLUDED' => [
192192
qr{^xt/},

cpan/bignum/gentest/backend.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash -u
2+
3+
modules=(
4+
bigint
5+
bignum
6+
bigrat
7+
)
8+
9+
backends=(
10+
#FastCalc
11+
GMP
12+
Pari
13+
#GMPz
14+
#BitVect
15+
#LTM
16+
)
17+
18+
dirname=$( dirname -- "$0" ) || exit
19+
cd "$dirname" || exit
20+
21+
gitroot=$( git rev-parse --show-toplevel ) || exit
22+
cd "$gitroot" || exit
23+
24+
for backend in ${backends[@]}; do
25+
for module in ${modules[@]}; do
26+
file=t/backend-${backend,,}-$module.t
27+
cat <<EOF >$file
28+
# -*- mode: perl; -*-
29+
30+
use strict;
31+
use warnings;
32+
33+
use Test::More;
34+
35+
BEGIN {
36+
eval { require Math::BigInt::$backend; };
37+
if (\$@) {
38+
plan skip_all => "Math::BigInt::$backend not installed";
39+
} else {
40+
plan tests => "1";
41+
}
42+
}
43+
44+
use $module only => "$backend";
45+
46+
my \$x = 1;
47+
is(\$x -> config("lib"), "Math::BigInt::$backend",
48+
"backend is Math::BigInt::$backend");
49+
EOF
50+
echo "Wrote '$file'"
51+
done
52+
done

cpan/bignum/gentest/scope-nested-const.sh

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ eval 'exec ${PERL-perl} -Sx "$0" ${1+"$@"}'
1010
use strict;
1111
use warnings;
1212

13+
use File::Basename;
14+
15+
my $outfile = "t/scope-nested-hex-oct.t";
16+
17+
my $dirname = dirname(__FILE__);
18+
chdir $dirname
19+
or die "$dirname: chdir failed: $!";
20+
21+
chomp(my $gitroot = `git rev-parse --show-toplevel`);
22+
chdir $gitroot
23+
or die "$gitroot: chdir failed: $!";
24+
25+
open my($fh), ">", $outfile
26+
or die "$outfile: can't open file for writing: $!";
27+
1328
use Algorithm::Combinatorics 'permutations';
1429

1530
my $data = [
@@ -18,13 +33,17 @@ my $data = [
1833
['bigrat', 'Math::BigRat' ],
1934
];
2035

21-
print <<"EOF";
22-
#!perl
36+
print $fh <<'EOF' or die "$outfile: print failed: $!";
37+
# -*- mode: perl; -*-
2338
2439
use strict;
2540
use warnings;
2641
27-
use Test::More tests => 48;
42+
use Test::More;
43+
44+
plan skip_all => 'Need at least Perl v5.10.1' if $] < "5.010001";
45+
46+
plan tests => 96;
2847
EOF
2948

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

40-
print <<"EOF";
59+
print $fh <<"EOF" or die "$outfile: print failed: $!";
4160
4261
note "\\n$p0 -> $p1 -> $p2\\n\\n";
4362
4463
{
4564
note "use $p0;";
4665
use $p0;
47-
is(ref(1), "$c0");
66+
is(ref(hex("1")), "$c0", 'ref(hex("1"))');
67+
is(ref(oct("1")), "$c0", 'ref(oct("1"))');
4868
4969
{
5070
note "use $p1;";
5171
use $p1;
52-
is(ref(1), "$c1");
72+
is(ref(hex("1")), "$c1", 'ref(hex("1"))');
73+
is(ref(oct("1")), "$c1", 'ref(oct("1"))');
5374
5475
{
5576
note "use $p2;";
5677
use $p2;
57-
is(ref(1), "$c2");
78+
is(ref(hex("1")), "$c2", 'ref(hex("1"))');
79+
is(ref(oct("1")), "$c2", 'ref(oct("1"))');
5880
5981
note "no $p2;";
6082
no $p2;
61-
is(ref(1), "");
83+
is(ref(hex("1")), "", 'ref(hex("1"))');
84+
is(ref(oct("1")), "", 'ref(oct("1"))');
6285
}
6386
64-
is(ref(1), "$c1");
87+
is(ref(hex("1")), "$c1", 'ref(hex("1"))');
88+
is(ref(oct("1")), "$c1", 'ref(oct("1"))');
6589
6690
note "no $p1;";
6791
no $p1;
68-
is(ref(1), "");
92+
is(ref(hex("1")), "", 'ref(hex("1"))');
93+
is(ref(oct("1")), "", 'ref(oct("1"))');
6994
}
7095
71-
is(ref(1), "$c0");
96+
is(ref(hex("1")), "$c0", 'ref(hex("1"))');
97+
is(ref(oct("1")), "$c0", 'ref(oct("1"))');
7298
7399
note "no $p0;";
74100
no $p0;
75-
is(ref(1), "");
101+
is(ref(hex("1")), "", 'ref(hex("1"))');
102+
is(ref(oct("1")), "", 'ref(oct("1"))');
76103
}
77104
EOF
78105
}
106+
107+
close($fh)
108+
or die "$outfile: can't close file after writing: $!";
109+
110+
print "Wrote '$outfile'\n";

cpan/bignum/gentest/scope-nested-hex-oct.sh

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ eval 'exec ${PERL-perl} -Sx "$0" ${1+"$@"}'
1010
use strict;
1111
use warnings;
1212

13+
use File::Basename;
14+
15+
my $outfile = "t/scope-nested-hex-oct.t";
16+
17+
my $dirname = dirname(__FILE__);
18+
chdir $dirname
19+
or die "$dirname: chdir failed: $!";
20+
21+
chomp(my $gitroot = `git rev-parse --show-toplevel`);
22+
chdir $gitroot
23+
or die "$gitroot: chdir failed: $!";
24+
25+
open my($fh), ">", $outfile
26+
or die "$outfile: can't open file for writing: $!";
27+
1328
use Algorithm::Combinatorics 'permutations';
1429

1530
my $data = [
@@ -18,13 +33,17 @@ my $data = [
1833
['bigrat', 'Math::BigRat' ],
1934
];
2035

21-
print <<"EOF";
22-
#!perl
36+
print $fh <<'EOF' or die "$outfile: print failed: $!";
37+
# -*- mode: perl; -*-
2338
2439
use strict;
2540
use warnings;
2641
27-
use Test::More tests => 96;
42+
use Test::More;
43+
44+
plan skip_all => 'Need at least Perl v5.10.1' if $] < "5.010001";
45+
46+
plan tests => 96;
2847
EOF
2948

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

40-
print <<"EOF";
59+
print $fh <<"EOF" or die "$outfile: print failed: $!";
4160
4261
note "\\n$p0 -> $p1 -> $p2\\n\\n";
4362
@@ -84,3 +103,8 @@ note "\\n$p0 -> $p1 -> $p2\\n\\n";
84103
}
85104
EOF
86105
}
106+
107+
close($fh)
108+
or die "$outfile: can't close file after writing: $!";
109+
110+
print "Wrote '$outfile'\n";

cpan/bignum/lib/Math/BigFloat/Trace.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use Math::BigFloat;
1010

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

13-
our $VERSION = '0.63';
13+
our $VERSION = '0.64';
1414

1515
use overload; # inherit overload from Math::BigFloat
1616

cpan/bignum/lib/Math/BigInt/Trace.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use Math::BigInt;
1010

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

13-
our $VERSION = '0.63';
13+
our $VERSION = '0.64';
1414

1515
use overload; # inherit overload from Math::BigInt
1616

cpan/bignum/lib/Math/BigRat/Trace.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use Math::BigRat;
1010

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

13-
our $VERSION = '0.63';
13+
our $VERSION = '0.64';
1414

1515
use overload; # inherit overload from Math::BigRat
1616

cpan/bignum/lib/bigint.pm

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ use warnings;
55

66
use Carp qw< carp croak >;
77

8-
our $VERSION = '0.63';
8+
our $VERSION = '0.64';
99

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

1515
use overload;
16-
use Math::BigInt;
1716

1817
my $obj_class = "Math::BigInt";
1918

@@ -303,35 +302,35 @@ sub import {
303302
# Upgrading.
304303

305304
if ($param eq 'upgrade') {
306-
$class -> upgrade(shift);
305+
push @import, 'upgrade', shift();
307306
next;
308307
}
309308

310309
# Downgrading.
311310

312311
if ($param eq 'downgrade') {
313-
$class -> downgrade(shift);
312+
push @import, 'downgrade', shift();
314313
next;
315314
}
316315

317316
# Accuracy.
318317

319318
if ($param =~ /^a(ccuracy)?$/) {
320-
$class -> accuracy(shift);
319+
push @import, 'accuracy', shift();
321320
next;
322321
}
323322

324323
# Precision.
325324

326325
if ($param =~ /^p(recision)?$/) {
327-
$class -> precision(shift);
326+
push @import, 'precision', shift();
328327
next;
329328
}
330329

331330
# Rounding mode.
332331

333332
if ($param eq 'round_mode') {
334-
$class -> round_mode(shift);
333+
push @import, 'round_mode', shift();
335334
next;
336335
}
337336

@@ -363,6 +362,8 @@ sub import {
363362
croak("Unknown option '$param'");
364363
}
365364

365+
eval "require $obj_class";
366+
die $@ if $@;
366367
$obj_class -> import(@import);
367368

368369
if ($ver) {
@@ -713,10 +714,29 @@ Example:
713714
714715
# perl -Mbigint=bpi -wle 'print bpi(80)'
715716
717+
=item accuracy()
718+
719+
Set or get the accuracy.
720+
721+
=item precision()
722+
723+
Set or get the precision.
724+
725+
=item round_mode()
726+
727+
Set or get the rounding mode.
728+
729+
=item div_scale()
730+
731+
Set or get the division scale.
732+
716733
=item upgrade()
717734
718-
Return the class that numbers are upgraded to, is in fact returning
719-
C<Math::BigInt-E<gt>upgrade()>.
735+
Return the class that numbers are upgraded to, if any.
736+
737+
=item downgrade()
738+
739+
Return the class that numbers are downgraded to, if any.
720740
721741
=item in_effect()
722742

0 commit comments

Comments
 (0)