Commit 0bbaa75f authored by Angel Abad's avatar Angel Abad

New upstream version 1.999800

parent c77145f1
......@@ -1870,6 +1870,39 @@ Fixes:
* Fix typo in lib/Math/BigInt.pm (CPAN RT 118550).
2016-11-15 v1.999800 pjacklam
* Upgrade bundled Module::Install from version 1.16 to version 1.17.
* Add Math::BigInt::Lib (lib/Math/BigInt/Lib.pm), a parent class for
Math::BigInt backend libraries.
* Use objects in Math::BigInt::Calc, not just array refs. Also use OO-style,
i.e., use $class->_add($x, $y) rather than _add($class, $x, $y).
* Not all library methods modify the invocand, so call library methods as,
e.g, $x = $LIB->method($x, $y) rather than just $LIB->method($x, $y).
* Math::BigInt::Calc is now a subclass of Math::BigInt::Lib.
* Add Math::BigInt::Lib::Minimal (t/Math/BigInt/Lib/Minimal.pm) for testing
inheritance from Math::BigInt::Lib.
* Minor simplification in Math::BigInt::Calc->_str().
* Speed up Math::BigInt::Calc->_root().
* Remove test files that were included in the previous release by accident.
* Add more tests and use more verbose output in some tests.
* Fix typo in lib/Math/BigFloat.pm
* Fix documentation error in lib/Math/Calc.pm
* Use Config::Tiny and an .ini file to handle the library specific
configuration for the author-lib*.t test files.
Please send us test-reports, your experiences with this and your ideas - we
love to hear about our work!
......
......@@ -19,6 +19,7 @@ lib/Math/BigFloat.pm
lib/Math/BigInt.pm
lib/Math/BigInt/Calc.pm
lib/Math/BigInt/CalcEmu.pm
lib/Math/BigInt/Lib.pm
LICENSE
Makefile.PL
MANIFEST This list of files
......@@ -46,7 +47,6 @@ t/author-lib-arithmetic-binary-_div.dat
t/author-lib-arithmetic-binary-_div.t
t/author-lib-arithmetic-binary-_gcd.dat
t/author-lib-arithmetic-binary-_gcd.t
t/author-lib-arithmetic-binary-_log_int-alt.t
t/author-lib-arithmetic-binary-_log_int.t
t/author-lib-arithmetic-binary-_mod.dat
t/author-lib-arithmetic-binary-_mod.t
......@@ -54,6 +54,8 @@ t/author-lib-arithmetic-binary-_modinv.dat
t/author-lib-arithmetic-binary-_modinv.t
t/author-lib-arithmetic-binary-_mul.dat
t/author-lib-arithmetic-binary-_mul.t
t/author-lib-arithmetic-binary-_nok.dat
t/author-lib-arithmetic-binary-_nok.t
t/author-lib-arithmetic-binary-_pow.t
t/author-lib-arithmetic-binary-_root.dat
t/author-lib-arithmetic-binary-_root.t
......@@ -104,14 +106,14 @@ t/author-lib-convert-string-_as_hex.t
t/author-lib-convert-string-_as_oct.dat
t/author-lib-convert-string-_as_oct.t
t/author-lib-convert-string-_str.t
t/author-lib-meta-_check.t
t/author-lib-meta-api_version.t
t/author-lib-meta-config.conf
t/author-lib-misc-_check.t
t/author-lib-misc-api_version.t
t/author-lib-property-_alen.t
t/author-lib-property-_digit.t
t/author-lib-property-_len.t
t/author-lib-property-_zeros.t
t/author-lib_load.t
t/author-lib.ini
t/author-lib.t
t/author-numify-mbf.t
t/author-numify-mbi.t
t/author-relop-mbi-mbf.t
......@@ -154,6 +156,7 @@ t/isa.t
t/lib_load.t
t/Math/BigFloat/Subclass.pm
t/Math/BigInt/BareCalc.pm
t/Math/BigInt/Lib/Minimal.pm
t/Math/BigInt/Lib/TestUtil.pm
t/Math/BigInt/Scalar.pm
t/Math/BigInt/Subclass.pm
......
......@@ -23,7 +23,7 @@
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "6.59",
"Test::More" : "0.9301"
"Test::More" : "0.94"
}
},
"configure" : {
......@@ -34,12 +34,12 @@
"runtime" : {
"requires" : {
"Math::Complex" : "1.39",
"Test::More" : "0.9301",
"Test::More" : "0.94",
"perl" : "5.006001"
}
}
},
"release_status" : "stable",
"version" : "1.999727",
"version" : "1.999800",
"x_serialization_backend" : "JSON::PP version 2.27400"
}
......@@ -4,7 +4,7 @@ author:
- '=over 4, Peter John Acklam <pjacklam@online.no>'
build_requires:
ExtUtils::MakeMaker: '6.59'
Test::More: '0.9301'
Test::More: '0.94'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
......@@ -20,7 +20,7 @@ no_index:
- inc
requires:
Math::Complex: '1.39'
Test::More: '0.9301'
Test::More: '0.94'
perl: '5.006001'
version: '1.999727'
version: '1.999800'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
......@@ -16,7 +16,7 @@ all_from 'lib/Math/BigInt.pm';
# Required versions.
requires 'perl' => 5.006001;
requires 'Math::Complex' => 1.39,
test_requires 'Test::More' => 0.9301;
test_requires 'Test::More' => 0.94;
install_as_core();
......
This diff is collapsed.
......@@ -31,7 +31,7 @@ BEGIN {
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
$VERSION = '1.16';
$VERSION = '1.17';
# Storage for the pseudo-singleton
$MAIN = undef;
......@@ -244,6 +244,8 @@ sub new {
}
return $args{_self} if $args{_self};
$base_path = VMS::Filespec::unixify($base_path) if $^O eq 'VMS';
$args{dispatch} ||= 'Admin';
$args{prefix} ||= 'inc';
$args{author} ||= ($^O eq 'VMS' ? '_author' : '.author');
......@@ -322,7 +324,7 @@ sub find_extensions {
my ($self, $path) = @_;
my @found;
File::Find::find( sub {
File::Find::find( {no_chdir => 1, wanted => sub {
my $file = $File::Find::name;
return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
my $subpath = $1;
......@@ -336,7 +338,7 @@ sub find_extensions {
# correctly. Otherwise, root through the file to locate the case-preserved
# version of the package name.
if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
my $content = Module::Install::_read($subpath . '.pm');
my $content = Module::Install::_read($File::Find::name);
my $in_pod = 0;
foreach ( split /\n/, $content ) {
$in_pod = 1 if /^=\w/;
......@@ -351,7 +353,7 @@ sub find_extensions {
}
push @found, [ $file, $pkg ];
}, $path ) if -d $path;
}}, $path ) if -d $path;
@found;
}
......@@ -373,8 +375,6 @@ sub _caller {
return $call;
}
# Done in evals to avoid confusing Perl::MinimumVersion
eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@;
sub _read {
local *FH;
open( FH, '<', $_[0] ) or die "open($_[0]): $!";
......@@ -383,16 +383,6 @@ sub _read {
close FH or die "close($_[0]): $!";
return $string;
}
END_NEW
sub _read {
local *FH;
open( FH, "< $_[0]" ) or die "open($_[0]): $!";
binmode FH;
my $string = do { local $/; <FH> };
close FH or die "close($_[0]): $!";
return $string;
}
END_OLD
sub _readperl {
my $string = Module::Install::_read($_[0]);
......@@ -413,8 +403,6 @@ sub _readpod {
return $string;
}
# Done in evals to avoid confusing Perl::MinimumVersion
eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@;
sub _write {
local *FH;
open( FH, '>', $_[0] ) or die "open($_[0]): $!";
......@@ -424,17 +412,6 @@ sub _write {
}
close FH or die "close($_[0]): $!";
}
END_NEW
sub _write {
local *FH;
open( FH, "> $_[0]" ) or die "open($_[0]): $!";
binmode FH;
foreach ( 1 .. $#_ ) {
print FH $_[$_] or die "print($_[0]): $!";
}
close FH or die "close($_[0]): $!";
}
END_OLD
# _version is for processing module versions (eg, 1.03_05) not
# Perl versions (eg, 5.8.1).
......
......@@ -4,7 +4,7 @@ package Module::Install::Base;
use strict 'vars';
use vars qw{$VERSION};
BEGIN {
$VERSION = '1.16';
$VERSION = '1.17';
}
# Suspend handler for "redefined" warnings
......
......@@ -8,7 +8,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
$VERSION = '1.16';
$VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
......@@ -121,6 +121,15 @@ END_C
# Can we locate a (the) C compiler
sub can_cc {
my $self = shift;
if ($^O eq 'VMS') {
require ExtUtils::CBuilder;
my $builder = ExtUtils::CBuilder->new(
quiet => 1,
);
return $builder->have_compiler;
}
my @chunks = split(/ /, $Config::Config{cc}) or return;
# $Config{cc} may contain args; try to find out the program part
......@@ -151,4 +160,4 @@ if ( $^O eq 'cygwin' ) {
__END__
#line 236
#line 245
......@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
$VERSION = '1.16';
$VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
......
......@@ -8,7 +8,7 @@ use Fcntl qw/:flock :seek/;
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
$VERSION = '1.16';
$VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
......
......@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
$VERSION = '1.16';
$VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
......
......@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
$VERSION = '1.16';
$VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
......
......@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
$VERSION = '1.16';
$VERSION = '1.17';
@ISA = qw{Module::Install::Base};
$ISCORE = 1;
}
......
This diff is collapsed.
......@@ -20,7 +20,7 @@ use warnings;
use Carp ();
our $VERSION = '1.999727';
our $VERSION = '1.999800';
$VERSION = eval $VERSION;
our @ISA = qw(Exporter);
......@@ -54,7 +54,6 @@ use overload
'/' => sub { $_[2] ? ref($_[0]) -> new($_[1]) -> bdiv($_[0])
: $_[0] -> copy -> bdiv($_[1]); },
'%' => sub { $_[2] ? ref($_[0]) -> new($_[1]) -> bmod($_[0])
: $_[0] -> copy -> bmod($_[1]); },
......
This diff is collapsed.
......@@ -4,7 +4,7 @@ use 5.006001;
use strict;
use warnings;
our $VERSION = '1.999727';
our $VERSION = '1.999800';
$VERSION = eval $VERSION;
package Math::BigInt;
......
This diff is collapsed.
This diff is collapsed.
#!perl
package Math::BigInt::Lib::TestUtil;
use strict;
use warnings;
package Math::BigInt::Lib::TestUtil;
use Exporter;
our @ISA = qw< Exporter >;
our @EXPORT_OK = qw< randstr >;
......
......@@ -16,14 +16,31 @@ use Test::More tests => 7705;
###############################################################################
# Read and load configuration file and backend library.
my $conffile = 't/author-lib-meta-config.conf';
open CONFFILE, $conffile or die "$conffile: can't open file for reading: $!";
my $confdata = do { local $/ = undef; <CONFFILE>; };
close CONFFILE or die "$conffile: can't close file after reading: $!";
use Config::Tiny ();
our ($LIB, $REF);
eval $confdata;
die $@ if $@;
my $config_file = 't/author-lib.ini';
my $config = Config::Tiny -> read('t/author-lib.ini')
or die Config::Tiny -> errstr();
# Read the library to test.
our $LIB = $config->{_}->{lib};
die "No library defined in file '$config_file'"
unless defined $LIB;
die "Invalid library name '$LIB' in file '$config_file'"
unless $LIB =~ /^[A-Za-z]\w*(::\w+)*\z/;
# Read the reference type the library uses.
our $REF = $config->{_}->{ref};
die "No reference type defined in file '$config_file'"
unless defined $REF;
die "Invalid reference type '$REF' in file '$config_file'"
unless $REF =~ /^[A-Za-z]\w*(::\w+)*\z/;
# Load the library.
eval "require $LIB";
die $@ if $@;
......@@ -40,7 +57,7 @@ diag "Skipping some tests since Scalar::Util is not installed."
my @data;
# Small numbers (625 tests).
# Small numbers.
for (my $x = 0; $x <= 24 ; ++ $x) {
for (my $y = 0; $y <= 24 ; ++ $y) {
......@@ -48,7 +65,7 @@ for (my $x = 0; $x <= 24 ; ++ $x) {
}
}
# 9 + 11, 99 + 101, 999 + 1001, 9999 + 1001, ... (50 tests)
# 9 + 11, 99 + 101, 999 + 1001, 9999 + 1001, ...
for (my $p = 1; $p <= 50 ; ++ $p) {
my $x = "9" x $p;
......@@ -57,7 +74,7 @@ for (my $p = 1; $p <= 50 ; ++ $p) {
push @data, [ $x, $y, $z ];
}
# 9 + 9, 99 + 99, 999 + 999, 9999 + 9999, ... (50 tests)
# 9 + 9, 99 + 99, 999 + 999, 9999 + 9999, ...
for (my $p = 1; $p <= 50 ; ++ $p) {
my $x = "9" x $p;
......@@ -65,7 +82,7 @@ for (my $p = 1; $p <= 50 ; ++ $p) {
push @data, [ $x, $x, $z ];
}
# Powers of 10 (625 tests).
# Powers of 10.
for (my $p = 0; $p <= 24 ; ++ $p) {
for (my $q = 0; $q <= 24 ; ++ $q) {
......@@ -179,3 +196,4 @@ for (my $i = 0 ; $i <= $#data ; ++ $i) {
"'$test' second output arg is unmodified");
};
}
......@@ -16,14 +16,31 @@ use Test::More tests => 3997;
###############################################################################
# Read and load configuration file and backend library.
my $conffile = 't/author-lib-meta-config.conf';
open CONFFILE, $conffile or die "$conffile: can't open file for reading: $!";
my $confdata = do { local $/ = undef; <CONFFILE>; };
close CONFFILE or die "$conffile: can't close file after reading: $!";
use Config::Tiny ();
our ($LIB, $REF);
eval $confdata;
die $@ if $@;
my $config_file = 't/author-lib.ini';
my $config = Config::Tiny -> read('t/author-lib.ini')
or die Config::Tiny -> errstr();
# Read the library to test.
our $LIB = $config->{_}->{lib};
die "No library defined in file '$config_file'"
unless defined $LIB;
die "Invalid library name '$LIB' in file '$config_file'"
unless $LIB =~ /^[A-Za-z]\w*(::\w+)*\z/;
# Read the reference type(s) the library uses.
our $REF = $config->{_}->{ref};
die "No reference type defined in file '$config_file'"
unless defined $REF;
die "Invalid reference type '$REF' in file '$config_file'"
unless $REF =~ /^[A-Za-z]\w*(::\w+)*\z/;
# Load the library.
eval "require $LIB";
die $@ if $@;
......@@ -40,7 +57,7 @@ diag "Skipping some tests since Scalar::Util is not installed."
my @data;
# Small numbers (625 tests).
# Small numbers.
for (my $x = 0; $x <= 24 ; ++ $x) {
for (my $y = 1; $y <= 24 ; ++ $y) {
......@@ -92,8 +109,13 @@ for (my $i = 0 ; $i <= $#data ; ++ $i) {
"'$test' first output arg is not the second input arg")
if $scalar_util_ok;
is(ref($got[1]), $REF,
"'$test' second output arg is a $REF");
SKIP: {
skip "$LIB doesn't use real objects", 1
if $LIB eq 'Math::BigInt::FastCalc';
is(ref($got[1]), $REF,
"'$test' second output arg is a $REF");
}
is($LIB->_check($got[1]), 0,
"'$test' second output arg is valid");
......@@ -161,3 +183,4 @@ for (my $i = 0 ; $i <= $#data ; ++ $i) {
"'$test' second output arg is unmodified");
};
}
......@@ -16,14 +16,31 @@ use Test::More tests => 10413;
###############################################################################
# Read and load configuration file and backend library.
my $conffile = 't/author-lib-meta-config.conf';
open CONFFILE, $conffile or die "$conffile: can't open file for reading: $!";
my $confdata = do { local $/ = undef; <CONFFILE>; };
close CONFFILE or die "$conffile: can't close file after reading: $!";
use Config::Tiny ();
our ($LIB, $REF);
eval $confdata;
die $@ if $@;
my $config_file = 't/author-lib.ini';
my $config = Config::Tiny -> read('t/author-lib.ini')
or die Config::Tiny -> errstr();
# Read the library to test.
our $LIB = $config->{_}->{lib};
die "No library defined in file '$config_file'"
unless defined $LIB;
die "Invalid library name '$LIB' in file '$config_file'"
unless $LIB =~ /^[A-Za-z]\w*(::\w+)*\z/;
# Read the reference type(s) the library uses.
our $REF = $config->{_}->{ref};
die "No reference type defined in file '$config_file'"
unless defined $REF;
die "Invalid reference type '$REF' in file '$config_file'"
unless $REF =~ /^[A-Za-z]\w*(::\w+)*\z/;
# Load the library.
eval "require $LIB";
die $@ if $@;
......@@ -87,8 +104,11 @@ for (my $i = 0 ; $i <= $#data ; ++ $i) {
is(ref($x), $REF,
"'$test' first input arg is still a $REF");
ok($LIB->_str($x) eq $out0 || $LIB->_str($x) eq $in0,
"'$test' first input arg has the right value");
my $strx = $LIB->_str($x);
ok($strx eq $out0 || $strx eq $in0,
"'$test' first input arg has the right value")
or diag(" got: $strx\n", " expected: ",
$out0 eq $in0 ? $out0 : "$out0 or $in0");
is(ref($y), $REF,
"'$test' second input arg is still a $REF");
......@@ -133,8 +153,11 @@ for (my $i = 0 ; $i <= $#data ; ++ $i) {
is(ref($x), $REF,
"'$test' first input arg is still a $REF");
ok($LIB->_str($x) eq $out0 || $LIB->_str($x) eq $in0,
"'$test' first input arg has the right value");
my $strx = $LIB->_str($x);
ok($strx eq $out0 || $strx eq $in0,
"'$test' first input arg has the right value")
or diag(" got: $strx\n", " expected: ",
$out0 eq $in0 ? $out0 : "$out0 or $in0");
is(ref($y), $REF,
"'$test' second input arg is still a $REF");
......@@ -143,3 +166,4 @@ for (my $i = 0 ; $i <= $#data ; ++ $i) {
"'$test' second input arg is unmodified");
};
}
#!perl
BEGIN {
unless ($ENV{AUTHOR_TESTING}) {
require Test::More;
Test::More::plan(skip_all =>
'these tests are for testing by the author');
}
}
use strict;
use warnings;
use Test::More tests => 18001;
###############################################################################
# Read and load configuration file and backend library.
my $conffile = 't/author-lib-meta-config.conf';
open CONFFILE, $conffile or die "$conffile: can't open file for reading: $!";
my $confdata = do { local $/ = undef; <CONFFILE>; };
close CONFFILE or die "$conffile: can't close file after reading: $!";
our ($LIB, $REF);
eval $confdata;
die $@ if $@;
eval "require $LIB";
die $@ if $@;
###############################################################################
can_ok($LIB, '_log_int');
my $scalar_util_ok = eval { require Scalar::Util; };
Scalar::Util -> import('refaddr') if $scalar_util_ok;
diag "Skipping some tests since Scalar::Util is not installed."
unless $scalar_util_ok;
my @data;
# Small numbers.
for (my $x = 1; $x <= 1000 ; ++ $x) {
for (my $y = 2; $y <= 10 ; ++ $y) {
push @data, [ $x, $y ];
}
}
# List context.
for (my $i = 0 ; $i <= $#data ; ++ $i) {
my ($in0, $in1) = @{ $data[$i] };
my ($x, $y, @got);
my $test = qq|\$x = $LIB->_new("$in0"); |
. qq|\$y = $LIB->_new("$in1"); |
. qq|\@got = $LIB->_log_int(\$x, \$y);|;
eval $test;
is($@, "", "'$test' gives emtpy \$\@");
subtest "_log_int() in list context: $test", sub {
plan tests => $scalar_util_ok ? 8 : 7;
# Number of input arguments.
cmp_ok(scalar @got, '==', 2,
"'$test' gives two output args");
# First output argument.
is(ref($got[0]), $REF,
"'$test' first output arg is a $REF");
is($LIB->_check($got[0]), 0,
"'$test' first output is valid");
isnt(refaddr($got[0]), refaddr($y),
"'$test' first output arg is not the second input arg")
if $scalar_util_ok;
is(ref($x), $REF,
"'$test' first input arg is still a $REF");
# Second output argument.
is(ref($got[1]), "",
"'$test' second output arg is a scalar");
if(!defined($got[1]) || $got[1] == 0 || $got[1] == 1) {
pass("'$test' second output arg is valid");
} else {
fail("'$test' second output arg is valid");
diag(" got: $got[1]");
diag(" expected: 0, 1, or undef");
}
# How to validate the first output argument depends on the second
# output agument.
if (!defined($got[1])) {
# The output might be truncated, which means that it is smaller
# than the exact result, or it might be exact.
my $base = $LIB->_new("$in1");
my $expo_lo = $got[0];
my $powr_lo = $LIB->_pow($LIB->_copy($base), $expo_lo);
my $expo_hi = $LIB->_inc($LIB->_copy($got[0]));
my $powr_hi = $LIB->_pow($LIB->_copy($base), $expo_hi);
my $powr = $LIB->_new("$in0");