summaryrefslogtreecommitdiff
path: root/cpan/bignum
diff options
context:
space:
mode:
authorSteve Hay <steve.m.hay@googlemail.com>2016-01-05 13:12:45 +0000
committerSteve Hay <steve.m.hay@googlemail.com>2016-01-05 13:12:45 +0000
commit91f07087781a2b155e844d6d5ee997b10844affb (patch)
tree66aac0bc5c8235012e417708fe497eb5c97b30a1 /cpan/bignum
parentda020b69a81e38794f67c761b89c5db2ae4f0856 (diff)
downloadperl-91f07087781a2b155e844d6d5ee997b10844affb.tar.gz
Upgrade bignum from version 0.41 to 0.42
Diffstat (limited to 'cpan/bignum')
-rw-r--r--cpan/bignum/lib/Math/BigFloat/Trace.pm13
-rw-r--r--cpan/bignum/lib/Math/BigInt/Trace.pm17
-rw-r--r--cpan/bignum/lib/bigint.pm17
-rw-r--r--cpan/bignum/lib/bignum.pm21
-rw-r--r--cpan/bignum/lib/bigrat.pm23
-rw-r--r--cpan/bignum/t/auth-bigint-hex.t49
-rw-r--r--cpan/bignum/t/auth-bigint-oct.t49
-rw-r--r--cpan/bignum/t/big_e_pi.t12
-rw-r--r--cpan/bignum/t/bigexp.t16
-rw-r--r--cpan/bignum/t/bigint.t106
-rw-r--r--cpan/bignum/t/bignum.t91
-rw-r--r--cpan/bignum/t/bigrat.t102
-rw-r--r--cpan/bignum/t/bii_e_pi.t14
-rw-r--r--cpan/bignum/t/biinfnan.t21
-rw-r--r--cpan/bignum/t/bir_e_pi.t17
-rw-r--r--cpan/bignum/t/bn_lite.t29
-rw-r--r--cpan/bignum/t/bninfnan.t21
-rw-r--r--cpan/bignum/t/br_lite.t29
-rw-r--r--cpan/bignum/t/brinfnan.t21
-rw-r--r--cpan/bignum/t/in_effect.t33
-rw-r--r--cpan/bignum/t/infnan.inc85
-rw-r--r--cpan/bignum/t/option_a.t23
-rw-r--r--cpan/bignum/t/option_l.t53
-rw-r--r--cpan/bignum/t/option_p.t23
-rw-r--r--cpan/bignum/t/overrides.t144
-rw-r--r--cpan/bignum/t/ratopt_a.t25
-rw-r--r--cpan/bignum/t/scope_f.t4
-rw-r--r--cpan/bignum/t/scope_i.t33
-rw-r--r--cpan/bignum/t/scope_r.t31
29 files changed, 585 insertions, 537 deletions
diff --git a/cpan/bignum/lib/Math/BigFloat/Trace.pm b/cpan/bignum/lib/Math/BigFloat/Trace.pm
index a034615fc2..5e043f5ef0 100644
--- a/cpan/bignum/lib/Math/BigFloat/Trace.pm
+++ b/cpan/bignum/lib/Math/BigFloat/Trace.pm
@@ -1,18 +1,19 @@
-#!/usr/bin/perl -w
+#!perl
package Math::BigFloat::Trace;
-require 5.005_02;
+require 5.006;
use strict;
+use warnings;
use Exporter;
use Math::BigFloat;
-use vars qw($VERSION @ISA $PACKAGE @EXPORT_OK
- $accuracy $precision $round_mode $div_scale);
-@ISA = qw(Exporter Math::BigFloat);
+our ($PACKAGE, @EXPORT_OK, $accuracy, $precision, $round_mode, $div_scale);
-$VERSION = '0.41';
+our @ISA = qw(Exporter Math::BigFloat);
+
+our $VERSION = '0.42';
use overload; # inherit overload from BigFloat
diff --git a/cpan/bignum/lib/Math/BigInt/Trace.pm b/cpan/bignum/lib/Math/BigInt/Trace.pm
index b43f36ee34..646c05f645 100644
--- a/cpan/bignum/lib/Math/BigInt/Trace.pm
+++ b/cpan/bignum/lib/Math/BigInt/Trace.pm
@@ -1,18 +1,19 @@
-#!/usr/bin/perl -w
+#!perl
package Math::BigInt::Trace;
-require 5.005_02;
+require 5.006;
use strict;
+use warnings;
use Exporter;
use Math::BigInt;
-use vars qw($VERSION @ISA $PACKAGE @EXPORT_OK
- $accuracy $precision $round_mode $div_scale);
-@ISA = qw(Exporter Math::BigInt);
+our ($PACKAGE, @EXPORT_OK, $accuracy, $precision, $round_mode, $div_scale);
-$VERSION = '0.41';
+our @ISA = qw(Exporter Math::BigInt);
+
+our $VERSION = '0.42';
use overload; # inherit overload from BigInt
@@ -22,8 +23,8 @@ $round_mode = 'even';
$div_scale = 40;
sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
my $value = shift;
my $a = $accuracy;
diff --git a/cpan/bignum/lib/bigint.pm b/cpan/bignum/lib/bigint.pm
index 71009a43fe..a47191e271 100644
--- a/cpan/bignum/lib/bigint.pm
+++ b/cpan/bignum/lib/bigint.pm
@@ -1,13 +1,16 @@
package bigint;
+
use 5.006;
+use strict;
+use warnings;
+
+our $VERSION = '0.42';
-$VERSION = '0.41';
use Exporter;
-@ISA = qw( Exporter );
-@EXPORT_OK = qw( PI e bpi bexp hex oct );
-@EXPORT = qw( inf NaN );
+our @ISA = qw( Exporter );
+our @EXPORT_OK = qw( PI e bpi bexp hex oct );
+our @EXPORT = qw( inf NaN );
-use strict;
use overload;
##############################################################################
@@ -15,7 +18,7 @@ use overload;
# These are all alike, and thus faked by AUTOLOAD
my @faked = qw/round_mode accuracy precision div_scale/;
-use vars qw/$VERSION $AUTOLOAD $_lite/; # _lite for testsuite
+our ($AUTOLOAD, $_lite); # _lite for testsuite
sub AUTOLOAD {
my $name = $AUTOLOAD;
@@ -371,6 +374,8 @@ sub bexp ($$) {
__END__
+=pod
+
=head1 NAME
bigint - Transparent BigInteger support for Perl
diff --git a/cpan/bignum/lib/bignum.pm b/cpan/bignum/lib/bignum.pm
index 9387ff06df..90d5db5aed 100644
--- a/cpan/bignum/lib/bignum.pm
+++ b/cpan/bignum/lib/bignum.pm
@@ -1,13 +1,16 @@
package bignum;
+
use 5.006;
+use strict;
+use warnings;
+
+our $VERSION = '0.42';
-$VERSION = '0.41';
use Exporter;
-@ISA = qw( bigint );
-@EXPORT_OK = qw( PI e bexp bpi hex oct );
-@EXPORT = qw( inf NaN );
+our @ISA = qw( bigint );
+our @EXPORT_OK = qw( PI e bpi bexp hex oct );
+our @EXPORT = qw( inf NaN );
-use strict;
use overload;
use bigint ();
@@ -23,12 +26,12 @@ BEGIN {
# These are all alike, and thus faked by AUTOLOAD
my @faked = qw/round_mode accuracy precision div_scale/;
-use vars qw/$VERSION $AUTOLOAD $_lite/; # _lite for testsuite
+our ($AUTOLOAD, $_lite); # _lite for testsuite
sub AUTOLOAD {
my $name = $AUTOLOAD;
- $name =~ s/.*:://; # split package
+ $name =~ s/.*:://; # split package
no strict 'refs';
foreach my $n (@faked) {
if ($n eq $name) {
@@ -207,7 +210,7 @@ sub import {
sub PI () { Math::BigFloat->new('3.141592653589793238462643383279502884197'); }
sub e () { Math::BigFloat->new('2.718281828459045235360287471352662497757'); }
-sub bpi ($) { Math::BigFloat::bpi(@_); }
+sub bpi ($) { Math::BigFloat->bpi(@_); }
sub bexp ($$) {
my $x = Math::BigFloat->new($_[0]);
$x->bexp($_[1]);
@@ -217,6 +220,8 @@ sub bexp ($$) {
__END__
+=pod
+
=head1 NAME
bignum - Transparent BigNumber support for Perl
diff --git a/cpan/bignum/lib/bigrat.pm b/cpan/bignum/lib/bigrat.pm
index 11cb6cdc39..79fe84d9f7 100644
--- a/cpan/bignum/lib/bigrat.pm
+++ b/cpan/bignum/lib/bigrat.pm
@@ -1,13 +1,16 @@
package bigrat;
+
use 5.006;
+use strict;
+use warnings;
-$VERSION = '0.41';
-require Exporter;
-@ISA = qw( bigint );
-@EXPORT_OK = qw( PI e bpi bexp hex oct );
-@EXPORT = qw( inf NaN );
+our $VERSION = '0.42';
+
+use Exporter;
+our @ISA = qw( bigint );
+our @EXPORT_OK = qw( PI e bpi bexp hex oct );
+our @EXPORT = qw( inf NaN );
-use strict;
use overload;
use bigint ();
@@ -23,7 +26,7 @@ BEGIN {
# These are all alike, and thus faked by AUTOLOAD
my @faked = qw/round_mode accuracy precision div_scale/;
-use vars qw/$VERSION $AUTOLOAD $_lite/; # _lite for testsuite
+our ($AUTOLOAD, $_lite); # _lite for testsuite
sub AUTOLOAD {
my $name = $AUTOLOAD;
@@ -194,11 +197,11 @@ sub import {
}
sub PI () { Math::BigFloat->new('3.141592653589793238462643383279502884197'); }
-sub e () { Math::BigFloat->new('2.718281828459045235360287471352662497757'); }
+sub e () { Math::BigFloat->new('2.718281828459045235360287471352662497757'); }
sub bpi ($) {
local $Math::BigFloat::upgrade;
- Math::BigFloat::bpi(@_);
+ Math::BigFloat->bpi(@_);
}
sub bexp ($$) {
@@ -211,6 +214,8 @@ sub bexp ($$) {
__END__
+=pod
+
=head1 NAME
bigrat - Transparent BigNumber/BigRational support for Perl
diff --git a/cpan/bignum/t/auth-bigint-hex.t b/cpan/bignum/t/auth-bigint-hex.t
deleted file mode 100644
index 76a38dea77..0000000000
--- a/cpan/bignum/t/auth-bigint-hex.t
+++ /dev/null
@@ -1,49 +0,0 @@
-#!perl
-
-BEGIN {
- unless ($ENV{AUTHOR_TESTING}) {
- require Test::More;
- Test::More::plan(skip_all => 'these tests are for release candidate testing');
- }
-}
-
-use strict;
-use warnings;
-
-use Test::More tests => 507068;
-
-use Algorithm::Combinatorics qw< variations >;
-
-use bigint;
-
-use Test::More;
-
-my $elements = ['0', 'b', 'x', '1', '1', '_', '_', '9', 'z'];
-
-for my $k (0 .. @$elements) {
- my $seen = {};
- for my $variation (variations($elements, $k)) {
- my $str = join "", @$variation;
- next if $seen -> {$str}++;
- print qq|#\n# hex("$str")\n#\n|;
-
- my $i;
- my @warnings;
- local $SIG{__WARN__} = sub {
- my $warning = shift;
- $warning =~ s/ at .*\z//s;
- $warnings[$i] = $warning;
- };
-
- $i = 0;
- my $want_val = CORE::hex("$str");
- my $want_warn = $warnings[$i];
-
- $i = 1;
- my $got_val = bigint::hex("$str");
- my $got_warn = $warnings[$i];
-
- is($got_val, $want_val, qq|hex("$str") (output)|);
- is($got_warn, $want_warn, qq|hex("$str") (warning)|);
- }
-}
diff --git a/cpan/bignum/t/auth-bigint-oct.t b/cpan/bignum/t/auth-bigint-oct.t
deleted file mode 100644
index 06ecffc07c..0000000000
--- a/cpan/bignum/t/auth-bigint-oct.t
+++ /dev/null
@@ -1,49 +0,0 @@
-#!perl
-
-BEGIN {
- unless ($ENV{AUTHOR_TESTING}) {
- require Test::More;
- Test::More::plan(skip_all => 'these tests are for release candidate testing');
- }
-}
-
-use strict;
-use warnings;
-
-use Test::More tests => 507068;
-
-use Algorithm::Combinatorics qw< variations >;
-
-use bigint;
-
-use Test::More;
-
-my $elements = ['0', 'b', 'x', '1', '1', '_', '_', '9', 'z'];
-
-for my $k (0 .. @$elements) {
- my $seen = {};
- for my $variation (variations($elements, $k)) {
- my $str = join "", @$variation;
- next if $seen -> {$str}++;
- print qq|#\n# oct("$str")\n#\n|;
-
- my $i;
- my @warnings;
- local $SIG{__WARN__} = sub {
- my $warning = shift;
- $warning =~ s/ at .*\z//s;
- $warnings[$i] = $warning;
- };
-
- $i = 0;
- my $want_val = CORE::oct("$str");
- my $want_warn = $warnings[$i];
-
- $i = 1;
- my $got_val = bigint::oct("$str");
- my $got_warn = $warnings[$i];
-
- is($got_val, $want_val, qq|hex("$str") (output)|);
- is($got_warn, $want_warn, qq|hex("$str") (warning)|);
- }
-}
diff --git a/cpan/bignum/t/big_e_pi.t b/cpan/bignum/t/big_e_pi.t
index 24f0843c41..06b4b0860a 100644
--- a/cpan/bignum/t/big_e_pi.t
+++ b/cpan/bignum/t/big_e_pi.t
@@ -1,15 +1,17 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
# test for e() and PI() exports
use strict;
+use warnings;
+
use Test::More tests => 4;
use bignum qw/e PI bexp bpi/;
-is (e, "2.718281828459045235360287471352662497757", 'e');
-is (PI, "3.141592653589793238462643383279502884197", 'PI');
+is(e, "2.718281828459045235360287471352662497757", 'e');
+is(PI, "3.141592653589793238462643383279502884197", 'PI');
-is (bexp(1,10), "2.718281828", 'e');
-is (bpi(10), "3.141592654", 'PI');
+is(bexp(1, 10), "2.718281828", 'bexp(1, 10)');
+is(bpi(10), "3.141592654", 'bpi(10)');
diff --git a/cpan/bignum/t/bigexp.t b/cpan/bignum/t/bigexp.t
index d9da12cd95..03355a5946 100644
--- a/cpan/bignum/t/bigexp.t
+++ b/cpan/bignum/t/bigexp.t
@@ -1,18 +1,20 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
# test for bug #18025: bignum/bigrat can lead to a number that is both 1 and 0
use strict;
+use warnings;
+
use Test::More tests => 4;
use bignum;
-my $lnev = -7 / (10**17);
-my $ev=exp($lnev);
+my $ln_ev = -7 / (10 ** 17);
+my $ev = exp($ln_ev);
-is( sprintf('%0.5f',$ev) , '1.00000', '($ev) is approx. 1' );
-is( sprintf('%0.5f',1-$ev) , '0.00000', '(1-$ev) is approx. 0' );
-is( sprintf('%0.5f',1-"$ev") , '0.00000', '(1-"$ev") is approx. 0' );
+is(sprintf('%0.5f', $ev), '1.00000', '($ev) is approx. 1');
+is(sprintf('%0.5f', 1 - $ev), '0.00000', '(1-$ev) is approx. 0');
+is(sprintf('%0.5f', 1 - "$ev"), '0.00000', '(1-"$ev") is approx. 0');
-cmp_ok( $ev, '!=', 0, '$ev should not equal 0');
+cmp_ok($ev, '!=', 0, '$ev should not equal 0');
diff --git a/cpan/bignum/t/bigint.t b/cpan/bignum/t/bigint.t
index e2df70e1bd..4af592f5c1 100644
--- a/cpan/bignum/t/bigint.t
+++ b/cpan/bignum/t/bigint.t
@@ -1,7 +1,10 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
+use strict;
+use warnings;
+
use Test::More tests => 51;
use bigint qw/hex oct/;
@@ -9,7 +12,7 @@ use bigint qw/hex oct/;
###############################################################################
# _constant tests
-foreach (qw/
+foreach (qw/
123:123
123.4:123
1.4:1
@@ -28,75 +31,78 @@ foreach (qw/
1234.567e+4:1234567E1
1234.567e+6:1234567E3
/)
- {
- my ($x,$y) = split /:/;
- print "# Try $x\n";
- is (bigint::_float_constant("$x"),"$y");
- }
+{
+ my ($x, $y) = split /:/;
+ is(bigint::_float_constant("$x"), "$y",
+ qq|bigint::_float_constant("$x") = $y|);
+}
-foreach (qw/
+foreach (qw/
0100:64
0200:128
0x100:256
0b1001:9
/)
- {
- my ($x,$y) = split /:/;
- print "# Try $x\n";
- is (bigint::_binary_constant("$x"),"$y");
- }
+{
+ my ($x, $y) = split /:/;
+ is(bigint::_binary_constant("$x"), "$y",
+ qq|bigint::_binary_constant("$x") = "$y")|);
+}
###############################################################################
# general tests
-my $x = 5; like (ref($x), qr/^Math::BigInt/); # :constant
-
-# todo: is (2 + 2.5,4.5); # should still work
-# todo: $x = 2 + 3.5; is (ref($x),'Math::BigFloat');
+my $x = 5;
+like(ref($x), qr/^Math::BigInt/, '$x = 5 makes $x a Math::BigInt'); # :constant
-$x = 2 ** 255; like (ref($x), qr/^Math::BigInt/);
+# todo: is(2 + 2.5, 4.5); # should still work
+# todo: $x = 2 + 3.5; is(ref($x), 'Math::BigFloat');
-is (12->bfac(),479001600);
-is (9/4,2);
+$x = 2 ** 255;
+like(ref($x), qr/^Math::BigInt/, '$x = 2 ** 255 makes $x a Math::BigInt');
-is (4.5+4.5,8); # truncate
-like (ref(4.5+4.5), qr/^Math::BigInt/);
+is(12->bfac(), 479001600, '12->bfac() = 479001600');
+is(9/4, 2, '9/4 = 2');
+is(4.5 + 4.5, 8, '4.5 + 4.5 = 2'); # truncate
+like(ref(4.5 + 4.5), qr/^Math::BigInt/, '4.5 + 4.5 makes a Math::BigInt');
###############################################################################
# accuracy and precision
-is ('bigint'->accuracy(), undef);
-is ('bigint'->accuracy(12),12);
-is ('bigint'->accuracy(),12);
+is(bigint->accuracy(), undef, 'get accuracy');
+is(bigint->accuracy(12), 12, 'set accuracy to 12');
+is(bigint->accuracy(), 12, 'get accuracy again');
-is ('bigint'->precision(), undef);
-is ('bigint'->precision(12),12);
-is ('bigint'->precision(),12);
+is(bigint->precision(), undef, 'get precision');
+is(bigint->precision(12), 12, 'set precision to 12');
+is(bigint->precision(), 12, 'get precision again');
-is ('bigint'->round_mode(),'even');
-is ('bigint'->round_mode('odd'),'odd');
-is ('bigint'->round_mode(),'odd');
+is(bigint->round_mode(), 'even', 'get round mode');
+is(bigint->round_mode('odd'), 'odd', 'set round mode');
+is(bigint->round_mode(), 'odd', 'get round mode again');
###############################################################################
# hex() and oct()
-my $c = 'Math::BigInt';
-
-is (ref(hex(1)), $c);
-is (ref(hex(0x1)), $c);
-is (ref(hex("af")), $c);
-is (hex("af"), Math::BigInt->new(0xaf));
-is (ref(hex("0x1")), $c);
-
-is (ref(oct("0x1")), $c);
-is (ref(oct("01")), $c);
-is (ref(oct("0b01")), $c);
-is (ref(oct("1")), $c);
-is (ref(oct(" 1")), $c);
-is (ref(oct(" 0x1")), $c);
-
-is (ref(oct(0x1)), $c);
-is (ref(oct(01)), $c);
-is (ref(oct(0b01)), $c);
-is (ref(oct(1)), $c);
+my $class = 'Math::BigInt';
+
+is(ref(hex(1)), $class, qq|ref(hex(1)) = $class|);
+is(ref(hex(0x1)), $class, qq|ref(hex(0x1)) = $class|);
+is(ref(hex("af")), $class, qq|ref(hex("af")) = $class|);
+is(ref(hex("0x1")), $class, qq|ref(hex("0x1")) = $class|);
+
+is(hex("af"), Math::BigInt->new(0xaf),
+ qq|hex("af") = Math::BigInt->new(0xaf)|);
+
+is(ref(oct("0x1")), $class, qq|ref(oct("0x1")) = $class|);
+is(ref(oct("01")), $class, qq|ref(oct("01")) = $class|);
+is(ref(oct("0b01")), $class, qq|ref(oct("0b01")) = $class|);
+is(ref(oct("1")), $class, qq|ref(oct("1")) = $class|);
+is(ref(oct(" 1")), $class, qq|ref(oct(" 1")) = $class|);
+is(ref(oct(" 0x1")), $class, qq|ref(oct(" 0x1")) = $class|);
+
+is(ref(oct(0x1)), $class, qq|ref(oct(0x1)) = $class|);
+is(ref(oct(01)), $class, qq|ref(oct(01)) = $class|);
+is(ref(oct(0b01)), $class, qq|ref(oct(0b01)) = $class|);
+is(ref(oct(1)), $class, qq|ref(oct(1)) = $class|);
diff --git a/cpan/bignum/t/bignum.t b/cpan/bignum/t/bignum.t
index 562564d327..6bdd5bb29b 100644
--- a/cpan/bignum/t/bignum.t
+++ b/cpan/bignum/t/bignum.t
@@ -10,65 +10,74 @@ use bignum qw/oct hex/;
###############################################################################
# general tests
-my $x = 5; like (ref($x), qr/^Math::BigInt/); # :constant
+my $x = 5;
+like(ref($x), qr/^Math::BigInt/, '$x = 5 makes $x a Math::BigInt'); # :constant
-is (2 + 2.5,4.5);
-$x = 2 + 3.5; is (ref($x),'Math::BigFloat');
-is (2 * 2.1,4.2);
-$x = 2 + 2.1; is (ref($x),'Math::BigFloat');
+is(2 + 2.5, 4.5, '2 + 2.5 = 4.5');
+$x = 2 + 3.5;
+is(ref($x), 'Math::BigFloat', '$x = 2 + 3.5 makes $x a Math::BigFloat');
-$x = 2 ** 255; like (ref($x), qr/^Math::BigInt/);
+is(2 * 2.1, 4.2, '2 * 2.1 = 4.2');
+$x = 2 + 2.1;
+is(ref($x), 'Math::BigFloat', '$x = 2 + 2.1 makes $x a Math::BigFloat');
+
+$x = 2 ** 255;
+like(ref($x), qr/^Math::BigInt/, '$x = 2 ** 255 makes $x a Math::BigInt');
# see if Math::BigInt constant and upgrading works
-is (Math::BigInt::bsqrt('12'),'3.464101615137754587054892683011744733886');
-is (sqrt(12),'3.464101615137754587054892683011744733886');
+is(Math::BigInt::bsqrt("12"), '3.464101615137754587054892683011744733886',
+ 'Math::BigInt::bsqrt("12")');
+is(sqrt(12), '3.464101615137754587054892683011744733886',
+ 'sqrt(12)');
-is (2/3,"0.6666666666666666666666666666666666666667");
+is(2/3, "0.6666666666666666666666666666666666666667", '2/3');
-#is (2 ** 0.5, 'NaN'); # should be sqrt(2);
+#is(2 ** 0.5, 'NaN'); # should be sqrt(2);
-is (12->bfac(),479001600);
+is(12->bfac(), 479001600, '12->bfac() = 479001600');
# see if Math::BigFloat constant works
-# 0123456789 0123456789 <- default 40
+# 0123456789 0123456789 <- default 40
# 0123456789 0123456789
-is (1/3, '0.3333333333333333333333333333333333333333');
+is(1/3, '0.3333333333333333333333333333333333333333', '1/3');
###############################################################################
# accuracy and precision
-is (bignum->accuracy(), undef);
-is (bignum->accuracy(12),12);
-is (bignum->accuracy(),12);
+is(bignum->accuracy(), undef, 'get accuracy');
+is(bignum->accuracy(12), 12, 'set accuracy to 12');
+is(bignum->accuracy(), 12, 'get accuracy again');
-is (bignum->precision(), undef);
-is (bignum->precision(12),12);
-is (bignum->precision(),12);
+is(bignum->precision(), undef, 'get precision');
+is(bignum->precision(12), 12, 'set precision to 12');
+is(bignum->precision(), 12, 'get precision again');
-is (bignum->round_mode(),'even');
-is (bignum->round_mode('odd'),'odd');
-is (bignum->round_mode(),'odd');
+is(bignum->round_mode(), 'even', 'get round mode');
+is(bignum->round_mode('odd'), 'odd', 'set round mode');
+is(bignum->round_mode(), 'odd', 'get round mode again');
###############################################################################
# hex() and oct()
-my $c = 'Math::BigInt';
-
-is (ref(hex(1)), $c);
-is (ref(hex(0x1)), $c);
-is (ref(hex("af")), $c);
-is (hex("af"), Math::BigInt->new(0xaf));
-is (ref(hex("0x1")), $c);
-
-is (ref(oct("0x1")), $c);
-is (ref(oct("01")), $c);
-is (ref(oct("0b01")), $c);
-is (ref(oct("1")), $c);
-is (ref(oct(" 1")), $c);
-is (ref(oct(" 0x1")), $c);
-
-is (ref(oct(0x1)), $c);
-is (ref(oct(01)), $c);
-is (ref(oct(0b01)), $c);
-is (ref(oct(1)), $c);
+my $class = 'Math::BigInt';
+
+is(ref(hex(1)), $class, qq|ref(hex(1)) = $class|);
+is(ref(hex(0x1)), $class, qq|ref(hex(0x1)) = $class|);
+is(ref(hex("af")), $class, qq|ref(hex("af")) = $class|);
+is(ref(hex("0x1")), $class, qq|ref(hex("0x1")) = $class|);
+
+is(hex("af"), Math::BigInt->new(0xaf),
+ qq|hex("af") = Math::BigInt->new(0xaf)|);
+
+is(ref(oct("0x1")), $class, qq|ref(oct("0x1")) = $class|);
+is(ref(oct("01")), $class, qq|ref(oct("01")) = $class|);
+is(ref(oct("0b01")), $class, qq|ref(oct("0b01")) = $class|);
+is(ref(oct("1")), $class, qq|ref(oct("1")) = $class|);
+is(ref(oct(" 1")), $class, qq|ref(oct(" 1")) = $class|);
+is(ref(oct(" 0x1")), $class, qq|ref(oct(" 0x1")) = $class|);
+
+is(ref(oct(0x1)), $class, qq|ref(oct(0x1)) = $class|);
+is(ref(oct(01)), $class, qq|ref(oct(01)) = $class|);
+is(ref(oct(0b01)), $class, qq|ref(oct(0b01)) = $class|);
+is(ref(oct(1)), $class, qq|ref(oct(1)) = $class|);
diff --git a/cpan/bignum/t/bigrat.t b/cpan/bignum/t/bigrat.t
index 7f40d62b09..ac6fc0c6db 100644
--- a/cpan/bignum/t/bigrat.t
+++ b/cpan/bignum/t/bigrat.t
@@ -1,8 +1,10 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
use strict;
+use warnings;
+
use Test::More tests => 40;
use bigrat qw/oct hex/;
@@ -10,69 +12,73 @@ use bigrat qw/oct hex/;
###############################################################################
# general tests
-my $x = 5; like (ref($x), qr/^Math::BigInt/); # :constant
+my $x = 5;
+like(ref($x), qr/^Math::BigInt/, '$x = 5 makes $x a Math::BigInt'); # :constant
-# todo: is (2 + 2.5,4.5); # should still work
-# todo: $x = 2 + 3.5; is (ref($x),'Math::BigFloat');
+# todo: is(2 + 2.5, 4.5); # should still work
+# todo: $x = 2 + 3.5; is(ref($x), 'Math::BigFloat');
-$x = 2 ** 255; like (ref($x), qr/^Math::BigInt/);
+$x = 2 ** 255;
+like(ref($x), qr/^Math::BigInt/, '$x = 2 ** 255 makes $x a Math::BigInt');
# see if Math::BigRat constant works
-is (1/3, '1/3');
-is (1/4+1/3,'7/12');
-is (5/7+3/7,'8/7');
+is(1/3, '1/3', qq|1/3 = '1/3'|);
+is(1/4+1/3, '7/12', qq|1/4+1/3 = '7/12'|);
+is(5/7+3/7, '8/7', qq|5/7+3/7 = '8/7'|);
-is (3/7+1,'10/7');
-is (3/7+1.1,'107/70');
-is (3/7+3/7,'6/7');
+is(3/7+1, '10/7', qq|3/7+1 = '10/7'|);
+is(3/7+1.1, '107/70', qq|3/7+1.1 = '107/70'|);
+is(3/7+3/7, '6/7', qq|3/7+3/7 = '6/7'|);
-is (3/7-1,'-4/7');
-is (3/7-1.1,'-47/70');
-is (3/7-2/7,'1/7');
+is(3/7-1, '-4/7', qq|3/7-1 = '-4/7'|);
+is(3/7-1.1, '-47/70', qq|3/7-1.1 = '-47/70'|);
+is(3/7-2/7, '1/7', qq|3/7-2/7 = '1/7'|);
# fails ?
-# is (1+3/7,'10/7');
+# is(1+3/7, '10/7', qq|1+3/7 = '10/7'|);
-is (1.1+3/7,'107/70');
-is (3/7*5/7,'15/49');
-is (3/7 / (5/7),'3/5');
-is (3/7 / 1,'3/7');
-is (3/7 / 1.5,'2/7');
+is(1.1+3/7, '107/70', qq|1.1+3/7 = '107/70'|);
+is(3/7*5/7, '15/49', qq|3/7*5/7 = '15/49'|);
+is(3/7 / (5/7), '3/5', qq|3/7 / (5/7) = '3/5'|);
+is(3/7 / 1, '3/7', qq|3/7 / 1 = '3/7'|);
+is(3/7 / 1.5, '2/7', qq|3/7 / 1.5 = '2/7'|);
###############################################################################
# accuracy and precision
-is (bigrat->accuracy(), undef);
-is (bigrat->accuracy(12),12);
-is (bigrat->accuracy(),12);
+is(bigrat->accuracy(), undef, 'get accuracy');
+is(bigrat->accuracy(12), 12, 'set accuracy to 12');
+is(bigrat->accuracy(), 12, 'get accuracy again');
-is (bigrat->precision(), undef);
-is (bigrat->precision(12),12);
-is (bigrat->precision(),12);
+is(bigrat->precision(), undef, 'get precision');
+is(bigrat->precision(12), 12, 'set precision to 12');
+is(bigrat->precision(), 12, 'get precision again');
-is (bigrat->round_mode(),'even');
-is (bigrat->round_mode('odd'),'odd');
-is (bigrat->round_mode(),'odd');
+is(bigrat->round_mode(), 'even', 'get round mode');
+is(bigrat->round_mode('odd'), 'odd', 'set round mode');
+is(bigrat->round_mode(), 'odd', 'get round mode again');
###############################################################################
# hex() and oct()
-my $c = 'Math::BigInt';
-
-is (ref(hex(1)), $c);
-is (ref(hex(0x1)), $c);
-is (ref(hex("af")), $c);
-is (hex("af"), Math::BigInt->new(0xaf));
-is (ref(hex("0x1")), $c);
-
-is (ref(oct("0x1")), $c);
-is (ref(oct("01")), $c);
-is (ref(oct("0b01")), $c);
-is (ref(oct("1")), $c);
-is (ref(oct(" 1")), $c);
-is (ref(oct(" 0x1")), $c);
-
-is (ref(oct(0x1)), $c);
-is (ref(oct(01)), $c);
-is (ref(oct(0b01)), $c);
-is (ref(oct(1)), $c);
+my $class = 'Math::BigInt';
+
+is(ref(hex(1)), $class, qq|ref(hex(1)) = $class|);
+is(ref(hex(0x1)), $class, qq|ref(hex(0x1)) = $class|);
+is(ref(hex("af")), $class, qq|ref(hex("af")) = $class|);
+is(ref(hex("0x1")), $class, qq|ref(hex("0x1")) = $class|);
+
+is(hex("af"), Math::BigInt->new(0xaf),
+ qq|hex("af") = Math::BigInt->new(0xaf)|);
+
+is(ref(oct("0x1")), $class, qq|ref(oct("0x1")) = $class|);
+is(ref(oct("01")), $class, qq|ref(oct("01")) = $class|);
+is(ref(oct("0b01")), $class, qq|ref(oct("0b01")) = $class|);
+is(ref(oct("1")), $class, qq|ref(oct("1")) = $class|);
+is(ref(oct(" 1")), $class, qq|ref(oct(" 1")) = $class|);
+is(ref(oct(" 0x1")), $class, qq|ref(oct(" 0x1")) = $class|);
+
+is(ref(oct(0x1)), $class, qq|ref(oct(0x1)) = $class|);
+is(ref(oct(01)), $class, qq|ref(oct(01)) = $class|);
+is(ref(oct(0b01)), $class, qq|ref(oct(0b01)) = $class|);
+is(ref(oct(1)), $class, qq|ref(oct(1)) = $class|);
diff --git a/cpan/bignum/t/bii_e_pi.t b/cpan/bignum/t/bii_e_pi.t
index b47b4a8d61..d9e20b5641 100644
--- a/cpan/bignum/t/bii_e_pi.t
+++ b/cpan/bignum/t/bii_e_pi.t
@@ -1,16 +1,18 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
# test for e() and PI() exports
use strict;
+use warnings;
+
use Test::More tests => 5;
use bigint qw/e PI bpi bexp/;
-is (e, "2", 'e');
-is (PI, "3", 'PI');
+is(e, "2", 'e');
+is(PI, "3", 'PI');
-is (bexp(1,10), "2", 'e');
-is (bexp(3,10), "20", 'e');
-is (bpi(10), "3", 'PI');
+is(bexp(1, 10), "2", 'e');
+is(bexp(3, 10), "20", 'e');
+is(bpi(10), "3", 'PI');
diff --git a/cpan/bignum/t/biinfnan.t b/cpan/bignum/t/biinfnan.t
index bb9f41f614..c3349173fc 100644
--- a/cpan/bignum/t/biinfnan.t
+++ b/cpan/bignum/t/biinfnan.t
@@ -1,11 +1,22 @@
-#!/usr/bin/perl -w
-
-###############################################################################
+#!perl
use strict;
-use Test::More tests => 26;
+use warnings;
+
+use Test::More tests => 66;
use bigint;
-require "t/infnan.inc";
+#require "t/infnan.inc";
+
+# The 'bigint'/'bignum'/'bigrat' pragma is lexical, so we can't 'require' or
+# 'do' the included file. Slurp the whole thing and 'eval' it.
+
+my $file = "t/infnan.inc";
+
+open FILE, $file or die "$file: can't open file for reading: $!";
+my $data = do { local $/; <FILE> };
+close FILE or die "$file: can't close file after reading: $!";
+eval $data;
+die $@ if $@;
diff --git a/cpan/bignum/t/bir_e_pi.t b/cpan/bignum/t/bir_e_pi.t
index f8b347be0c..8305580b04 100644
--- a/cpan/bignum/t/bir_e_pi.t
+++ b/cpan/bignum/t/bir_e_pi.t
@@ -1,17 +1,20 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
# test for e() and PI() exports
use strict;
+use warnings;
+
use Test::More tests => 4;
use bigrat qw/e PI bexp bpi/;
-is (e, "2.718281828459045235360287471352662497757", 'e');
-is (PI, "3.141592653589793238462643383279502884197", 'PI');
+is(e, "2.718281828459045235360287471352662497757", 'e');
+is(PI, "3.141592653589793238462643383279502884197", 'PI');
+
+# These tests should actually produce big rationals, but this is not yet
+# implemented.
-# these tests should actually produce big rationals, but this is not yet
-# implemented:
-is (bexp(1,10), "2.718281828", 'e');
-is (bpi(10), "3.141592654", 'PI');
+is(bexp(1, 10), "2.718281828", 'bexp(1, 10)');
+is(bpi(10), "3.141592654", 'bpi(10)');
diff --git a/cpan/bignum/t/bn_lite.t b/cpan/bignum/t/bn_lite.t
index c2a04cd7d4..d26fe5ceb7 100644
--- a/cpan/bignum/t/bn_lite.t
+++ b/cpan/bignum/t/bn_lite.t
@@ -1,21 +1,20 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
use strict;
-use Test::More;
+use warnings;
-if (eval { require Math::BigInt::Lite; 1 })
- {
- plan (tests => 1);
- # can use Lite, so let bignum try it
- require bignum; bignum->import();
- # can't get to work a ref(1+1) here, presumable because :constant phase
- # already done
- is ($bignum::_lite,1);
- }
-else
- {
- plan skip_all => "no Math::BigInt::Lite";
- }
+use Test::More;
+if (eval { require Math::BigInt::Lite; 1 }) {
+ plan tests => 1;
+ # can use Lite, so let bignum try it
+ require bignum;
+ bignum->import();
+ # can't get to work a ref(1+1) here, presumable because :constant phase
+ # already done
+ is($bignum::_lite, 1, '$bignum::_lite is 1');
+} else {
+ plan skip_all => "no Math::BigInt::Lite";
+}
diff --git a/cpan/bignum/t/bninfnan.t b/cpan/bignum/t/bninfnan.t
index 45f83b98f8..e437ca116b 100644
--- a/cpan/bignum/t/bninfnan.t
+++ b/cpan/bignum/t/bninfnan.t
@@ -1,11 +1,22 @@
-#!/usr/bin/perl -w
-
-###############################################################################
+#!perl
use strict;
-use Test::More tests => 26;
+use warnings;
+
+use Test::More tests => 66;
use bignum;
-require "t/infnan.inc";
+#require "t/infnan.inc";
+
+# The 'bigint'/'bignum'/'bigrat' pragma is lexical, so we can't 'require' or
+# 'do' the included file. Slurp the whole thing and 'eval' it.
+
+my $file = "t/infnan.inc";
+
+open FILE, $file or die "$file: can't open file for reading: $!";
+my $data = do { local $/; <FILE> };
+close FILE or die "$file: can't close file after reading: $!";
+eval $data;
+die $@ if $@;
diff --git a/cpan/bignum/t/br_lite.t b/cpan/bignum/t/br_lite.t
index 4e75356bc2..79ac2c655c 100644
--- a/cpan/bignum/t/br_lite.t
+++ b/cpan/bignum/t/br_lite.t
@@ -1,21 +1,20 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
use strict;
-use Test::More;
+use warnings;
-if (eval { require Math::BigInt::Lite; 1 })
- {
- plan (tests => 1);
- # can use Lite, so let bignum try it
- require bigrat; bigrat->import();
- # can't get to work a ref(1+1) here, presumable because :constant phase
- # already done
- is ($bigrat::_lite,1);
- }
-else
- {
- plan (skip_all => "no Math::BigInt::Lite");
- }
+use Test::More;
+if (eval { require Math::BigInt::Lite; 1 }) {
+ plan tests => 1;
+ # can use Lite, so let bignum try it
+ require bigrat;
+ bigrat->import();
+ # can't get to work a ref(1+1) here, presumable because :constant phase
+ # already done
+ is($bigrat::_lite, 1, '$bigrat::_lite is 1');
+} else {
+ plan skip_all => "no Math::BigInt::Lite";
+}
diff --git a/cpan/bignum/t/brinfnan.t b/cpan/bignum/t/brinfnan.t
index ce7daa189d..1be81649ef 100644
--- a/cpan/bignum/t/brinfnan.t
+++ b/cpan/bignum/t/brinfnan.t
@@ -1,11 +1,22 @@
-#!/usr/bin/perl -w
-
-###############################################################################
+#!perl
use strict;
-use Test::More tests => 26;
+use warnings;
+
+use Test::More tests => 66;
use bigrat;
-require "t/infnan.inc";
+#require "t/infnan.inc";
+
+# The 'bigint'/'bignum'/'bigrat' pragma is lexical, so we can't 'require' or
+# 'do' the included file. Slurp the whole thing and 'eval' it.
+
+my $file = "t/infnan.inc";
+
+open FILE, $file or die "$file: can't open file for reading: $!";
+my $data = do { local $/; <FILE> };
+close FILE or die "$file: can't close file after reading: $!";
+eval $data;
+die $@ if $@;
diff --git a/cpan/bignum/t/in_effect.t b/cpan/bignum/t/in_effect.t
index 5d09fc172f..b4507ea54a 100644
--- a/cpan/bignum/t/in_effect.t
+++ b/cpan/bignum/t/in_effect.t
@@ -1,34 +1,35 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
# Test in_effect()
use strict;
+use warnings;
+
use Test::More tests => 9;
use bigint;
use bignum;
use bigrat;
-can_ok ('bigint', qw/in_effect/);
-can_ok ('bignum', qw/in_effect/);
-can_ok ('bigrat', qw/in_effect/);
+can_ok('bigint', qw/in_effect/);
+can_ok('bignum', qw/in_effect/);
+can_ok('bigrat', qw/in_effect/);
SKIP: {
- skip ('Need at least Perl v5.9.4', 3) if $] < "5.009005";
+ skip('Need at least Perl v5.9.4', 3) if $] < "5.009005";
- is (bigint::in_effect(), 1, 'bigint in effect');
- is (bignum::in_effect(), 1, 'bignum in effect');
- is (bigrat::in_effect(), 1, 'bigrat in effect');
- }
+ is(bigint::in_effect(), 1, 'bigint in effect');
+ is(bignum::in_effect(), 1, 'bignum in effect');
+ is(bigrat::in_effect(), 1, 'bigrat in effect');
+}
{
- no bigint;
- no bignum;
- no bigrat;
+ no bigint;
+ no bignum;
+ no bigrat;
- is (bigint::in_effect(), undef, 'bigint not in effect');
- is (bignum::in_effect(), undef, 'bignum not in effect');
- is (bigrat::in_effect(), undef, 'bigrat not in effect');
+ is(bigint::in_effect(), undef, 'bigint not in effect');
+ is(bignum::in_effect(), undef, 'bignum not in effect');
+ is(bigrat::in_effect(), undef, 'bigrat not in effect');
}
-
diff --git a/cpan/bignum/t/infnan.inc b/cpan/bignum/t/infnan.inc
index 561adc1a70..695b9135dd 100644
--- a/cpan/bignum/t/infnan.inc
+++ b/cpan/bignum/t/infnan.inc
@@ -1,35 +1,92 @@
+#!perl
use strict;
+use warnings;
-my ($x);
+my $x;
###############################################################################
# inf tests
-$x = 1+inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'inf');
-$x = 1*inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'inf');
+$x = 1 + inf;
+like(ref($x), qr/^Math::BigInt/, '$x = 1 + inf makes a Math::BigInt');
+is($x->bstr(), 'inf', qq|$x = 1 + inf; $x->bstr() = 'inf'|);
+
+$x = 1 * inf;
+like(ref($x), qr/^Math::BigInt/, '$x = 1 * inf makes a Math::BigInt');
+is($x->bstr(), 'inf', qq|$x = 1 * inf; $x->bstr() = 'inf'|);
# these don't work without exporting inf()
-$x = inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'inf');
-$x = inf+inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'inf');
-$x = inf*inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'inf');
+$x = inf;
+like(ref($x), qr/^Math::BigInt/, '$x = inf makes a Math::BigInt');
+is($x->bstr(), 'inf', qq|$x = inf; $x->bstr() = 'inf'|);
+
+$x = inf + inf;
+like(ref($x), qr/^Math::BigInt/, '$x = inf + inf makes a Math::BigInt');
+is($x->bstr(), 'inf', qq|$x = inf + inf; $x->bstr() = 'inf'|);
+
+$x = inf * inf;
+like(ref($x), qr/^Math::BigInt/, '$x = inf * inf makes a Math::BigInt');
+is($x->bstr(), 'inf', qq|$x = inf * inf; $x->bstr() = 'inf'|);
###############################################################################
# NaN tests
-$x = 1+NaN; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
-$x = 1*NaN; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
+$x = 1 + NaN;
+like(ref($x), qr/^Math::BigInt/, '$x = 1 + NaN makes a Math::BigInt');
+is($x->bstr(), 'NaN', qq|$x = 1 + NaN; $x->bstr() = 'NaN'|);
+
+$x = 1 * NaN;
+like(ref($x), qr/^Math::BigInt/, '$x = 1 * NaN makes a Math::BigInt');
+is($x->bstr(), 'NaN', qq|$x = 1 * NaN; $x->bstr() = 'NaN'|);
# these don't work without exporting NaN()
-$x = NaN; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
-$x = NaN+NaN; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
-$x = NaN*NaN; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
+$x = NaN;
+like(ref($x), qr/^Math::BigInt/, '$x = NaN makes a Math::BigInt');
+is($x->bstr(), 'NaN', qq|$x = NaN; $x->bstr() = 'NaN'|);
+
+$x = NaN + NaN;
+like(ref($x), qr/^Math::BigInt/, '$x = NaN + NaN makes a Math::BigInt');
+is($x->bstr(), 'NaN', qq|$x = NaN + NaN; $x->bstr() = 'NaN'|);
+
+$x = NaN * NaN;
+like(ref($x), qr/^Math::BigInt/, '$x = NaN * NaN makes a Math::BigInt');
+is($x->bstr(), 'NaN', qq|$x = NaN * NaN; $x->bstr() = 'NaN'|);
###############################################################################
# mixed tests
# these don't work without exporting NaN() or inf()
-$x = NaN+inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
-$x = NaN*inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
-$x = inf*NaN; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
+$x = NaN + inf;
+like(ref($x), qr/^Math::BigInt/, '$x = NaN + inf makes a Math::BigInt');
+is($x->bstr(), 'NaN', qq|$x = NaN + inf; $x->bstr() = 'NaN'|);
+
+$x = NaN * inf;
+like(ref($x), qr/^Math::BigInt/, '$x = NaN * inf makes a Math::BigInt');
+is($x->bstr(), 'NaN', qq|$x = NaN * inf; $x->bstr() = 'NaN'|);
+
+$x = inf * NaN;
+like(ref($x), qr/^Math::BigInt/, '$x = inf * NaN makes a Math::BigInt');
+is($x->bstr(), 'NaN', qq|$x = inf * NaN; $x->bstr() = 'NaN'|);
+
+###############################################################################
+# inf and NaN as strings.
+
+for my $nan (qw/ nan naN nAn nAN Nan NaN NAn NAN /) {
+ my $x = 1 + $nan;
+ print ref($x), "<<<\n";
+ is($x->bstr(), "NaN", qq|\$x = 1 + "$nan"; \$x->bstr() = "NaN"|);
+ isa_ok($x, "Math::BigInt");
+}
+
+for my $inf (qw/ inf inF iNf iNF Inf InF INf INF
+ infinity Infinity InFiNiTy iNfInItY
+ /)
+{
+ my $x = 1 + $inf;
+ is($x->bstr(), "inf", qq|\$x = 1 + "$inf"; \$x->bstr() = "inf"|);
+ isa_ok($x, "Math::BigInt");
+}
+
+1;
diff --git a/cpan/bignum/t/option_a.t b/cpan/bignum/t/option_a.t
index 1f135626cc..2a9d17154d 100644
--- a/cpan/bignum/t/option_a.t
+++ b/cpan/bignum/t/option_a.t
@@ -1,23 +1,22 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
use strict;
+use warnings;
+
use Test::More tests => 4;
use bignum a => '12';
-my @C = qw/Math::BigInt Math::BigFloat/;
-
-foreach my $c (@C)
- {
- is ($c->accuracy(),12, "$c accuracy = 12");
- }
+my @CLASSES = qw/Math::BigInt Math::BigFloat/;
-bignum->import( accuracy => '23');
+foreach my $class (@CLASSES) {
+ is($class->accuracy(),12, "$class accuracy = 12");
+}
-foreach my $c (@C)
- {
- is ($c->accuracy(), 23, "$c accuracy = 23");
- }
+bignum->import(accuracy => '23');
+foreach my $class (@CLASSES) {
+ is($class->accuracy(), 23, "$class accuracy = 23");
+}
diff --git a/cpan/bignum/t/option_l.t b/cpan/bignum/t/option_l.t
index b5eddec154..4744ded165 100644
--- a/cpan/bignum/t/option_l.t
+++ b/cpan/bignum/t/option_l.t
@@ -1,46 +1,53 @@
-#!/usr/bin/perl -w
+#!perl
# test the "l", "lib", "try" and "only" options:
use strict;
+use warnings;
+
use Test::More tests => 19;
use bignum;
-my @W;
+my @WARNINGS;
{
-# catch warnings:
-require Carp;
-no warnings 'redefine';
-*Carp::carp = sub { push @W, $_[0]; };
+ # catch warnings:
+ require Carp;
+ no warnings 'redefine';
+ *Carp::carp = sub { push @WARNINGS, $_[0]; };
}
-my $rc = eval { bignum->import( "l" => "foo" ) };
-is ($@,''); # shouldn't die
-is (scalar @W, 1, 'one warning');
-like ($W[0], qr/fallback to Math::/, 'got fallback');
+my $rc;
+
+$rc = eval { bignum->import( "l" => "foo" ) };
+is($@, '', # shouldn't die
+ qq|eval { bignum->import( "l" => "foo" ) }|);
+is(scalar(@WARNINGS), 1, 'one warning');
+like($WARNINGS[0], qr/fallback to Math::/, 'got fallback');
$rc = eval { bignum->import( "lib" => "foo" ) };
-is ($@,''); # ditto
-is (scalar @W, 2, 'two warnings');
-like ($W[1], qr/fallback to Math::/, 'got fallback');
+is($@, '', # ditto
+ qq|eval { bignum->import( "lib" => "foo" ) }|);
+is(scalar @WARNINGS, 2, 'two warnings');
+like($WARNINGS[1], qr/fallback to Math::/, 'got fallback');
$rc = eval { bignum->import( "try" => "foo" ) };
-is ($@,''); # shouldn't die
+is($@, '', # shouldn't die
+ qq|eval { bignum->import( "try" => "foo" ) }|);
+
$rc = eval { bignum->import( "try" => "foo" ) };
-is ($@,''); # ditto
+is($@, '', # ditto
+ qq|eval { bignum->import( "try" => "foo" ) }|);
$rc = eval { bignum->import( "foo" => "bar" ) };
-like ($@, qr/^Unknown option foo/i, 'died'); # should die
+like($@, qr/^Unknown option foo/i, 'died'); # should die
$rc = eval { bignum->import( "only" => "bar" ) };
-like ($@, qr/fallback disallowed/i, 'died'); # should die
+like($@, qr/fallback disallowed/i, 'died'); # should die
# test that options are only lowercase (don't see a reason why allow UPPER)
-foreach (qw/L LIB Lib T Trace TRACE V Version VERSION/)
- {
- $rc = eval { bignum->import( $_ => "bar" ) };
- like ($@, qr/^Unknown option $_/i, 'died'); # should die
- }
-
+foreach (qw/L LIB Lib T Trace TRACE V Version VERSION/) {
+ $rc = eval { bignum->import( $_ => "bar" ) };
+ like($@, qr/^Unknown option $_/i, 'died'); # should die
+}
diff --git a/cpan/bignum/t/option_p.t b/cpan/bignum/t/option_p.t
index cdc4f4311b..6f57c92c81 100644
--- a/cpan/bignum/t/option_p.t
+++ b/cpan/bignum/t/option_p.t
@@ -1,21 +1,20 @@
-#!/usr/bin/perl -w
+#!perl
use strict;
+use warnings;
+
use Test::More tests => 4;
-my @C = qw/Math::BigInt Math::BigFloat/;
+my @CLASSES = qw/Math::BigInt Math::BigFloat/;
use bignum p => '12';
-foreach my $c (@C)
- {
- is ($c->precision(),12, "$c precision = 12");
- }
-
-bignum->import( p => '42' );
+foreach my $class (@CLASSES) {
+ is($class->precision(), 12, "$class precision = 12");
+}
-foreach my $c (@C)
- {
- is ($c->precision(),42, "$c precision = 42");
- }
+bignum->import(p => '42');
+foreach my $class (@CLASSES) {
+ is($class->precision(), 42, "$class precision = 42");
+}
diff --git a/cpan/bignum/t/overrides.t b/cpan/bignum/t/overrides.t
index 84a2ce1924..371d91d667 100644
--- a/cpan/bignum/t/overrides.t
+++ b/cpan/bignum/t/overrides.t
@@ -1,75 +1,77 @@
-#!perl -w
+#!perl
+
+use strict;
+use warnings;
# Test behaviour of hex and oct overrides in detail, and also how the three
# modules interact.
use Test::More tests => 35;
+my $hex_called;
+my $oct_called;
+
# For testing that existing CORE::GLOBAL overrides are not clobbered
-BEGIN
- {
- if ($] > 5.009004)
- {
- no warnings 'syntax';
- *CORE::GLOBAL::hex = sub(_) { ++$hex_called; CORE::hex(@_?$_[0]:$_) };
- *CORE::GLOBAL::oct = sub(_) { ++$oct_called; CORE::oct(@_?$_[0]:$_) };
- }
- else
- {
- *CORE::GLOBAL::hex = sub(;$) { ++$hex_called; CORE::hex(@_?$_[0]:$_) };
- *CORE::GLOBAL::oct = sub(;$) { ++$oct_called; CORE::oct(@_?$_[0]:$_) };
+BEGIN {
+ if ($] > 5.009004) {
+ no warnings 'syntax';
+ *CORE::GLOBAL::hex = sub(_) { ++$hex_called; CORE::hex(@_?$_[0]:$_) };
+ *CORE::GLOBAL::oct = sub(_) { ++$oct_called; CORE::oct(@_?$_[0]:$_) };
+ } else {
+ *CORE::GLOBAL::hex = sub(;$) { ++$hex_called; CORE::hex(@_?$_[0]:$_) };
+ *CORE::GLOBAL::oct = sub(;$) { ++$oct_called; CORE::oct(@_?$_[0]:$_) };
}
- }
+}
{
- use bigint;
- $_ = "20";
- is hex, "32", 'bigint hex override without arguments infers $_';
- is oct, "16", 'bigint oct override without arguments infers $_';
- @_ = 1..20;
- is hex(@_), "32", 'bigint hex override provides scalar context';
- is oct(@_), "16", 'bigint oct override provides scalar context';
+ use bigint;
+ $_ = "20";
+ is hex, "32", 'bigint hex override without arguments infers $_';
+ is oct, "16", 'bigint oct override without arguments infers $_';
+ @_ = 1..20;
+ is hex(@_), "32", 'bigint hex override provides scalar context';
+ is oct(@_), "16", 'bigint oct override provides scalar context';
SKIP:
{
- skip "no lexical hex/oct", 2 unless $] > do { no bigint; 5.009004};
- is ref hex(1), 'Math::BigInt',
- 'bigint hex() works when bignum and bigrat are loaded';
- is ref oct(1), 'Math::BigInt',
- 'bigint oct() works when bignum and bigrat are loaded';
+ skip "no lexical hex/oct", 2 unless $] > do { no bigint; 5.009004 };
+ is ref hex(1), 'Math::BigInt',
+ 'bigint hex() works when bignum and bigrat are loaded';
+ is ref oct(1), 'Math::BigInt',
+ 'bigint oct() works when bignum and bigrat are loaded';
}
}
{
- use bignum;
- $_ = "20";
- is hex, "32", 'bignum hex override without arguments infers $_';
- is oct, "16", 'bignum oct override without arguments infers $_';
- @_ = 1..20;
- is hex(@_), "32", 'bignum hex override provides scalar context';
- is oct(@_), "16", 'bignum oct override provides scalar context';
+ use bignum;
+ $_ = "20";
+ is hex, "32", 'bignum hex override without arguments infers $_';
+ is oct, "16", 'bignum oct override without arguments infers $_';
+ @_ = 1..20;
+ is hex(@_), "32", 'bignum hex override provides scalar context';
+ is oct(@_), "16", 'bignum oct override provides scalar context';
SKIP:
{
- skip "no lexical hex/oct", 2 unless $] > 5.009004;
- is ref hex(1), 'Math::BigInt',
- 'bignum hex() works when bigint and bigrat are loaded';
- is ref oct(1), 'Math::BigInt',
- 'bignum oct() works when bigint and bigrat are loaded';
+ skip "no lexical hex/oct", 2 unless $] > 5.009004;
+ is ref hex(1), 'Math::BigInt',
+ 'bignum hex() works when bigint and bigrat are loaded';
+ is ref oct(1), 'Math::BigInt',
+ 'bignum oct() works when bigint and bigrat are loaded';
}
}
{
- use bigrat;
- $_ = "20";
- is hex, "32", 'bigrat hex override without arguments infers $_';
- is oct, "16", 'bigrat oct override without arguments infers $_';
- @_ = 1..20;
- is hex(@_), "32", 'bigrat hex override provides scalar context';
- is oct(@_), "16", 'bigrat oct override provides scalar context';
+ use bigrat;
+ $_ = "20";
+ is hex, "32", 'bigrat hex override without arguments infers $_';
+ is oct, "16", 'bigrat oct override without arguments infers $_';
+ @_ = 1..20;
+ is hex(@_), "32", 'bigrat hex override provides scalar context';
+ is oct(@_), "16", 'bigrat oct override provides scalar context';
SKIP:
{
- skip "no lexical hex/oct", 2 unless $] > 5.009004;
- is ref hex(1), 'Math::BigInt',
- 'bigrat hex() works when bignum and bigint are loaded';
- is ref oct(1), 'Math::BigInt',
- 'bigrat oct() works when bignum and bigint are loaded';
+ skip "no lexical hex/oct", 2 unless $] > 5.009004;
+ is ref hex(1), 'Math::BigInt',
+ 'bigrat hex() works when bignum and bigint are loaded';
+ is ref oct(1), 'Math::BigInt',
+ 'bigrat oct() works when bignum and bigint are loaded';
}
}
@@ -81,32 +83,32 @@ $oct_called = 0;
is $oct_called, 1, 'existing oct overrides are called';
{
- package _importer;
- {
- use bigint 'hex', 'oct';
- ::is \&hex, \&bigint::hex, 'exported hex function';
- ::is \&oct, \&bigint::oct, 'exported oct function';
- }
- ::ok ref hex(), 'exported hex function returns ref outside pragma scope';
- ::ok ref oct(), 'exported oct function returns ref outside pragma scope';
- ::is oct("20"), "16", 'exported oct function works with "decimal"';
+ package _importer;
+ {
+ use bigint 'hex', 'oct';
+ ::is \&hex, \&bigint::hex, 'exported hex function';
+ ::is \&oct, \&bigint::oct, 'exported oct function';
+ }
+ ::ok ref hex(), 'exported hex function returns ref outside pragma scope';
+ ::ok ref oct(), 'exported oct function returns ref outside pragma scope';
+ ::is oct("20"), "16", 'exported oct function works with "decimal"';
# (used to return 20 because it thought it was decimal)
}
{
- package _importer2;
- use bignum 'hex', 'oct';
- ::is \&hex, \&bignum::hex, 'bignum exports hex';
- ::is \&oct, \&bignum::oct, 'bignum exports oct';
- ::is \&hex, \&bigint::hex, 'bignum exports same hex as bigint';
- ::is \&oct, \&bigint::oct, 'bignum exports same oct as bigint';
+ package _importer2;
+ use bignum 'hex', 'oct';
+ ::is \&hex, \&bignum::hex, 'bignum exports hex';
+ ::is \&oct, \&bignum::oct, 'bignum exports oct';
+ ::is \&hex, \&bigint::hex, 'bignum exports same hex as bigint';
+ ::is \&oct, \&bigint::oct, 'bignum exports same oct as bigint';
}
{
- package _importer3;
- use bigrat 'hex', 'oct';
- ::is \&hex, \&bigrat::hex, 'bigrat exports hex';
- ::is \&oct, \&bigrat::oct, 'bigrat exports oct';
- ::is \&hex, \&bigint::hex, 'bigrat exports same hex as bigint';
- ::is \&oct, \&bigint::oct, 'bigrat exports same oct as bigint';
+ package _importer3;
+ use bigrat 'hex', 'oct';
+ ::is \&hex, \&bigrat::hex, 'bigrat exports hex';
+ ::is \&oct, \&bigrat::oct, 'bigrat exports oct';
+ ::is \&hex, \&bigint::hex, 'bigrat exports same hex as bigint';
+ ::is \&oct, \&bigint::oct, 'bigrat exports same oct as bigint';
}
is ref(hex 0), "", 'hex export is not global';
is ref(oct 0), "", 'oct export is not global';
diff --git a/cpan/bignum/t/ratopt_a.t b/cpan/bignum/t/ratopt_a.t
index 0d18e87031..e5ee13b942 100644
--- a/cpan/bignum/t/ratopt_a.t
+++ b/cpan/bignum/t/ratopt_a.t
@@ -1,26 +1,25 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
use strict;
+use warnings;
+
use Test::More tests => 7;
-my @C = qw/Math::BigInt Math::BigFloat Math::BigRat/;
+my @CLASSES = qw/Math::BigInt Math::BigFloat Math::BigRat/;
# bigrat (bug until v0.15)
use bigrat a => 2;
-foreach my $c (@C)
- {
- is ($c->accuracy(), 2, "$c accuracy = 2");
- }
-
-eval { bigrat->import( accuracy => '42') };
+foreach my $class (@CLASSES) {
+ is($class->accuracy(), 2, "$class accuracy = 2");
+}
-is ($@, '', 'no error');
+eval { bigrat->import(accuracy => '42') };
-foreach my $c (@C)
- {
- is ($c->accuracy(), 42, "$c accuracy = 42");
- }
+is($@, '', 'no error');
+foreach my $class (@CLASSES) {
+ is($class->accuracy(), 42, "$class accuracy = 42");
+}
diff --git a/cpan/bignum/t/scope_f.t b/cpan/bignum/t/scope_f.t
index ba11f5b0e2..23ffc3a665 100644
--- a/cpan/bignum/t/scope_f.t
+++ b/cpan/bignum/t/scope_f.t
@@ -1,9 +1,11 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
# Test "no bignum;" and overloading of hex()/oct() for newer Perls
use strict;
+use warnings;
+
use Test::More tests => 10;
# no :hex and :oct means these do not get overloaded for older Perls:
diff --git a/cpan/bignum/t/scope_i.t b/cpan/bignum/t/scope_i.t
index 8a11a6b17e..e76ceeee25 100644
--- a/cpan/bignum/t/scope_i.t
+++ b/cpan/bignum/t/scope_i.t
@@ -1,34 +1,35 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
# Test "no bigint;" and overloading of hex()/oct() for newer Perls
use strict;
+use warnings;
+
use Test::More tests => 10;
# no :hex and :oct means these do not get overloaded for older Perls:
use bigint;
-isnt (ref(1), '', 'is in effect');
-isnt (ref(2.0), '', 'is in effect');
-isnt (ref(0x20), '', 'is in effect');
+isnt(ref(1), '', 'is in effect');
+isnt(ref(2.0), '', 'is in effect');
+isnt(ref(0x20), '', 'is in effect');
SKIP: {
- skip ('Need at least Perl v5.9.4', 2) if $] < "5.009004"; # quote due to "use bigint;"
+ # Quote version number due to "use bigint;"
+ skip('Need at least Perl v5.9.4', 2) if $] < "5.009004";
- is (ref(hex(9)), 'Math::BigInt', 'hex is overloaded');
- is (ref(oct(07)), 'Math::BigInt', 'oct is overloaded');
- }
+ is(ref(hex(9)), 'Math::BigInt', 'hex is overloaded');
+ is(ref(oct(07)), 'Math::BigInt', 'oct is overloaded');
+}
{
- no bigint;
+ no bigint;
- is (ref(1), '', 'is not in effect');
- is (ref(2.0), '', 'is not in effect');
- is (ref(0x20), '', 'is not in effect');
-
- isnt (ref(hex(9)), 'Math::BigInt', 'hex is not overloaded');
- isnt (ref(oct(07)), 'Math::BigInt', 'oct is not overloaded');
+ is(ref(1), '', 'is not in effect');
+ is(ref(2.0), '', 'is not in effect');
+ is(ref(0x20), '', 'is not in effect');
+ isnt(ref(hex(9)), 'Math::BigInt', 'hex is not overloaded');
+ isnt(ref(oct(07)), 'Math::BigInt', 'oct is not overloaded');
}
-
diff --git a/cpan/bignum/t/scope_r.t b/cpan/bignum/t/scope_r.t
index 5cc2117f01..8ad2626bf8 100644
--- a/cpan/bignum/t/scope_r.t
+++ b/cpan/bignum/t/scope_r.t
@@ -1,33 +1,34 @@
-#!/usr/bin/perl -w
+#!perl
###############################################################################
# Test "no bigrat;" and overloading of hex()/oct() for newer Perls
use strict;
+use warnings;
+
use Test::More tests => 10;
# no :hex and :oct means these do not get overloaded for older Perls:
use bigrat;
-isnt (ref(1), '', 'is in effect');
-isnt (ref(2.0), '', 'is in effect');
-isnt (ref(0x20), '', 'is in effect');
+isnt(ref(1), '', 'is in effect');
+isnt(ref(2.0), '', 'is in effect');
+isnt(ref(0x20), '', 'is in effect');
SKIP: {
- skip ('Need at least Perl v5.9.4', 2) if $] < 5.009004;
+ skip('Need at least Perl v5.9.4', 2) if $] < 5.009004;
- is (ref(hex(9)), 'Math::BigInt', 'hex is overloaded');
- is (ref(oct(07)), 'Math::BigInt', 'oct is overloaded');
- }
+ is(ref(hex(9)), 'Math::BigInt', 'hex is overloaded');
+ is(ref(oct(07)), 'Math::BigInt', 'oct is overloaded');
+}
{
- no bigrat;
+ no bigrat;
- is (ref(1), '', 'is not in effect');
- is (ref(2.0), '', 'is not in effect');
- is (ref(0x20), '', 'is not in effect');
+ is(ref(1), '', 'is not in effect');
+ is(ref(2.0), '', 'is not in effect');
+ is(ref(0x20), '', 'is not in effect');
- isnt (ref(hex(9)), 'Math::BigInt', 'hex is not overloaded');
- isnt (ref(oct(07)), 'Math::BigInt', 'oct is not overloaded');
+ isnt(ref(hex(9)), 'Math::BigInt', 'hex is not overloaded');
+ isnt(ref(oct(07)), 'Math::BigInt', 'oct is not overloaded');
}
-