summaryrefslogtreecommitdiff
path: root/cpan/Math-BigRat
diff options
context:
space:
mode:
authorRichard Leach <richardleach@users.noreply.github.com>2021-11-19 21:37:48 +0000
committerRichard Leach <richardleach@users.noreply.github.com>2021-11-19 21:37:48 +0000
commit6853e8af3bcdae27c05a50e71c8ede1ab2b42822 (patch)
tree77213230b2a506aeab7d2f43f56eb5856933f5a3 /cpan/Math-BigRat
parent4c4a89ed9c56cf3cb024f4ed67e9be031b5960cf (diff)
downloadperl-6853e8af3bcdae27c05a50e71c8ede1ab2b42822.tar.gz
Update bignum, Math::BigInt, Math::BigInt::FastCalc, and Math::BigRat
bignum ====== 0.63 2021-10-08 * This version instroduces no changes to the Perl modules, only the tests. * Remove tests that don't work on old Perls and that were actually testing Math::Big(Int|Float|Rat) more than big(int|num|rat). * Skip tests that don't work on older versions of Perl. * Remove Perl v5.10.0 as dependency. This distribution is compatible with Perls back to at least v5.6.1, although some functionality (e.g., nesting the pragmas) requires more recent versions of Perl. 0.62 2021-10-03 * Add support for multiple options in import(), so that one can use, e.g., use bignum accuracy => 20, lib => "GMP"; * Make sure the bigrat pragma always returns Math::BigRat objects. * Make the "trace" option work as indended, or at least according to what I believe is the intention. * Improve documentation. Fix typos, improve wording, add more examples etc. 0.61 2021-10-01 * Improve documentation related to floating point literals. * Skip tests that fail due to Perl's broken handling of floating point literals before v5.32.0. 0.60 2021-09-28 * Separate the bigint, bignum, and bigrat pragmas. - The bigint pragma now converts every numeric constant that represents an integer to a Math::BigInt object. Non-integers are converted to Math::BigInt NaNs. With the previous behaviour, only some numeric constant integers were converted to a Math::BigInt. - The bignum pragma now converts every numeric constant to a Math::BigFloat object. - The bigrat pragma now converts every numeric constant to a Math::BigRat pragma. The pragmas no longer activate upgrading and downgrading. The upgrading and downgrading must now be activated explicitly. The rationale behind deactivating it by default is that can cause infinite looping where objects bounce back and forth between different classes. Explicitly requesting a specific class doesn't always work either, because the object might be automatically upgraded or downgraded to a different class. Only one pragma can be used at a time in a given scope. Enabling one pragma disables the others in the same scope. * Implementat working version of "no bigint", "no bignum", and "no bigrat". Previously, the upgrading and downgrading activated by, e.g., "use bigint" was not deactivated by "no bigint". * Sync behaviour with the Math-BigInt distribution. Math::BigInt ============ 1.999827 2021-10-03 * Improve error message for missing library argument. * Skip tests that don't work on older Perls. Also skip tests that compare floating point numbers. 1.999826 2021-10-01 * Improve documentation related to floating point literals. * Skip tests that fail due to Perl's broken handling of floating point literals before v5.32.0. 1.999825 2021-09-28 * Make Math::BigInt accept integers regardless of whether they are written as decimal, binary, octal, or hexadecimal integers or decimal, binary, octal, or hexadecimal floating point number. * When numeric constants are overloaded (with the ":constant" option) in Math::BigInt, every numeric constant that represent an integer is converted to an object regardless of how it is written. All finite non-integers are converted to a NaN. * When numeric constants are overloaded (with the ":constant" option) in Math::BigFloat, every numeric constant is converted to an object regardless of how it is written. * Add method from_dec() (cf. from_bin(), from_oct(), and from_hex()). It is like new() except that it does not accept anything but a string representing a finite decimal number. 1.999824 2021-09-20 * Don't allow mixing math libraries. Use the first backend math library that is successfully loaded, and ignore any further attempts at loading a different backend library. This is a solution to the re-occurring problem of using objects using different math libraries. * Add missing documentation. * Miscellaneous minor improvements. Math::BigInt::FastCalc ====================== 0.5012 2021-09-28 * Sync test files with Math-BigInt. 0.5011 2021-09-20 * Sync test files with Math-BigInt. * Add missing documentation. * Make the test files only print to the standard error when there is an actual error. * Miscellaneous changes and updates to author and release test files. Math::BigRat ============ 0.2620 2021-10-03 * Skip tests that don't work on older Perls. Also skip tests that compare floating point numbers. 0.2619 2021-10-01 * Correct the handling of Inf and NaN in numify(). * Improve constant overloading. When numeric constants are overloaded (with the ":constant" option) in Math::BigRat, every numeric constant is converted to an object regardless of how it is written. 0.2618 2021-09-28 * Add new method binv() for the inverse. * Add new method dparts(), which returns the integer part and fraction part of a number. For example, 9/4 is split into 2 and 1/4. This method is equivalent to the Math::BigInt and Math::BigFloat methods with the same name. * Improve blog(). Handle cases $x->blog($b) where the numerator of $x and/or $b is 1 as special. * Sync tests with Math-BigInt.
Diffstat (limited to 'cpan/Math-BigRat')
-rw-r--r--cpan/Math-BigRat/lib/Math/BigRat.pm308
-rw-r--r--cpan/Math-BigRat/t/badd-mbr.t164
-rw-r--r--cpan/Math-BigRat/t/big_ap.t2
-rw-r--r--cpan/Math-BigRat/t/bigfltrt.t2
-rw-r--r--cpan/Math-BigRat/t/bigrat.t72
-rw-r--r--cpan/Math-BigRat/t/bigratpm.inc7
-rw-r--r--cpan/Math-BigRat/t/bigratpm.t4
-rw-r--r--cpan/Math-BigRat/t/bigratup.t2
-rw-r--r--cpan/Math-BigRat/t/binv-mbr.t89
-rw-r--r--cpan/Math-BigRat/t/bitwise.t2
-rw-r--r--cpan/Math-BigRat/t/bnok-mbr.t2
-rw-r--r--cpan/Math-BigRat/t/const-mbr.t319
-rw-r--r--cpan/Math-BigRat/t/dparts-mbr.t67
-rw-r--r--cpan/Math-BigRat/t/hang.t2
-rw-r--r--cpan/Math-BigRat/t/new-mbr.t50
-rw-r--r--cpan/Math-BigRat/t/requirer.t2
-rw-r--r--cpan/Math-BigRat/t/rt121139.t2
-rw-r--r--cpan/Math-BigRat/t/trap.t2
18 files changed, 1008 insertions, 90 deletions
diff --git a/cpan/Math-BigRat/lib/Math/BigRat.pm b/cpan/Math-BigRat/lib/Math/BigRat.pm
index e799abd58b..5f3af33b3e 100644
--- a/cpan/Math-BigRat/lib/Math/BigRat.pm
+++ b/cpan/Math-BigRat/lib/Math/BigRat.pm
@@ -16,11 +16,12 @@ use 5.006;
use strict;
use warnings;
-use Carp qw< carp croak >;
+use Carp qw< carp croak >;
+use Scalar::Util qw< blessed >;
-use Math::BigFloat 1.999718;
+use Math::BigFloat ();
-our $VERSION = '0.2617';
+our $VERSION = '0.2620';
our @ISA = qw(Math::BigFloat);
@@ -793,12 +794,21 @@ sub badd {
($class, $x, $y, @r) = objectify(2, @_);
}
- # +inf + +inf => +inf, -inf + -inf => -inf
- return $x->binf(substr($x->{sign}, 0, 1))
- if $x->{sign} eq $y->{sign} && $x->{sign} =~ /^[+-]inf$/;
-
- # +inf + -inf or -inf + +inf => NaN
- return $x->bnan() if ($x->{sign} !~ /^[+-]$/ || $y->{sign} !~ /^[+-]$/);
+ unless ($x -> is_finite() && $y -> is_finite()) {
+ if ($x -> is_nan() || $y -> is_nan()) {
+ return $x -> bnan(@r);
+ } elsif ($x -> is_inf("+")) {
+ return $x -> bnan(@r) if $y -> is_inf("-");
+ return $x -> binf("+", @r);
+ } elsif ($x -> is_inf("-")) {
+ return $x -> bnan(@r) if $y -> is_inf("+");
+ return $x -> binf("-", @r);
+ } elsif ($y -> is_inf("+")) {
+ return $x -> binf("+", @r);
+ } elsif ($y -> is_inf("-")) {
+ return $x -> binf("-", @r);
+ }
+ }
# 1 1 gcd(3, 4) = 1 1*3 + 1*4 7
# - + - = --------- = --
@@ -1115,6 +1125,20 @@ sub binc {
$x->bnorm()->round(@r);
}
+sub binv {
+ my $x = shift;
+ my @r = @_;
+
+ return $x if $x->modify('binv');
+
+ return $x if $x -> is_nan();
+ return $x -> bzero() if $x -> is_inf();
+ return $x -> binf("+") if $x -> is_zero();
+
+ ($x -> {_n}, $x -> {_d}) = ($x -> {_d}, $x -> {_n});
+ $x -> round(@r);
+}
+
##############################################################################
# is_foo methods (the rest is inherited)
@@ -1206,6 +1230,35 @@ sub parts {
($n, $d);
}
+sub dparts {
+ my $x = shift;
+ my $class = ref $x;
+
+ croak("dparts() is an instance method") unless $class;
+
+ if ($x -> is_nan()) {
+ return $class -> bnan(), $class -> bnan() if wantarray;
+ return $class -> bnan();
+ }
+
+ if ($x -> is_inf()) {
+ return $class -> binf($x -> sign()), $class -> bzero() if wantarray;
+ return $class -> binf($x -> sign());
+ }
+
+ # 355/113 => 3 + 16/113
+
+ my ($q, $r) = $LIB -> _div($LIB -> _copy($x -> {_n}), $x -> {_d});
+
+ my $int = Math::BigRat -> new($x -> {sign} . $LIB -> _str($q));
+ return $int unless wantarray;
+
+ my $frc = Math::BigRat -> new($x -> {sign} . $LIB -> _str($r),
+ $LIB -> _str($x -> {_d}));
+
+ return $int, $frc;
+}
+
sub length {
my ($class, $x) = ref($_[0]) ? (undef, $_[0]) : objectify(1, @_);
@@ -1353,11 +1406,11 @@ sub blog {
# $x->blog(undef) signals that the base is Euler's number.
if (!ref($_[0]) && $_[0] =~ /^[A-Za-z]|::/) {
- # E.g., Math::BigFloat->blog(256, 2)
+ # E.g., Math::BigRat->blog(256, 2)
($class, $x, $base, @r) =
defined $_[2] ? objectify(2, @_) : objectify(1, @_);
} else {
- # E.g., Math::BigFloat::blog(256, 2) or $x->blog(2)
+ # E.g., Math::BigRat::blog(256, 2) or $x->blog(2)
($class, $x, $base, @r) =
defined $_[1] ? objectify(2, @_) : objectify(1, @_);
}
@@ -1398,6 +1451,24 @@ sub blog {
return $x -> binf($sign);
}
+ # Now take care of the cases where $x and/or $base is 1/N.
+ #
+ # log(1/N) / log(B) = -log(N)/log(B)
+ # log(1/N) / log(1/B) = log(N)/log(B)
+ # log(N) / log(1/B) = -log(N)/log(B)
+
+ my $neg = 0;
+ if ($x -> numerator() -> is_one()) {
+ $x -> binv();
+ $neg = !$neg;
+ }
+ if (defined(blessed($base)) && $base -> isa($class)) {
+ if ($base -> numerator() -> is_one()) {
+ $base = $base -> copy() -> binv();
+ $neg = !$neg;
+ }
+ }
+
# At this point we are done handling all exception cases and trivial cases.
$base = Math::BigFloat -> new($base) if defined $base;
@@ -1411,7 +1482,7 @@ sub blog {
$x -> {_n} = $xtmp -> {_n};
$x -> {_d} = $xtmp -> {_d};
- return $x;
+ return $neg ? $x -> bneg() : $x;
}
sub bexp {
@@ -1813,9 +1884,9 @@ sub bcmp {
if ($x->{sign} !~ /^[+-]$/ || $y->{sign} !~ /^[+-]$/) {
# $x is NaN and/or $y is NaN
- return undef if $x->{sign} eq $nan || $y->{sign} eq $nan;
+ return if $x->{sign} eq $nan || $y->{sign} eq $nan;
# $x and $y are both either +inf or -inf
- return 0 if $x->{sign} eq $y->{sign} && $x->{sign} =~ /^[+-]inf$/;
+ return 0 if $x->{sign} eq $y->{sign} && $x->{sign} =~ /^[+-]inf$/;
# $x = +inf and $y < +inf
return +1 if $x->{sign} eq '+inf';
# $x = -inf and $y > -inf
@@ -1860,9 +1931,9 @@ sub bacmp {
if (($x->{sign} !~ /^[+-]$/) || ($y->{sign} !~ /^[+-]$/)) {
# handle +-inf and NaN
- return undef if (($x->{sign} eq $nan) || ($y->{sign} eq $nan));
- return 0 if $x->{sign} =~ /^[+-]inf$/ && $y->{sign} =~ /^[+-]inf$/;
- return 1 if $x->{sign} =~ /^[+-]inf$/ && $y->{sign} !~ /^[+-]inf$/;
+ return if (($x->{sign} eq $nan) || ($y->{sign} eq $nan));
+ return 0 if $x->{sign} =~ /^[+-]inf$/ && $y->{sign} =~ /^[+-]inf$/;
+ return 1 if $x->{sign} =~ /^[+-]inf$/ && $y->{sign} !~ /^[+-]inf$/;
return -1;
}
@@ -1953,7 +2024,17 @@ sub numify {
# Non-finite number.
- return $x->bstr() if $x->{sign} !~ /^[+-]$/;
+ if ($x -> is_nan()) {
+ require Math::Complex;
+ my $inf = $Math::Complex::Inf;
+ return $inf - $inf;
+ }
+
+ if ($x -> is_inf()) {
+ require Math::Complex;
+ my $inf = $Math::Complex::Inf;
+ return $x -> is_negative() ? -$inf : $inf;
+ }
# Finite number.
@@ -2029,18 +2110,27 @@ sub as_oct {
sub from_hex {
my $class = shift;
- $class->new(@_);
+ # The relationship should probably go the otherway, i.e, that new() calls
+ # from_hex(). Fixme!
+ my ($x, @r) = @_;
+ $x =~ s|^\s*(?:0?[Xx]_*)?|0x|;
+ $class->new($x, @r);
}
sub from_bin {
my $class = shift;
- $class->new(@_);
+ # The relationship should probably go the otherway, i.e, that new() calls
+ # from_bin(). Fixme!
+ my ($x, @r) = @_;
+ $x =~ s|^\s*(?:0?[Bb]_*)?|0b|;
+ $class->new($x, @r);
}
sub from_oct {
my $class = shift;
+ # Why is this different from from_hex() and from_bin()? Fixme!
my @parts;
for my $c (@_) {
push @parts, Math::BigInt->from_oct($c);
@@ -2053,53 +2143,97 @@ sub from_oct {
sub import {
my $class = shift;
- my @a;
- my $lib = '';
- my $try = 'try';
+ my @a; # unrecognized arguments
+ my $lib_param = '';
+ my $lib_value = '';
+
+ while (@_) {
+ my $param = shift;
+
+ # Enable overloading of constants.
+
+ if ($param eq ':constant') {
+ overload::constant
+
+ integer => sub {
+ $class -> new(shift);
+ },
- for (my $i = 0; $i <= $#_ ; $i++) {
- croak "Error in import(): argument with index $i is undefined"
- unless defined($_[$i]);
+ float => sub {
+ $class -> new(shift);
+ },
- if ($_[$i] eq ':constant') {
- # this rest causes overlord er load to step in
- overload::constant float => sub { $class->new(shift); };
+ binary => sub {
+ # E.g., a literal 0377 shall result in an object whose value
+ # is decimal 255, but new("0377") returns decimal 377.
+ return $class -> from_oct($_[0]) if $_[0] =~ /^0_*[0-7]/;
+ $class -> new(shift);
+ };
+ next;
}
- #elsif ($_[$i] eq 'upgrade') {
- # # this causes upgrading
- # $upgrade = $_[$i+1]; # or undef to disable
- # $i++;
- #}
+ # Upgrading.
- elsif ($_[$i] eq 'downgrade') {
- # this causes downgrading
- $downgrade = $_[$i+1]; # or undef to disable
- $i++;
+ if ($param eq 'upgrade') {
+ $class -> upgrade(shift);
+ next;
}
- elsif ($_[$i] =~ /^(lib|try|only)\z/) {
- $lib = $_[$i+1] || '';
- $try = $1; # "lib", "try" or "only"
- $i++;
+ # Downgrading.
+
+ if ($param eq 'downgrade') {
+ $class -> downgrade(shift);
+ next;
}
- elsif ($_[$i] eq 'with') {
- # this argument is no longer used
- # $LIB = $_[$i+1] || 'Calc';
- # carp "'with' is no longer supported, use 'lib', 'try', or 'only'";
- $i++;
+ # Accuracy.
+
+ if ($param eq 'accuracy') {
+ $class -> accuracy(shift);
+ next;
+ }
+
+ # Precision.
+
+ if ($param eq 'precision') {
+ $class -> precision(shift);
+ next;
+ }
+
+ # Rounding mode.
+
+ if ($param eq 'round_mode') {
+ $class -> round_mode(shift);
+ next;
}
- else {
- push @a, $_[$i];
+ # Backend library.
+
+ if ($param =~ /^(lib|try|only)\z/) {
+ # alternative library
+ $lib_param = $param; # "lib", "try", or "only"
+ $lib_value = shift;
+ next;
}
+
+ if ($param eq 'with') {
+ # alternative class for our private parts()
+ # XXX: no longer supported
+ # $LIB = shift() || 'Calc';
+ # carp "'with' is no longer supported, use 'lib', 'try', or 'only'";
+ shift;
+ next;
+ }
+
+ # Unrecognized parameter.
+
+ push @a, $param;
}
require Math::BigInt;
my @import = ('objectify');
- push @import, $try, $lib if $lib ne '';
+ push @import, $lib_param, $lib_value if $lib_param ne '';
Math::BigInt -> import(@import);
# find out which one was actually loaded
@@ -2211,6 +2345,10 @@ Returns a copy of the denominator (the part under the line) as positive BigInt.
Return a list consisting of (signed) numerator and (unsigned) denominator as
BigInts.
+=item dparts()
+
+Returns the integer part and the fraction part.
+
=item numify()
my $y = $x->numify();
@@ -2525,6 +2663,12 @@ does floored division (F-division), returning an integer $q and a remainder $r
so that $x = $q * $y + $r. The remainer (modulo) is equal to what is returned
by C<< $x->bmod($y) >>.
+=item binv()
+
+ $x->binv();
+
+Inverse of $x.
+
=item bdec()
$x->bdec();
@@ -2705,6 +2849,70 @@ supported.
=back
+=head1 NUMERIC LITERALS
+
+After C<use Math::BigRat ':constant'> all numeric literals in the given scope
+are converted to C<Math::BigRat> objects. This conversion happens at compile
+time. Every non-integer is convert to a NaN.
+
+For example,
+
+ perl -MMath::BigRat=:constant -le 'print 2**150'
+
+prints the exact value of C<2**150>. Note that without conversion of constants
+to objects the expression C<2**150> is calculated using Perl scalars, which
+leads to an inaccurate result.
+
+Please note that strings are not affected, so that
+
+ use Math::BigRat qw/:constant/;
+
+ $x = "1234567890123456789012345678901234567890"
+ + "123456789123456789";
+
+does give you what you expect. You need an explicit Math::BigRat->new() around
+at least one of the operands. You should also quote large constants to prevent
+loss of precision:
+
+ use Math::BigRat;
+
+ $x = Math::BigRat->new("1234567889123456789123456789123456789");
+
+Without the quotes Perl first converts the large number to a floating point
+constant at compile time, and then converts the result to a Math::BigRat object
+at run time, which results in an inaccurate result.
+
+=head2 Hexadecimal, octal, and binary floating point literals
+
+Perl (and this module) accepts hexadecimal, octal, and binary floating point
+literals, but use them with care with Perl versions before v5.32.0, because some
+versions of Perl silently give the wrong result. Below are some examples of
+different ways to write the number decimal 314.
+
+Hexadecimal floating point literals:
+
+ 0x1.3ap+8 0X1.3AP+8
+ 0x1.3ap8 0X1.3AP8
+ 0x13a0p-4 0X13A0P-4
+
+Octal floating point literals (with "0" prefix):
+
+ 01.164p+8 01.164P+8
+ 01.164p8 01.164P8
+ 011640p-4 011640P-4
+
+Octal floating point literals (with "0o" prefix) (requires v5.34.0):
+
+ 0o1.164p+8 0O1.164P+8
+ 0o1.164p8 0O1.164P8
+ 0o11640p-4 0O11640P-4
+
+Binary floating point literals:
+
+ 0b1.0011101p+8 0B1.0011101P+8
+ 0b1.0011101p8 0B1.0011101P8
+ 0b10011101000p-2 0B10011101000P-2
+
=head1 BUGS
Please report any bugs or feature requests to
diff --git a/cpan/Math-BigRat/t/badd-mbr.t b/cpan/Math-BigRat/t/badd-mbr.t
new file mode 100644
index 0000000000..1f96200736
--- /dev/null
+++ b/cpan/Math-BigRat/t/badd-mbr.t
@@ -0,0 +1,164 @@
+# -*- mode: perl; -*-
+
+use strict;
+use warnings;
+
+use Test::More tests => 173;
+
+my $class;
+
+BEGIN {
+ $class = 'Math::BigRat';
+ use_ok($class);
+}
+
+while (<DATA>) {
+ s/#.*$//; # remove comments
+ s/\s+$//; # remove trailing whitespace
+ next unless length; # skip empty lines
+
+ my ($xval, $yval, $zval) = split /:/;
+ my ($x, $y, $got, @got);
+
+ for my $context_is_scalar (0, 1) {
+ for my $y_is_scalar (0, 1) {
+
+ my $test = qq|\$x = $class -> new("$xval");|;
+
+ $test .= $y_is_scalar
+ ? qq| \$y = "$yval";|
+ : qq| \$y = $class -> new("$yval");|;
+
+ $test .= $context_is_scalar
+ ? qq| \$got = \$x -> badd(\$y);|
+ : qq| \@got = \$x -> badd(\$y);|;
+
+ my $desc = "badd() in ";
+ $desc .= $context_is_scalar ? "scalar context" : "list context";
+ $desc .= $y_is_scalar ? " with y as scalar" : " with y as object";
+
+ subtest $desc,
+ sub {
+ plan tests => $context_is_scalar ? 7 : 8;
+
+ eval $test;
+ is($@, "", "'$test' gives emtpy \$\@");
+
+ if ($context_is_scalar) {
+
+ # Check output.
+
+ is(ref($got), $class,
+ "'$test' output arg is a $class");
+
+ is($got -> bstr(), $zval,
+ "'$test' output arg has the right value");
+
+ } else {
+
+ # Check number of output arguments.
+
+ cmp_ok(scalar @got, '==', 1,
+ "'$test' gives one output arg");
+
+ # Check output.
+
+ is(ref($got[0]), $class,
+ "'$test' output arg is a $class");
+
+ is($got[0] -> bstr(), $zval,
+ "'$test' output arg has the right value");
+ }
+
+ # Check the invocand.
+
+ is(ref($x), $class,
+ "'$test' invocand is still a $class");
+
+ is($x -> bstr(), $zval,
+ "'$test' invocand has the right value");
+
+ # Check the input argument.
+
+ if ($y_is_scalar) {
+
+ is(ref($y), '',
+ "'$test' second input arg is still a scalar");
+
+ is($y, $yval,
+ "'$test' second input arg is unmodified");
+
+ } else {
+
+ is(ref($y), $class,
+ "'$test' second input arg is still a $class");
+
+ is($y -> bstr(), $yval,
+ "'$test' second input arg is unmodified");
+ }
+ };
+ }
+ }
+}
+
+__DATA__
+
+# x and/or y is NaN
+
+NaN:NaN:NaN
+
+NaN:-inf:NaN
+NaN:-3:NaN
+NaN:0:NaN
+NaN:3:NaN
+NaN:inf:NaN
+
+-inf:NaN:NaN
+-3:NaN:NaN
+0:NaN:NaN
+3:NaN:NaN
+inf:NaN:NaN
+
+# x = inf
+
+inf:-inf:NaN
+inf:-3:inf
+inf:-2:inf
+inf:-1:inf
+inf:0:inf
+inf:1:inf
+inf:2:inf
+inf:3:inf
+inf:inf:inf
+
+# x = -inf
+
+-inf:-inf:-inf
+-inf:-3:-inf
+-inf:-2:-inf
+-inf:-1:-inf
+-inf:0:-inf
+-inf:1:-inf
+-inf:2:-inf
+-inf:3:-inf
+-inf:inf:NaN
+
+# y = inf
+
+-3:inf:inf
+-2:inf:inf
+-1:inf:inf
+0:inf:inf
+1:inf:inf
+2:inf:inf
+3:inf:inf
+
+# y = -inf
+
+-3:-inf:-inf
+-2:-inf:-inf
+-1:-inf:-inf
+0:-inf:-inf
+1:-inf:-inf
+2:-inf:-inf
+3:-inf:-inf
diff --git a/cpan/Math-BigRat/t/big_ap.t b/cpan/Math-BigRat/t/big_ap.t
index 1ac46e5d9f..dd114be707 100644
--- a/cpan/Math-BigRat/t/big_ap.t
+++ b/cpan/Math-BigRat/t/big_ap.t
@@ -1,4 +1,4 @@
-#!perl
+# -*- mode: perl; -*-
# Test that accuracy() and precision() in BigInt/BigFloat do not disturb
# the rounding force in BigRat.
diff --git a/cpan/Math-BigRat/t/bigfltrt.t b/cpan/Math-BigRat/t/bigfltrt.t
index 856318614f..27a17b2d81 100644
--- a/cpan/Math-BigRat/t/bigfltrt.t
+++ b/cpan/Math-BigRat/t/bigfltrt.t
@@ -1,4 +1,4 @@
-#!perl
+# -*- mode: perl; -*-
use strict;
use warnings;
diff --git a/cpan/Math-BigRat/t/bigrat.t b/cpan/Math-BigRat/t/bigrat.t
index fec6afd568..8c31cfe2dc 100644
--- a/cpan/Math-BigRat/t/bigrat.t
+++ b/cpan/Math-BigRat/t/bigrat.t
@@ -1,9 +1,9 @@
-#!perl
+# -*- mode: perl; -*-
use strict;
use warnings;
-use Test::More tests => 202;
+use Test::More tests => 201;
# basic testing of Math::BigRat
@@ -346,7 +346,8 @@ $x = $mbr->new('-7/5')->bsstr();
is($x, '-7/5');
##############################################################################
-# numify()
+
+note("numify()");
my @array = qw/1 2 3 4 5 6 7 8 9/;
$x = $mbr->new('8/8');
@@ -367,23 +368,60 @@ is($array[$x], 6);
$x = $mbr->new('-8/1');
is($array[$x], 2); # -8 => 2
-$x = $mbr->new('33/8');
-is($x->numify() * 1000, 4125);
-
-$x = $mbr->new('-33/8');
-is($x->numify() * 1000, -4125);
-
-$x = $mbr->new('inf');
-is($x->numify(), 'inf');
+require Math::Complex;
-$x = $mbr->new('-inf');
-is($x->numify(), '-inf');
+my $inf = $Math::Complex::Inf;
+my $nan = $inf - $inf;
-$x = $mbr->new('NaN');
-is($x->numify(), 'NaN');
+sub isnumeric {
+ my $value = shift;
+ ($value ^ $value) eq "0";
+}
-$x = $mbr->new('4/3');
-is($x->numify(), 4/3);
+subtest qq|$mbr -> new("33/8") -> numify()| => sub {
+ plan tests => 3;
+
+ $x = $mbr -> new("33/8") -> numify();
+ is(ref($x), "", '$x is a scalar');
+ ok(isnumeric($x), '$x is numeric');
+ cmp_ok($x, "==", 4.125, '$x has the right value');
+};
+
+subtest qq|$mbr -> new("-33/8") -> numify()| => sub {
+ plan tests => 3;
+
+ $x = $mbr -> new("-33/8") -> numify();
+ is(ref($x), "", '$x is a scalar');
+ ok(isnumeric($x), '$x is numeric');
+ cmp_ok($x, "==", -4.125, '$x has the right value');
+};
+
+subtest qq|$mbr -> new("inf") -> numify()| => sub {
+ plan tests => 3;
+
+ $x = $mbr -> new("inf") -> numify();
+ is(ref($x), "", '$x is a scalar');
+ ok(isnumeric($x), '$x is numeric');
+ cmp_ok($x, "==", $inf, '$x has the right value');
+};
+
+subtest qq|$mbr -> new("-inf") -> numify()| => sub {
+ plan tests => 3;
+
+ $x = $mbr -> new("-inf") -> numify();
+ is(ref($x), "", '$x is a scalar');
+ ok(isnumeric($x), '$x is numeric');
+ cmp_ok($x, "==", -$inf, '$x has the right value');
+};
+
+subtest qq|$mbr -> new("NaN") -> numify()| => sub {
+ plan tests => 3;
+
+ $x = $mbr -> new("NaN") -> numify();
+ is(ref($x), "", '$x is a scalar');
+ ok(isnumeric($x), '$x is numeric');
+ cmp_ok($x, "!=", $nan, '$x has the right value'); # Note: NaN != NaN
+};
##############################################################################
# as_hex(), as_bin(), as_oct()
diff --git a/cpan/Math-BigRat/t/bigratpm.inc b/cpan/Math-BigRat/t/bigratpm.inc
index b3015360b8..9d5f77ed09 100644
--- a/cpan/Math-BigRat/t/bigratpm.inc
+++ b/cpan/Math-BigRat/t/bigratpm.inc
@@ -318,9 +318,6 @@ NaN:1:NaN
5/2:2.5
3/2:1.5
5/4:1.25
-NaN:NaN
-+inf:inf
--inf:-inf
&fnan
abc:NaN
@@ -361,10 +358,6 @@ inf/-5:-inf
-inf/-5:inf
123:123
-123.4567:-1234567/10000
-# invalid inputs
-1__2:NaN
-1E1__2:NaN
-11__2E2:NaN
#1.E3:NaN
.2E-3.:NaN
#1e3e4:NaN
diff --git a/cpan/Math-BigRat/t/bigratpm.t b/cpan/Math-BigRat/t/bigratpm.t
index 40f9f6eb8a..d6d9641b21 100644
--- a/cpan/Math-BigRat/t/bigratpm.t
+++ b/cpan/Math-BigRat/t/bigratpm.t
@@ -1,9 +1,9 @@
-#!perl
+# -*- mode: perl; -*-
use strict;
use warnings;
-use Test::More tests => 905;
+use Test::More tests => 899;
use Math::BigRat lib => 'Calc';
diff --git a/cpan/Math-BigRat/t/bigratup.t b/cpan/Math-BigRat/t/bigratup.t
index f424486a52..1f9bf49c29 100644
--- a/cpan/Math-BigRat/t/bigratup.t
+++ b/cpan/Math-BigRat/t/bigratup.t
@@ -1,4 +1,4 @@
-#!perl
+# -*- mode: perl; -*-
# Test whether $Math::BigInt::upgrade breaks our neck
diff --git a/cpan/Math-BigRat/t/binv-mbr.t b/cpan/Math-BigRat/t/binv-mbr.t
new file mode 100644
index 0000000000..dfba7fd652
--- /dev/null
+++ b/cpan/Math-BigRat/t/binv-mbr.t
@@ -0,0 +1,89 @@
+# -*- mode: perl; -*-
+
+use strict;
+use warnings;
+
+use Test::More tests => 21;
+
+use Scalar::Util qw< refaddr >;
+
+my $class;
+
+BEGIN {
+ $class = 'Math::BigRat';
+ use_ok($class);
+}
+
+while (<DATA>) {
+ s/#.*$//; # remove comments
+ s/\s+$//; # remove trailing whitespace
+ next unless length; # skip empty lines
+
+ my ($xval, $yval) = split /:/;
+ my ($x, $got, @got);
+
+ for my $context_is_scalar (0, 1) {
+
+ my $test = qq|\$x = $class -> new("$xval");|;
+
+ $test .= $context_is_scalar
+ ? qq| \$got = \$x -> binv();|
+ : qq| \@got = \$x -> binv();|;
+
+ my $desc = "binv() in ";
+ $desc .= $context_is_scalar ? "scalar context" : "list context";
+
+ subtest $desc,
+ sub {
+ plan tests => $context_is_scalar ? 4 : 5;
+
+ eval $test;
+ is($@, "", "'$test' gives emtpy \$\@");
+
+ if ($context_is_scalar) {
+
+ # Check output.
+
+ is(ref($got), $class,
+ "'$test' output arg is a $class");
+
+ is($x -> bstr(), $yval,
+ "'$test' output arg has the right value");
+
+ is(refaddr($got), refaddr($x),
+ "'$test' output arg is the invocand");
+
+ } else {
+
+ # Check number of output arguments.
+
+ cmp_ok(scalar(@got), '==', 1,
+ "'$test' gives one output arg");
+
+ # Check output.
+
+ is(ref($got[0]), $class,
+ "'$test' output arg is a $class");
+
+ is($got[0] -> bstr(), $yval,
+ "'$test' output arg has the right value");
+
+ is(refaddr($got[0]), refaddr($x),
+ "'$test' output arg is the invocand");
+ }
+ };
+ }
+}
+
+__DATA__
+
+NaN:NaN
+inf:0
+5:1/5
+2:1/2
+1:1
+0:inf
+-1:-1
+-2:-1/2
+-5:-1/5
+-inf:0
diff --git a/cpan/Math-BigRat/t/bitwise.t b/cpan/Math-BigRat/t/bitwise.t
index 6bd499fa51..490b0f3dcf 100644
--- a/cpan/Math-BigRat/t/bitwise.t
+++ b/cpan/Math-BigRat/t/bitwise.t
@@ -1,4 +1,4 @@
-#!perl
+# -*- mode: perl; -*-
use strict;
use warnings;
diff --git a/cpan/Math-BigRat/t/bnok-mbr.t b/cpan/Math-BigRat/t/bnok-mbr.t
index 2328297497..7de6365d91 100644
--- a/cpan/Math-BigRat/t/bnok-mbr.t
+++ b/cpan/Math-BigRat/t/bnok-mbr.t
@@ -1,4 +1,4 @@
-#!perl
+# -*- mode: perl; -*-
use strict;
use warnings;
diff --git a/cpan/Math-BigRat/t/const-mbr.t b/cpan/Math-BigRat/t/const-mbr.t
new file mode 100644
index 0000000000..672882d3be
--- /dev/null
+++ b/cpan/Math-BigRat/t/const-mbr.t
@@ -0,0 +1,319 @@
+# -*- mode: perl; -*-
+
+# Binary, octal, and hexadecimal floating point literals were introduced in
+# v5.22.0.
+#
+# - It wasn't until v5.28.0 that binary, octal, and hexadecimal floating point
+# literals were converted to the correct value on perls compiled with quadmath
+# support.
+#
+# - It wasn't until v5.32.0 that binary and octal floating point literals worked
+# correctly with constant overloading. Before v5.32.0, it seems like the
+# second character is always silently converted to an "x", so, e.g., "0b1.1p8"
+# is passed to the overload::constant subroutine as "0x1.1p8", and "01.1p+8"
+# is passed as "0x.1p+8".
+#
+# - Octal floating point literals using the "0o" prefix were introduced in
+# v5.34.0.
+
+# Note that all numeric literals that should not be overloaded must be quoted.
+
+use strict;
+use warnings;
+
+use Test::More tests => "171";
+
+use Math::BigRat ":constant";
+
+my $class = "Math::BigRat";
+my $x;
+
+################################################################################
+# The following tests should be identical for Math::BigInt, Math::BigFloat and
+# Math::BigRat.
+
+# These are handled by "binary".
+
+$x = 0xff;
+is($x, "255", "hexadecimal integer literal 0xff");
+is(ref($x), $class, "value is a $class");
+
+SKIP: {
+ # Hexadecimal literals using the "0X" prefix require v5.14.0.
+ skip "perl v5.14.0 required for hexadecimal integer literals"
+ . " with '0X' prefix", "2" if $] < "5.014";
+
+ $x = eval "0XFF";
+ is($x, "255", "hexadecimal integer literal 0XFF");
+ is(ref($x), $class, "value is a $class");
+}
+
+$x = 0377;
+is($x, "255", "octal integer literal 0377");
+is(ref($x), $class, "value is a $class");
+
+SKIP: {
+ # Octal literals using the "0o" prefix requires v5.34.0.
+ skip "perl v5.34.0 required for octal floating point literals"
+ . " with '0o' prefix", "4" if $] < "5.034";
+
+ for my $str (qw/ 0o377 0O377 /) {
+ $x = eval $str;
+ is($x, "255", "octal integer literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+}
+
+$x = 0b11111111;
+is($x, "255", "binary integer literal 0b11111111");
+is(ref($x), $class, "value is a $class");
+
+SKIP: {
+ # Binary literals using the "0B" prefix require v5.14.0.
+ skip "perl v5.14.0 required for binary integer literals"
+ . " with '0B' prefix", "2" if $] < "5.014";
+
+ $x = eval "0B11111111";
+ is($x, "255", "binary integer literal 0B11111111");
+ is(ref($x), $class, "value is a $class");
+}
+
+# These are handled by "float".
+
+$x = 999999999999999999999999999999999999999999999999999999999999999999999999;
+is($x,
+ "999999999999999999999999999999999999999999999999999999999999999999999999",
+ "decimal integer literal " . ("9" x 72));
+is(ref($x), $class, "value is a $class");
+
+$x = 1e72 - 1;
+is($x,
+ "999999999999999999999999999999999999999999999999999999999999999999999999",
+ "literal 1e72 - 1");
+is(ref($x), $class, "value is a $class");
+
+# These are handled by "float".
+
+SKIP: {
+ # Hexadecimal floating point literals require v5.28.0.
+ skip "perl v5.28.0 required for hexadecimal floating point literals",
+ "6" * "2" + "2" * "2" if $] < "5.028";
+
+ for my $str (qw/ 0x1.3ap+8 0X1.3AP+8
+ 0x1.3ap8 0X1.3AP8
+ 0x13a0p-4 0X13A0P-4 /)
+ {
+ $x = eval $str;
+ is($x, "314", "hexadecimal floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+
+ for my $str (qw/ 0x0.0p+8 0X0.0P+8 /)
+ {
+ $x = eval $str;
+ is($x, "0", "hexadecimal floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+}
+
+SKIP: {
+ # Octal floating point literals using the "0o" prefix require v5.34.0.
+ skip "perl v5.34.0 required for octal floating point literals"
+ . " with '0o' prefix", "6" * "2" + "6" * "2" if $] < "5.034";
+
+ for my $str (qw/ 0o1.164p+8 0O1.164P+8
+ 0o1.164p8 0O1.164P8
+ 0o11640p-4 0O11640P-4 /)
+ {
+ $x = eval $str;
+ is($x, "314", "octal floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+
+ for my $str (qw/ 0o0.0p+8 0O0.0P+8
+ 0o0.0p8 0O0.0P8
+ 0o0.0p-8 0O0.0P-8 /)
+ {
+ $x = eval $str;
+ is($x, "0", "octal floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+}
+
+SKIP: {
+ # Octal floating point literals using the "0" prefix require v5.32.0.
+ skip "perl v5.32.0 required for octal floating point literals",
+ "6" * "2" + "6" * "2" if $] < "5.032";
+
+ for my $str (qw/ 01.164p+8 01.164P+8
+ 01.164p8 01.164P8
+ 011640p-4 011640P-4 /)
+ {
+ $x = eval $str;
+ is($x, "314", "octal floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+
+ for my $str (qw/ 00.0p+8 00.0P+8
+ 00.0p8 00.0P8
+ 00.0p-8 00.0P-8 /)
+ {
+ $x = eval $str;
+ is($x, "0", "octal floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+}
+
+SKIP: {
+ # Binary floating point literals require v5.32.0.
+ skip "perl v5.32.0 required for binary floating point literals",
+ "6" * "2" + "6" * "2" if $] < "5.032";
+
+ for my $str (qw/ 0b1.0011101p+8 0B1.0011101P+8
+ 0b1.0011101p8 0B1.0011101P8
+ 0b10011101000p-2 0B10011101000P-2 /)
+ {
+ $x = eval $str;
+ is($x, "314", "binary floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+
+ for my $str (qw/ 0b0p+8 0B0P+8
+ 0b0p8 0B0P8
+ 0b0p-8 0B0P-8
+ /)
+ {
+ $x = eval $str;
+ is($x, "0", "binary floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+}
+
+# These are handled by "integer".
+
+$x = 314;
+is($x, "314", "integer literal 314");
+is(ref($x), $class, "value is a $class");
+
+$x = 0;
+is($x, "0", "integer literal 0");
+is(ref($x), $class, "value is a $class");
+
+$x = 2 ** 255;
+is($x,
+ "578960446186580977117854925043439539266"
+ . "34992332820282019728792003956564819968",
+ "2 ** 255");
+is(ref($x), $class, "value is a $class");
+
+# These are handled by "binary".
+
+{
+ no warnings "portable"; # protect against "non-portable" warnings
+
+ # hexadecimal constant
+ $x = 0x123456789012345678901234567890;
+ is($x,
+ "94522879687365475552814062743484560",
+ "hexadecimal constant 0x123456789012345678901234567890");
+ is(ref($x), $class, "value is a $class");
+
+ # octal constant
+ $x = 012345676543210123456765432101234567654321;
+ is($x,
+ "1736132869400711976876385488263403729",
+ "octal constant 012345676543210123456765432101234567654321");
+ is(ref($x), $class, "value is a $class");
+
+ # binary constant
+ $x = 0b01010100011001010110110001110011010010010110000101101101;
+ is($x,
+ "23755414508757357",
+ "binary constant 0b0101010001100101011011000111"
+ . "0011010010010110000101101101");
+ is(ref($x), $class, "value is a $class");
+}
+
+################################################################################
+# The following tests are unique to $class.
+
+# These are handled by "float".
+
+$x = 0.999999999999999999999999999999999999999999999999999999999999999999999999;
+is($x,
+ "999999999999999999999999999999999999999999999999999999999999999999999999" .
+ "/1000000000000000000000000000000000000000000000000000000000000000000000000",
+ "decimal floating point literal 0." . ("9" x 72));
+is(ref($x), $class, "value is a $class");
+
+$x = 1e72 - 0.1;
+is($x,
+ "9999999999999999999999999999999999999999999999999999999999999999999999999"
+ . "/10",
+ "literal 1e72 - 0.1");
+is(ref($x), $class, "value is a $class");
+
+# These are handled by "float".
+
+SKIP: {
+ # Hexadecimal floating point literals require v5.28.0.
+ skip "perl v5.28.0 required for hexadecimal floating point literals",
+ "6" * "2" if $] < "5.028";
+
+ for my $str (qw/ 0x1.92p+1 0X1.92P+1
+ 0x1.92p1 0X1.92P1
+ 0x19.2p-3 0X19.2P-3 /)
+ {
+ $x = eval $str;
+ is($x, "201/64", "hexadecimal floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+}
+
+SKIP: {
+ # Octal floating point literals using the "0o" prefix require v5.34.0.
+ skip "perl v5.34.0 required for octal floating point literals"
+ . " with '0o' prefix", "6" * "2" if $] < "5.034";
+
+ for my $str (qw/ 0o1.444p+1 0O1.444P+1
+ 0o1.444p1 0O1.444P1
+ 0o14.44p-2 0O14.44P-2 /)
+ {
+ $x = eval $str;
+ is($x, "201/64", "octal floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+}
+
+SKIP: {
+ # Octal floating point literals using the "0" prefix require v5.32.0.
+ skip "perl v5.32.0 required for octal floating point literals",
+ "6" * "2" if $] < "5.032";
+
+ for my $str (qw/ 01.444p+1 01.444P+1
+ 01.444p1 01.444P1
+ 014.44p-2 014.44P-2 /)
+ {
+ $x = eval $str;
+ is($x, "201/64", "octal floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+}
+
+SKIP: {
+ # Binary floating point literals require v5.32.0.
+ skip "perl v5.32.0 required for binary floating point literals",
+ "6" * "2" if $] < "5.032";
+
+ for my $str (qw/ 0b1.1001001p+1 0B1.1001001P+1
+ 0b1.1001001p1 0B1.1001001P1
+ 0b110.01001p-1 0B110.01001P-1 /)
+ {
+ $x = eval $str;
+ is($x, "201/64", "binary floating point literal $str");
+ is(ref($x), $class, "value is a $class");
+ }
+}
+
+is(1.0 / 3.0, "1/3",
+ "1.0 / 3.0 = 1/3");
diff --git a/cpan/Math-BigRat/t/dparts-mbr.t b/cpan/Math-BigRat/t/dparts-mbr.t
new file mode 100644
index 0000000000..454bf59a0f
--- /dev/null
+++ b/cpan/Math-BigRat/t/dparts-mbr.t
@@ -0,0 +1,67 @@
+# -*- mode: perl; -*-
+
+use strict;
+use warnings;
+
+use Test::More tests => 17;
+
+my $class;
+
+BEGIN {
+ $class = 'Math::BigRat';
+ use_ok($class);
+}
+
+while (<DATA>) {
+ s/#.*$//; # remove comments
+ s/\s+$//; # remove trailing whitespace
+ next unless length; # skip empty lines
+
+ my ($x_str, $int_str, $frc_str) = split /:/;
+ my $test;
+
+ $test = qq|\$x = $class -> new("$x_str");|
+ . qq| (\$i, \$f) = \$x -> dparts();|;
+
+ subtest $test => sub {
+ plan tests => 5;
+
+ my $x = $class -> new($x_str);
+ my ($int_got, $frc_got) = $x -> dparts();
+
+ is(ref($int_got), $class, "class of integer part");
+ is(ref($frc_got), $class, "class of fraction part");
+
+ is($int_got, $int_str, "value of integer part");
+ is($frc_got, $frc_str, "value of fraction part");
+ is($x, $x_str, "input is unmodified");
+ };
+
+ $test = qq|\$x = $class -> new("$x_str");|
+ . qq| \$i = \$x -> dparts();|;
+
+ subtest $test => sub {
+ plan tests => 3,
+
+ my $x = $class -> new($x_str);
+ my $int_got = $x -> dparts();
+
+ isa_ok($int_got, $class);
+
+ is($int_got, $int_str, "value of integer part");
+ is($x, $x_str, "input is unmodified");
+ };
+}
+
+__DATA__
+
+NaN:NaN:NaN
+
+inf:inf:0
+-inf:-inf:0
+
+-9/4:-2:-1/4
+-1:-1:0
+0:0:0
+1:1:0
+9/4:2:1/4
diff --git a/cpan/Math-BigRat/t/hang.t b/cpan/Math-BigRat/t/hang.t
index 21b9304cbd..3e8637749e 100644
--- a/cpan/Math-BigRat/t/hang.t
+++ b/cpan/Math-BigRat/t/hang.t
@@ -1,4 +1,4 @@
-#!perl
+# -*- mode: perl; -*-
# test for bug #34584: hang in exp(1/2)
diff --git a/cpan/Math-BigRat/t/new-mbr.t b/cpan/Math-BigRat/t/new-mbr.t
index dad99428d1..24da7a8356 100644
--- a/cpan/Math-BigRat/t/new-mbr.t
+++ b/cpan/Math-BigRat/t/new-mbr.t
@@ -1,21 +1,25 @@
-#!perl
+# -*- mode: perl; -*-
use strict;
use warnings;
-use Test::More tests => 4;
-use Math::BigRat;
+use Test::More tests => 8;
+
+my $class;
+
+BEGIN { $class = 'Math::BigRat'; }
+BEGIN { use_ok($class); }
use Scalar::Util qw< refaddr >;
# CPAN RT #132712.
-my $q1 = Math::BigRat -> new("-1/2");
+my $q1 = $class -> new("-1/2");
my ($n, $d) = $q1 -> parts();
my $n_orig = $n -> copy();
my $d_orig = $d -> copy();
-my $q2 = Math::BigRat -> new($n, $d);
+my $q2 = $class -> new($n, $d);
cmp_ok($n, "==", $n_orig,
"The value of the numerator hasn't changed");
@@ -26,3 +30,39 @@ isnt(refaddr($n), refaddr($n_orig),
"The addresses of the numerators have changed");
isnt(refaddr($d), refaddr($d_orig),
"The addresses of the denominators have changed");
+
+# new()
+
+{
+ my $x = $class -> new();
+ subtest qq|\$x = $class -> new();|, => sub {
+ plan tests => 2;
+
+ is(ref($x), $class, "output arg is a $class");
+ is($x, "0", 'output arg has the right value');
+ };
+}
+
+# new("")
+
+{
+ my $x = $class -> new("");
+ subtest qq|\$x = $class -> new("");|, => sub {
+ plan tests => 2;
+
+ is(ref($x), $class, "output arg is a $class");
+ is($x, "NaN", 'output arg has the right value');
+ };
+}
+
+# new(undef)
+
+{
+ my $x = $class -> new(undef);
+ subtest qq|\$x = $class -> new(undef);|, => sub {
+ plan tests => 2;
+
+ is(ref($x), $class, "output arg is a $class");
+ is($x, "0", 'output arg has the right value');
+ };
+}
diff --git a/cpan/Math-BigRat/t/requirer.t b/cpan/Math-BigRat/t/requirer.t
index 6788783a29..4e2fadb969 100644
--- a/cpan/Math-BigRat/t/requirer.t
+++ b/cpan/Math-BigRat/t/requirer.t
@@ -1,4 +1,4 @@
-#!perl
+# -*- mode: perl; -*-
# check that simple requiring BigRat works
diff --git a/cpan/Math-BigRat/t/rt121139.t b/cpan/Math-BigRat/t/rt121139.t
index b0cd214ad3..97f28a9060 100644
--- a/cpan/Math-BigRat/t/rt121139.t
+++ b/cpan/Math-BigRat/t/rt121139.t
@@ -1,4 +1,4 @@
-#!perl
+# -*- mode: perl; -*-
# check for cpan rt #121139
diff --git a/cpan/Math-BigRat/t/trap.t b/cpan/Math-BigRat/t/trap.t
index bab85d4e5d..a61abb9b45 100644
--- a/cpan/Math-BigRat/t/trap.t
+++ b/cpan/Math-BigRat/t/trap.t
@@ -1,4 +1,4 @@
-#!perl
+# -*- mode: perl; -*-
# test that config( trap_nan => 1, trap_inf => 1) really works/dies