summaryrefslogtreecommitdiff
path: root/lib/Math/BigInt/t
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-02-19 21:17:10 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-02-19 21:17:10 +0000
commit9b924220109ab5ca4ffe2f23c240236dc5a723c2 (patch)
tree69c11d167bab8903a99a104bdf2a59ab8f7343b6 /lib/Math/BigInt/t
parentb6a15bc5202dd52395ce566b43e1490d38dc2141 (diff)
downloadperl-9b924220109ab5ca4ffe2f23c240236dc5a723c2.tar.gz
Upgrade to prereleases of Math::BigInt 1.70 and
Math::BigRat 0.12, by Tels. p4raw-id: //depot/perl@22344
Diffstat (limited to 'lib/Math/BigInt/t')
-rw-r--r--lib/Math/BigInt/t/bare_mbf.t2
-rw-r--r--lib/Math/BigInt/t/bare_mbi.t2
-rw-r--r--lib/Math/BigInt/t/bare_mif.t2
-rw-r--r--lib/Math/BigInt/t/bigfltpm.inc33
-rwxr-xr-xlib/Math/BigInt/t/bigfltpm.t4
-rw-r--r--lib/Math/BigInt/t/bigintc.t358
-rw-r--r--lib/Math/BigInt/t/bigintpm.inc36
-rwxr-xr-xlib/Math/BigInt/t/bigintpm.t2
-rw-r--r--lib/Math/BigInt/t/bigints.t67
-rw-r--r--lib/Math/BigInt/t/biglog.t11
-rw-r--r--lib/Math/BigInt/t/calling.t19
-rw-r--r--lib/Math/BigInt/t/config.t2
-rw-r--r--lib/Math/BigInt/t/mbimbf.inc24
-rw-r--r--lib/Math/BigInt/t/mbimbf.t7
-rw-r--r--lib/Math/BigInt/t/req_mbfw.t5
-rwxr-xr-xlib/Math/BigInt/t/sub_mbf.t2
-rwxr-xr-xlib/Math/BigInt/t/sub_mbi.t2
-rw-r--r--lib/Math/BigInt/t/sub_mif.t2
-rw-r--r--lib/Math/BigInt/t/upgrade.inc12
-rw-r--r--lib/Math/BigInt/t/upgrade.t2
-rw-r--r--lib/Math/BigInt/t/use_mbfw.t8
-rw-r--r--lib/Math/BigInt/t/with_sub.t5
22 files changed, 343 insertions, 264 deletions
diff --git a/lib/Math/BigInt/t/bare_mbf.t b/lib/Math/BigInt/t/bare_mbf.t
index 08ac4c2ad4..9f946717d2 100644
--- a/lib/Math/BigInt/t/bare_mbf.t
+++ b/lib/Math/BigInt/t/bare_mbf.t
@@ -27,7 +27,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 1772;
+ plan tests => 1814;
}
use Math::BigFloat lib => 'BareCalc';
diff --git a/lib/Math/BigInt/t/bare_mbi.t b/lib/Math/BigInt/t/bare_mbi.t
index 0cc055e2c2..6514e1ec43 100644
--- a/lib/Math/BigInt/t/bare_mbi.t
+++ b/lib/Math/BigInt/t/bare_mbi.t
@@ -26,7 +26,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 2770;
+ plan tests => 2832;
}
use Math::BigInt lib => 'BareCalc';
diff --git a/lib/Math/BigInt/t/bare_mif.t b/lib/Math/BigInt/t/bare_mif.t
index 00629fd9a5..0cc1de9365 100644
--- a/lib/Math/BigInt/t/bare_mif.t
+++ b/lib/Math/BigInt/t/bare_mif.t
@@ -28,7 +28,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 679
+ plan tests => 684
+ 1; # our own tests
}
diff --git a/lib/Math/BigInt/t/bigfltpm.inc b/lib/Math/BigInt/t/bigfltpm.inc
index 34d264a911..d307ee6a27 100644
--- a/lib/Math/BigInt/t/bigfltpm.inc
+++ b/lib/Math/BigInt/t/bigfltpm.inc
@@ -30,7 +30,7 @@ while (<DATA>)
{
@args = split(/:/,$_,99); $ans = pop(@args);
}
- $try = "\$x = $class->new('$args[0]');";
+ $try = "\$x = $class->new(\"$args[0]\");";
if ($f eq "fnorm")
{
$try .= "\$x;";
@@ -142,7 +142,7 @@ while (<DATA>)
# trailing zeros
#print $ans1->_trailing_zeros(),"\n";
print "# Has trailing zeros after '$try'\n"
- if !ok ($ans1->{_m}->_trailing_zeros(), 0);
+ if !ok ($CL->_zeros( $ans1->{_m}), 0);
}
}
} # end pattern or string
@@ -165,9 +165,11 @@ ok ($y,1200); ok ($x,1200);
my $monster = '1e1234567890123456789012345678901234567890';
-# new
+# new and exponent
ok ($class->new($monster)->bsstr(),
'1e+1234567890123456789012345678901234567890');
+ok ($class->new($monster)->exponent(),
+ '1234567890123456789012345678901234567890');
# cmp
ok ($class->new($monster) > 0,1);
@@ -176,6 +178,11 @@ ok ($class->new($monster)->bsub( $monster),0);
ok ($class->new($monster)->bmul(2)->bsstr(),
'2e+1234567890123456789012345678901234567890');
+# mantissa
+$monster = '1234567890123456789012345678901234567890e2';
+ok ($class->new($monster)->mantissa(),
+ '123456789012345678901234567890123456789');
+
###############################################################################
# zero,inf,one,nan
@@ -476,6 +483,18 @@ abc:NaN
-3e111:-3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-4e-1111:-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004
&fpow
+NaN:1:NaN
+1:NaN:NaN
+NaN:-1:NaN
+-1:NaN:NaN
+NaN:-21:NaN
+-21:NaN:NaN
+NaN:21:NaN
+21:NaN:NaN
+0:0:1
+0:1:0
+0:9:0
+0:-2:inf
2:2:4
1:2:1
1:3:1
@@ -491,6 +510,14 @@ abc:123.456:NaN
-inf:123.45:-inf
+inf:-123.45:inf
-inf:-123.45:-inf
+-2:2:4
+-2:3:-8
+-2:4:16
+-2:5:-32
+-3:2:9
+-3:3:-27
+-3:4:81
+-3:5:-243
# 2 ** 0.5 == sqrt(2)
# 1.41..7 and not 1.4170 since fallback (bsqrt(9) is '3', not 3.0...0)
2:0.5:1.41421356237309504880168872420969807857
diff --git a/lib/Math/BigInt/t/bigfltpm.t b/lib/Math/BigInt/t/bigfltpm.t
index 84741bad23..3fce4605b3 100755
--- a/lib/Math/BigInt/t/bigfltpm.t
+++ b/lib/Math/BigInt/t/bigfltpm.t
@@ -26,7 +26,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 1772
+ plan tests => 1814
+ 2; # own tests
}
@@ -38,6 +38,6 @@ $class = "Math::BigFloat";
$CL = "Math::BigInt::Calc";
ok ($class->config()->{class},$class);
-ok ($class->config()->{with},'Math::BigInt');
+ok ($class->config()->{with}, $CL);
require 'bigfltpm.inc'; # all tests here for sharing
diff --git a/lib/Math/BigInt/t/bigintc.t b/lib/Math/BigInt/t/bigintc.t
index 1f0804cf9c..f0aa66dea0 100644
--- a/lib/Math/BigInt/t/bigintc.t
+++ b/lib/Math/BigInt/t/bigintc.t
@@ -8,15 +8,11 @@ BEGIN
$| = 1;
chdir 't' if -d 't';
unshift @INC, '../lib'; # for running manually
+ plan tests => 308;
}
use Math::BigInt::Calc;
-BEGIN
- {
- plan tests => 300;
- }
-
my ($BASE_LEN, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN_SMALL, $MAX_VAL) =
Math::BigInt::Calc->_base_len();
@@ -31,52 +27,59 @@ print "# IOR_BITS = $OR_BITS\n";
my $C = 'Math::BigInt::Calc'; # pass classname to sub's
# _new and _str
-my $x = $C->_new(\"123"); my $y = $C->_new(\"321");
-ok (ref($x),'ARRAY'); ok (${$C->_str($x)},123); ok (${$C->_str($y)},321);
+my $x = $C->_new("123"); my $y = $C->_new("321");
+ok (ref($x),'ARRAY'); ok ($C->_str($x),123); ok ($C->_str($y),321);
###############################################################################
# _add, _sub, _mul, _div
-ok (${$C->_str($C->_add($x,$y))},444);
-ok (${$C->_str($C->_sub($x,$y))},123);
-ok (${$C->_str($C->_mul($x,$y))},39483);
-ok (${$C->_str($C->_div($x,$y))},123);
+ok ($C->_str($C->_add($x,$y)),444);
+ok ($C->_str($C->_sub($x,$y)),123);
+ok ($C->_str($C->_mul($x,$y)),39483);
+ok ($C->_str($C->_div($x,$y)),123);
###############################################################################
# check that mul/div doesn't change $y
# and returns the same reference, not something new
-ok (${$C->_str($C->_mul($x,$y))},39483);
-ok (${$C->_str($x)},39483); ok (${$C->_str($y)},321);
+ok ($C->_str($C->_mul($x,$y)),39483);
+ok ($C->_str($x),39483); ok ($C->_str($y),321);
-ok (${$C->_str($C->_div($x,$y))},123);
-ok (${$C->_str($x)},123); ok (${$C->_str($y)},321);
+ok ($C->_str($C->_div($x,$y)),123);
+ok ($C->_str($x),123); ok ($C->_str($y),321);
-$x = $C->_new(\"39483");
+$x = $C->_new("39483");
my ($x1,$r1) = $C->_div($x,$y);
ok ("$x1","$x");
$C->_inc($x1);
ok ("$x1","$x");
-ok (${$C->_str($r1)},'0');
+ok ($C->_str($r1),'0');
-$x = $C->_new(\"39483"); # reset
+$x = $C->_new("39483"); # reset
###############################################################################
-my $z = $C->_new(\"2");
-ok (${$C->_str($C->_add($x,$z))},39485);
+my $z = $C->_new("2");
+ok ($C->_str($C->_add($x,$z)),39485);
my ($re,$rr) = $C->_div($x,$y);
-ok (${$C->_str($re)},123); ok (${$C->_str($rr)},2);
+ok ($C->_str($re),123); ok ($C->_str($rr),2);
# is_zero, _is_one, _one, _zero
ok ($C->_is_zero($x)||0,0);
ok ($C->_is_one($x)||0,0);
-ok (${$C->_str($C->_zero())},"0");
-ok (${$C->_str($C->_one())},"1");
+ok ($C->_str($C->_zero()),"0");
+ok ($C->_str($C->_one()),"1");
-# _two() (only used internally)
-ok (${$C->_str($C->_two())},"2");
+# _two() and _ten()
+ok ($C->_str($C->_two()),"2");
+ok ($C->_str($C->_ten()),"10");
+ok ($C->_is_ten($C->_two()),0);
+ok ($C->_is_two($C->_two()),1);
+ok ($C->_is_ten($C->_ten()),1);
+ok ($C->_is_two($C->_ten()),0);
ok ($C->_is_one($C->_one()),1);
+ok ($C->_is_one($C->_two()),0);
+ok ($C->_is_one($C->_ten()),0);
ok ($C->_is_one($C->_zero()) || 0,0);
@@ -89,35 +92,35 @@ ok ($C->_is_odd($C->_one()),1); ok ($C->_is_odd($C->_zero())||0,0);
ok ($C->_is_even($C->_one()) || 0,0); ok ($C->_is_even($C->_zero()),1);
# _len
-$x = $C->_new(\"1"); ok ($C->_len($x),1);
-$x = $C->_new(\"12"); ok ($C->_len($x),2);
-$x = $C->_new(\"123"); ok ($C->_len($x),3);
-$x = $C->_new(\"1234"); ok ($C->_len($x),4);
-$x = $C->_new(\"12345"); ok ($C->_len($x),5);
-$x = $C->_new(\"123456"); ok ($C->_len($x),6);
-$x = $C->_new(\"1234567"); ok ($C->_len($x),7);
-$x = $C->_new(\"12345678"); ok ($C->_len($x),8);
-$x = $C->_new(\"123456789"); ok ($C->_len($x),9);
-
-$x = $C->_new(\"8"); ok ($C->_len($x),1);
-$x = $C->_new(\"21"); ok ($C->_len($x),2);
-$x = $C->_new(\"321"); ok ($C->_len($x),3);
-$x = $C->_new(\"4321"); ok ($C->_len($x),4);
-$x = $C->_new(\"54321"); ok ($C->_len($x),5);
-$x = $C->_new(\"654321"); ok ($C->_len($x),6);
-$x = $C->_new(\"7654321"); ok ($C->_len($x),7);
-$x = $C->_new(\"87654321"); ok ($C->_len($x),8);
-$x = $C->_new(\"987654321"); ok ($C->_len($x),9);
+$x = $C->_new("1"); ok ($C->_len($x),1);
+$x = $C->_new("12"); ok ($C->_len($x),2);
+$x = $C->_new("123"); ok ($C->_len($x),3);
+$x = $C->_new("1234"); ok ($C->_len($x),4);
+$x = $C->_new("12345"); ok ($C->_len($x),5);
+$x = $C->_new("123456"); ok ($C->_len($x),6);
+$x = $C->_new("1234567"); ok ($C->_len($x),7);
+$x = $C->_new("12345678"); ok ($C->_len($x),8);
+$x = $C->_new("123456789"); ok ($C->_len($x),9);
+
+$x = $C->_new("8"); ok ($C->_len($x),1);
+$x = $C->_new("21"); ok ($C->_len($x),2);
+$x = $C->_new("321"); ok ($C->_len($x),3);
+$x = $C->_new("4321"); ok ($C->_len($x),4);
+$x = $C->_new("54321"); ok ($C->_len($x),5);
+$x = $C->_new("654321"); ok ($C->_len($x),6);
+$x = $C->_new("7654321"); ok ($C->_len($x),7);
+$x = $C->_new("87654321"); ok ($C->_len($x),8);
+$x = $C->_new("987654321"); ok ($C->_len($x),9);
for (my $i = 1; $i < 9; $i++)
{
my $a = "$i" . '0' x ($i-1);
- $x = $C->_new(\$a);
+ $x = $C->_new($a);
print "# Tried len '$a'\n" unless ok ($C->_len($x),$i);
}
# _digit
-$x = $C->_new(\"123456789");
+$x = $C->_new("123456789");
ok ($C->_digit($x,0),9);
ok ($C->_digit($x,1),8);
ok ($C->_digit($x,2),7);
@@ -128,201 +131,202 @@ ok ($C->_digit($x,-3),3);
# _copy
foreach (qw/ 1 12 123 1234 12345 123456 1234567 12345678 123456789/)
{
- $x = $C->_new(\"$_");
- ok (${$C->_str($C->_copy($x))},"$_");
- ok (${$C->_str($x)},"$_"); # did _copy destroy original x?
+ $x = $C->_new("$_");
+ ok ($C->_str($C->_copy($x)),"$_");
+ ok ($C->_str($x),"$_"); # did _copy destroy original x?
}
# _zeros
-$x = $C->_new(\"1256000000"); ok ($C->_zeros($x),6);
-$x = $C->_new(\"152"); ok ($C->_zeros($x),0);
-$x = $C->_new(\"123000"); ok ($C->_zeros($x),3);
+$x = $C->_new("1256000000"); ok ($C->_zeros($x),6);
+$x = $C->_new("152"); ok ($C->_zeros($x),0);
+$x = $C->_new("123000"); ok ($C->_zeros($x),3);
+$x = $C->_new("0"); ok ($C->_zeros($x),0);
# _lsft, _rsft
-$x = $C->_new(\"10"); $y = $C->_new(\"3");
-ok (${$C->_str($C->_lsft($x,$y,10))},10000);
-$x = $C->_new(\"20"); $y = $C->_new(\"3");
-ok (${$C->_str($C->_lsft($x,$y,10))},20000);
+$x = $C->_new("10"); $y = $C->_new("3");
+ok ($C->_str($C->_lsft($x,$y,10)),10000);
+$x = $C->_new("20"); $y = $C->_new("3");
+ok ($C->_str($C->_lsft($x,$y,10)),20000);
-$x = $C->_new(\"128"); $y = $C->_new(\"4");
-ok (${$C->_str($C->_lsft($x,$y,2))}, 128 << 4);
+$x = $C->_new("128"); $y = $C->_new("4");
+ok ($C->_str($C->_lsft($x,$y,2)), 128 << 4);
-$x = $C->_new(\"1000"); $y = $C->_new(\"3");
-ok (${$C->_str($C->_rsft($x,$y,10))},1);
-$x = $C->_new(\"20000"); $y = $C->_new(\"3");
-ok (${$C->_str($C->_rsft($x,$y,10))},20);
-$x = $C->_new(\"256"); $y = $C->_new(\"4");
-ok (${$C->_str($C->_rsft($x,$y,2))},256 >> 4);
+$x = $C->_new("1000"); $y = $C->_new("3");
+ok ($C->_str($C->_rsft($x,$y,10)),1);
+$x = $C->_new("20000"); $y = $C->_new("3");
+ok ($C->_str($C->_rsft($x,$y,10)),20);
+$x = $C->_new("256"); $y = $C->_new("4");
+ok ($C->_str($C->_rsft($x,$y,2)),256 >> 4);
-$x = $C->_new(\"6411906467305339182857313397200584952398");
-$y = $C->_new(\"45");
-ok (${$C->_str($C->_rsft($x,$y,10))},0);
+$x = $C->_new("6411906467305339182857313397200584952398");
+$y = $C->_new("45");
+ok ($C->_str($C->_rsft($x,$y,10)),0);
# _acmp
-$x = $C->_new(\"123456789");
-$y = $C->_new(\"987654321");
+$x = $C->_new("123456789");
+$y = $C->_new("987654321");
ok ($C->_acmp($x,$y),-1);
ok ($C->_acmp($y,$x),1);
ok ($C->_acmp($x,$x),0);
ok ($C->_acmp($y,$y),0);
-$x = $C->_new(\"12");
-$y = $C->_new(\"12");
+$x = $C->_new("12");
+$y = $C->_new("12");
ok ($C->_acmp($x,$y),0);
-$x = $C->_new(\"21");
+$x = $C->_new("21");
ok ($C->_acmp($x,$y),1);
ok ($C->_acmp($y,$x),-1);
-$x = $C->_new(\"123456789");
-$y = $C->_new(\"1987654321");
+$x = $C->_new("123456789");
+$y = $C->_new("1987654321");
ok ($C->_acmp($x,$y),-1);
ok ($C->_acmp($y,$x),+1);
-$x = $C->_new(\"1234567890123456789");
-$y = $C->_new(\"987654321012345678");
+$x = $C->_new("1234567890123456789");
+$y = $C->_new("987654321012345678");
ok ($C->_acmp($x,$y),1);
ok ($C->_acmp($y,$x),-1);
ok ($C->_acmp($x,$x),0);
ok ($C->_acmp($y,$y),0);
-$x = $C->_new(\"1234");
-$y = $C->_new(\"987654321012345678");
+$x = $C->_new("1234");
+$y = $C->_new("987654321012345678");
ok ($C->_acmp($x,$y),-1);
ok ($C->_acmp($y,$x),1);
ok ($C->_acmp($x,$x),0);
ok ($C->_acmp($y,$y),0);
# _modinv
-$x = $C->_new(\"8");
-$y = $C->_new(\"5033");
+$x = $C->_new("8");
+$y = $C->_new("5033");
my ($xmod,$sign) = $C->_modinv($x,$y);
-ok (${$C->_str($xmod)},'629'); # -629 % 5033 == 4404
+ok ($C->_str($xmod),'629'); # -629 % 5033 == 4404
ok ($sign, '-');
# _div
-$x = $C->_new(\"3333"); $y = $C->_new(\"1111");
-ok (${$C->_str(scalar $C->_div($x,$y))},3);
-$x = $C->_new(\"33333"); $y = $C->_new(\"1111"); ($x,$y) = $C->_div($x,$y);
-ok (${$C->_str($x)},30); ok (${$C->_str($y)},3);
-$x = $C->_new(\"123"); $y = $C->_new(\"1111");
-($x,$y) = $C->_div($x,$y); ok (${$C->_str($x)},0); ok (${$C->_str($y)},123);
+$x = $C->_new("3333"); $y = $C->_new("1111");
+ok ($C->_str(scalar $C->_div($x,$y)),3);
+$x = $C->_new("33333"); $y = $C->_new("1111"); ($x,$y) = $C->_div($x,$y);
+ok ($C->_str($x),30); ok ($C->_str($y),3);
+$x = $C->_new("123"); $y = $C->_new("1111");
+($x,$y) = $C->_div($x,$y); ok ($C->_str($x),0); ok ($C->_str($y),123);
# _num
foreach (qw/1 12 123 1234 12345 1234567 12345678 123456789 1234567890/)
{
- $x = $C->_new(\"$_");
- ok (ref($x)||'','ARRAY'); ok (${$C->_str($x)},"$_");
+ $x = $C->_new("$_");
+ ok (ref($x)||'','ARRAY'); ok ($C->_str($x),"$_");
$x = $C->_num($x); ok (ref($x)||'',''); ok ($x,$_);
}
# _sqrt
-$x = $C->_new(\"144"); ok (${$C->_str($C->_sqrt($x))},'12');
-$x = $C->_new(\"144000000000000"); ok (${$C->_str($C->_sqrt($x))},'12000000');
+$x = $C->_new("144"); ok ($C->_str($C->_sqrt($x)),'12');
+$x = $C->_new("144000000000000"); ok ($C->_str($C->_sqrt($x)),'12000000');
# _root
-$x = $C->_new(\"81"); my $n = $C->_new(\"3"); # 4*4*4 = 64, 5*5*5 = 125
-ok (${$C->_str($C->_root($x,$n))},'4'); # 4.xx => 4.0
-$x = $C->_new(\"81"); $n = $C->_new(\"4"); # 3*3*3*3 == 81
-ok (${$C->_str($C->_root($x,$n))},'3');
+$x = $C->_new("81"); my $n = $C->_new("3"); # 4*4*4 = 64, 5*5*5 = 125
+ok ($C->_str($C->_root($x,$n)),'4'); # 4.xx => 4.0
+$x = $C->_new("81"); $n = $C->_new("4"); # 3*3*3*3 == 81
+ok ($C->_str($C->_root($x,$n)),'3');
# _pow (and _root)
-$x = $C->_new(\"0"); $n = $C->_new(\"3"); # 0 ** y => 0
-ok (${$C->_str($C->_pow($x,$n))}, 0);
-$x = $C->_new(\"3"); $n = $C->_new(\"0"); # x ** 0 => 1
-ok (${$C->_str($C->_pow($x,$n))}, 1);
-$x = $C->_new(\"1"); $n = $C->_new(\"3"); # 1 ** y => 1
-ok (${$C->_str($C->_pow($x,$n))}, 1);
-$x = $C->_new(\"5"); $n = $C->_new(\"1"); # x ** 1 => x
-ok (${$C->_str($C->_pow($x,$n))}, 5);
+$x = $C->_new("0"); $n = $C->_new("3"); # 0 ** y => 0
+ok ($C->_str($C->_pow($x,$n)), 0);
+$x = $C->_new("3"); $n = $C->_new("0"); # x ** 0 => 1
+ok ($C->_str($C->_pow($x,$n)), 1);
+$x = $C->_new("1"); $n = $C->_new("3"); # 1 ** y => 1
+ok ($C->_str($C->_pow($x,$n)), 1);
+$x = $C->_new("5"); $n = $C->_new("1"); # x ** 1 => x
+ok ($C->_str($C->_pow($x,$n)), 5);
-$x = $C->_new(\"81"); $n = $C->_new(\"3"); # 81 ** 3 == 531441
-ok (${$C->_str($C->_pow($x,$n))},81 ** 3);
+$x = $C->_new("81"); $n = $C->_new("3"); # 81 ** 3 == 531441
+ok ($C->_str($C->_pow($x,$n)),81 ** 3);
-ok (${$C->_str($C->_root($x,$n))},81);
+ok ($C->_str($C->_root($x,$n)),81);
-$x = $C->_new(\"81");
-ok (${$C->_str($C->_pow($x,$n))},81 ** 3);
-ok (${$C->_str($C->_pow($x,$n))},'150094635296999121'); # 531441 ** 3 ==
+$x = $C->_new("81");
+ok ($C->_str($C->_pow($x,$n)),81 ** 3);
+ok ($C->_str($C->_pow($x,$n)),'150094635296999121'); # 531441 ** 3 ==
-ok (${$C->_str($C->_root($x,$n))},'531441');
-ok (${$C->_str($C->_root($x,$n))},'81');
+ok ($C->_str($C->_root($x,$n)),'531441');
+ok ($C->_str($C->_root($x,$n)),'81');
-$x = $C->_new(\"81"); $n = $C->_new(\"14");
-ok (${$C->_str($C->_pow($x,$n))},'523347633027360537213511521');
-ok (${$C->_str($C->_root($x,$n))},'81');
+$x = $C->_new("81"); $n = $C->_new("14");
+ok ($C->_str($C->_pow($x,$n)),'523347633027360537213511521');
+ok ($C->_str($C->_root($x,$n)),'81');
-$x = $C->_new(\"523347633027360537213511520");
-ok (${$C->_str($C->_root($x,$n))},'80');
+$x = $C->_new("523347633027360537213511520");
+ok ($C->_str($C->_root($x,$n)),'80');
-$x = $C->_new(\"523347633027360537213511522");
-ok (${$C->_str($C->_root($x,$n))},'81');
+$x = $C->_new("523347633027360537213511522");
+ok ($C->_str($C->_root($x,$n)),'81');
my $res = [ qw/ 9 31 99 316 999 3162 9999/ ];
# 99 ** 2 = 9801, 999 ** 2 = 998001 etc
for my $i (2 .. 9)
{
- $x = '9' x $i; $x = $C->_new(\$x);
- $n = $C->_new(\"2");
+ $x = '9' x $i; $x = $C->_new($x);
+ $n = $C->_new("2");
my $rc = '9' x ($i-1). '8' . '0' x ($i-1) . '1';
print "# _pow( ", '9' x $i, ", 2) \n" unless
- ok (${$C->_str($C->_pow($x,$n))},$rc);
+ ok ($C->_str($C->_pow($x,$n)),$rc);
if ($i <= 7)
{
- $x = '9' x $i; $x = $C->_new(\$x);
- $n = '9' x $i; $n = $C->_new(\$n);
+ $x = '9' x $i; $x = $C->_new($x);
+ $n = '9' x $i; $n = $C->_new($n);
print "# _root( ", '9' x $i, ", ", 9 x $i, ") \n" unless
- ok (${$C->_str($C->_root($x,$n))},'1');
+ ok ($C->_str($C->_root($x,$n)),'1');
- $x = '9' x $i; $x = $C->_new(\$x);
- $n = $C->_new(\"2");
+ $x = '9' x $i; $x = $C->_new($x);
+ $n = $C->_new("2");
print "# _root( ", '9' x $i, ", ", 9 x $i, ") \n" unless
- ok (${$C->_str($C->_root($x,$n))}, $res->[$i-2]);
+ ok ($C->_str($C->_root($x,$n)), $res->[$i-2]);
}
}
##############################################################################
# _fac
-$x = $C->_new(\"0"); ok (${$C->_str($C->_fac($x))},'1');
-$x = $C->_new(\"1"); ok (${$C->_str($C->_fac($x))},'1');
-$x = $C->_new(\"2"); ok (${$C->_str($C->_fac($x))},'2');
-$x = $C->_new(\"3"); ok (${$C->_str($C->_fac($x))},'6');
-$x = $C->_new(\"4"); ok (${$C->_str($C->_fac($x))},'24');
-$x = $C->_new(\"5"); ok (${$C->_str($C->_fac($x))},'120');
-$x = $C->_new(\"10"); ok (${$C->_str($C->_fac($x))},'3628800');
-$x = $C->_new(\"11"); ok (${$C->_str($C->_fac($x))},'39916800');
-$x = $C->_new(\"12"); ok (${$C->_str($C->_fac($x))},'479001600');
-$x = $C->_new(\"13"); ok (${$C->_str($C->_fac($x))},'6227020800');
+$x = $C->_new("0"); ok ($C->_str($C->_fac($x)),'1');
+$x = $C->_new("1"); ok ($C->_str($C->_fac($x)),'1');
+$x = $C->_new("2"); ok ($C->_str($C->_fac($x)),'2');
+$x = $C->_new("3"); ok ($C->_str($C->_fac($x)),'6');
+$x = $C->_new("4"); ok ($C->_str($C->_fac($x)),'24');
+$x = $C->_new("5"); ok ($C->_str($C->_fac($x)),'120');
+$x = $C->_new("10"); ok ($C->_str($C->_fac($x)),'3628800');
+$x = $C->_new("11"); ok ($C->_str($C->_fac($x)),'39916800');
+$x = $C->_new("12"); ok ($C->_str($C->_fac($x)),'479001600');
+$x = $C->_new("13"); ok ($C->_str($C->_fac($x)),'6227020800');
# test that _fac modifes $x in place for small arguments
-$x = $C->_new(\"3"); $C->_fac($x); ok (${$C->_str($x)},'6');
-$x = $C->_new(\"13"); $C->_fac($x); ok (${$C->_str($x)},'6227020800');
+$x = $C->_new("3"); $C->_fac($x); ok ($C->_str($x),'6');
+$x = $C->_new("13"); $C->_fac($x); ok ($C->_str($x),'6227020800');
##############################################################################
# _inc and _dec
foreach (qw/1 11 121 1231 12341 1234561 12345671 123456781 1234567891/)
{
- $x = $C->_new(\"$_"); $C->_inc($x);
- print "# \$x = ",${$C->_str($x)},"\n"
- unless ok (${$C->_str($x)},substr($_,0,length($_)-1) . '2');
- $C->_dec($x); ok (${$C->_str($x)},$_);
+ $x = $C->_new("$_"); $C->_inc($x);
+ print "# \$x = ",$C->_str($x),"\n"
+ unless ok ($C->_str($x),substr($_,0,length($_)-1) . '2');
+ $C->_dec($x); ok ($C->_str($x),$_);
}
foreach (qw/19 119 1219 12319 1234519 12345619 123456719 1234567819/)
{
- $x = $C->_new(\"$_"); $C->_inc($x);
- print "# \$x = ",${$C->_str($x)},"\n"
- unless ok (${$C->_str($x)},substr($_,0,length($_)-2) . '20');
- $C->_dec($x); ok (${$C->_str($x)},$_);
+ $x = $C->_new("$_"); $C->_inc($x);
+ print "# \$x = ",$C->_str($x),"\n"
+ unless ok ($C->_str($x),substr($_,0,length($_)-2) . '20');
+ $C->_dec($x); ok ($C->_str($x),$_);
}
foreach (qw/999 9999 99999 9999999 99999999 999999999 9999999999 99999999999/)
{
- $x = $C->_new(\"$_"); $C->_inc($x);
- print "# \$x = ",${$C->_str($x)},"\n"
- unless ok (${$C->_str($x)}, '1' . '0' x (length($_)));
- $C->_dec($x); ok (${$C->_str($x)},$_);
+ $x = $C->_new("$_"); $C->_inc($x);
+ print "# \$x = ",$C->_str($x),"\n"
+ unless ok ($C->_str($x), '1' . '0' x (length($_)));
+ $C->_dec($x); ok ($C->_str($x),$_);
}
-$x = $C->_new(\"1000"); $C->_inc($x); ok (${$C->_str($x)},'1001');
-$C->_dec($x); ok (${$C->_str($x)},'1000');
+$x = $C->_new("1000"); $C->_inc($x); ok ($C->_str($x),'1001');
+$C->_dec($x); ok ($C->_str($x),'1000');
my $BL;
{
@@ -332,45 +336,45 @@ my $BL;
$x = '1' . '0' x $BL;
$z = '1' . '0' x ($BL-1); $z .= '1';
-$x = $C->_new(\$x); $C->_inc($x); ok (${$C->_str($x)},$z);
+$x = $C->_new($x); $C->_inc($x); ok ($C->_str($x),$z);
$x = '1' . '0' x $BL; $z = '9' x $BL;
-$x = $C->_new(\$x); $C->_dec($x); ok (${$C->_str($x)},$z);
+$x = $C->_new($x); $C->_dec($x); ok ($C->_str($x),$z);
# should not happen:
-# $x = $C->_new(\"-2"); $y = $C->_new(\"4"); ok ($C->_acmp($x,$y),-1);
+# $x = $C->_new("-2"); $y = $C->_new("4"); ok ($C->_acmp($x,$y),-1);
###############################################################################
# _mod
-$x = $C->_new(\"1000"); $y = $C->_new(\"3");
-ok (${$C->_str(scalar $C->_mod($x,$y))},1);
-$x = $C->_new(\"1000"); $y = $C->_new(\"2");
-ok (${$C->_str(scalar $C->_mod($x,$y))},0);
+$x = $C->_new("1000"); $y = $C->_new("3");
+ok ($C->_str(scalar $C->_mod($x,$y)),1);
+$x = $C->_new("1000"); $y = $C->_new("2");
+ok ($C->_str(scalar $C->_mod($x,$y)),0);
# _and, _or, _xor
-$x = $C->_new(\"5"); $y = $C->_new(\"2");
-ok (${$C->_str(scalar $C->_xor($x,$y))},7);
-$x = $C->_new(\"5"); $y = $C->_new(\"2");
-ok (${$C->_str(scalar $C->_or($x,$y))},7);
-$x = $C->_new(\"5"); $y = $C->_new(\"3");
-ok (${$C->_str(scalar $C->_and($x,$y))},1);
+$x = $C->_new("5"); $y = $C->_new("2");
+ok ($C->_str(scalar $C->_xor($x,$y)),7);
+$x = $C->_new("5"); $y = $C->_new("2");
+ok ($C->_str(scalar $C->_or($x,$y)),7);
+$x = $C->_new("5"); $y = $C->_new("3");
+ok ($C->_str(scalar $C->_and($x,$y)),1);
# _from_hex, _from_bin
-ok (${$C->_str(scalar $C->_from_hex(\"0xFf"))},255);
-ok (${$C->_str(scalar $C->_from_bin(\"0b10101011"))},160+11);
+ok ($C->_str( $C->_from_hex("0xFf")),255);
+ok ($C->_str( $C->_from_bin("0b10101011")),160+11);
# _as_hex, _as_bin
-ok (${$C->_str(scalar $C->_from_hex( $C->_as_hex( $C->_new(\"128"))))}, 128);
-ok (${$C->_str(scalar $C->_from_bin( $C->_as_bin( $C->_new(\"128"))))}, 128);
-ok (${$C->_str(scalar $C->_from_hex( $C->_as_hex( $C->_new(\"0"))))}, 0);
-ok (${$C->_str(scalar $C->_from_bin( $C->_as_bin( $C->_new(\"0"))))}, 0);
-ok ( ${$C->_as_hex( $C->_new(\"0"))}, '0x0');
-ok ( ${$C->_as_bin( $C->_new(\"0"))}, '0b0');
-ok ( ${$C->_as_hex( $C->_new(\"12"))}, '0xc');
-ok ( ${$C->_as_bin( $C->_new(\"12"))}, '0b1100');
+ok ($C->_str( $C->_from_hex( $C->_as_hex( $C->_new("128")))), 128);
+ok ($C->_str( $C->_from_bin( $C->_as_bin( $C->_new("128")))), 128);
+ok ($C->_str( $C->_from_hex( $C->_as_hex( $C->_new("0")))), 0);
+ok ($C->_str( $C->_from_bin( $C->_as_bin( $C->_new("0")))), 0);
+ok ($C->_as_hex( $C->_new("0")), '0x0');
+ok ($C->_as_bin( $C->_new("0")), '0b0');
+ok ($C->_as_hex( $C->_new("12")), '0xc');
+ok ($C->_as_bin( $C->_new("12")), '0b1100');
# _check
-$x = $C->_new(\"123456789");
+$x = $C->_new("123456789");
ok ($C->_check($x),0);
ok ($C->_check(123),'123 is not a reference');
diff --git a/lib/Math/BigInt/t/bigintpm.inc b/lib/Math/BigInt/t/bigintpm.inc
index 4e526676b8..cdefea633a 100644
--- a/lib/Math/BigInt/t/bigintpm.inc
+++ b/lib/Math/BigInt/t/bigintpm.inc
@@ -1683,6 +1683,13 @@ abc:1:abc:NaN
111111111111111111111111111111:111111111111111111111111111111:0
12345678901234567890:12345678901234567890:0
&bgcd
+inf:12:NaN
+-inf:12:NaN
+12:inf:NaN
+12:-inf:NaN
+inf:inf:NaN
+inf:-inf:NaN
+-inf:-inf:NaN
abc:abc:NaN
abc:+0:NaN
+0:abc:NaN
@@ -1693,6 +1700,10 @@ abc:+0:NaN
+2:+3:1
+3:+2:1
-3:+2:1
+-3:-2:1
+-144:-60:12
+144:-60:12
+144:60:12
100:625:25
4096:81:1
1034:804:2
@@ -1717,12 +1728,16 @@ abc:0:NaN
+281474976710656:0:0
+281474976710656:1:0
+281474976710656:+281474976710656:281474976710656
+281474976710656:-1:281474976710656
-2:-3:-4
-1:-1:-1
-6:-6:-6
-7:-4:-8
-7:4:0
-4:7:4
+# negative argument is bitwise shorter than positive [perl #26559]
+30:-3:28
+123:-1:123
# equal arguments are treated special, so also do some test with unequal ones
0xFFFF:0xFFFF:0x0xFFFF
0xFFFFFF:0xFFFFFF:0x0xFFFFFF
@@ -1754,6 +1769,11 @@ abc:0:NaN
-6:-6:-6
-7:4:-3
-4:7:-1
++281474976710656:-1:-1
+30:-3:-1
+30:-4:-2
+300:-76:-68
+-76:300:-68
# equal arguments are treated special, so also do some test with unequal ones
0xFFFF:0xFFFF:0x0xFFFF
0xFFFFFF:0xFFFFFF:0x0xFFFFFF
@@ -1802,6 +1822,10 @@ abc:0:NaN
-4:7:-5
4:-7:-3
-4:-7:5
+30:-3:-29
+30:-4:-30
+300:-76:-360
+-76:300:-360
# equal arguments are treated special, so also do some test with unequal ones
0xFFFF:0xFFFF:0
0xFFFFFF:0xFFFFFF:0
@@ -1916,8 +1940,8 @@ abc:12:NaN
0:0:1
0:1:0
0:2:0
-0:-1:NaN
-0:-2:NaN
+0:-1:inf
+0:-2:inf
1:0:1
1:1:1
1:2:1
@@ -1960,6 +1984,14 @@ abc:12:NaN
10:9:1000000000
10:20:100000000000000000000
123456:2:15241383936
+-2:2:4
+-2:3:-8
+-2:4:16
+-2:5:-32
+-3:2:9
+-3:3:-27
+-3:4:81
+-3:5:-243
&length
100:3
10:2
diff --git a/lib/Math/BigInt/t/bigintpm.t b/lib/Math/BigInt/t/bigintpm.t
index 0ffa4a298a..50fca1dbf1 100755
--- a/lib/Math/BigInt/t/bigintpm.t
+++ b/lib/Math/BigInt/t/bigintpm.t
@@ -10,7 +10,7 @@ BEGIN
my $location = $0; $location =~ s/bigintpm.t//;
unshift @INC, $location; # to locate the testing files
chdir 't' if -d 't';
- plan tests => 2770;
+ plan tests => 2832;
}
use Math::BigInt;
diff --git a/lib/Math/BigInt/t/bigints.t b/lib/Math/BigInt/t/bigints.t
index 6b21a75487..de073e21e5 100644
--- a/lib/Math/BigInt/t/bigints.t
+++ b/lib/Math/BigInt/t/bigints.t
@@ -36,24 +36,24 @@ use Math::BigInt::Scalar;
my $C = 'Math::BigInt::Scalar'; # pass classname to sub's
# _new and _str
-my $x = $C->_new(\"123"); my $y = $C->_new(\"321");
-ok (ref($x),'SCALAR'); ok (${$C->_str($x)},123); ok (${$C->_str($y)},321);
+my $x = $C->_new("123"); my $y = $C->_new("321");
+ok (ref($x),'SCALAR'); ok ($C->_str($x),123); ok ($C->_str($y),321);
# _add, _sub, _mul, _div
-ok (${$C->_str($C->_add($x,$y))},444);
-ok (${$C->_str($C->_sub($x,$y))},123);
-ok (${$C->_str($C->_mul($x,$y))},39483);
-ok (${$C->_str($C->_div($x,$y))},123);
+ok ($C->_str($C->_add($x,$y)),444);
+ok ($C->_str($C->_sub($x,$y)),123);
+ok ($C->_str($C->_mul($x,$y)),39483);
+ok ($C->_str($C->_div($x,$y)),123);
-ok (${$C->_str($C->_mul($x,$y))},39483);
-ok (${$C->_str($x)},39483);
-ok (${$C->_str($y)},321);
-my $z = $C->_new(\"2");
-ok (${$C->_str($C->_add($x,$z))},39485);
+ok ($C->_str($C->_mul($x,$y)),39483);
+ok ($C->_str($x),39483);
+ok ($C->_str($y),321);
+my $z = $C->_new("2");
+ok ($C->_str($C->_add($x,$z)),39485);
my ($re,$rr) = $C->_div($x,$y);
-ok (${$C->_str($re)},123); ok (${$C->_str($rr)},2);
+ok ($C->_str($re),123); ok ($C->_str($rr),2);
# is_zero, _is_one, _one, _zero
ok ($C->_is_zero($x),0);
@@ -67,7 +67,7 @@ ok ($C->_is_odd($C->_one()),1); ok ($C->_is_odd($C->_zero()),0);
ok ($C->_is_even($C->_one()),0); ok ($C->_is_even($C->_zero()),1);
# _digit
-$x = $C->_new(\"123456789");
+$x = $C->_new("123456789");
ok ($C->_digit($x,0),9);
ok ($C->_digit($x,1),8);
ok ($C->_digit($x,2),7);
@@ -76,47 +76,44 @@ ok ($C->_digit($x,-2),2);
ok ($C->_digit($x,-3),3);
# _copy
-$x = $C->_new(\"12356");
-ok (${$C->_str($C->_copy($x))},12356);
+$x = $C->_new("12356");
+ok ($C->_str($C->_copy($x)),12356);
# _acmp
-$x = $C->_new(\"123456789");
-$y = $C->_new(\"987654321");
+$x = $C->_new("123456789");
+$y = $C->_new("987654321");
ok ($C->_acmp($x,$y),-1);
ok ($C->_acmp($y,$x),1);
ok ($C->_acmp($x,$x),0);
ok ($C->_acmp($y,$y),0);
# _div
-$x = $C->_new(\"3333"); $y = $C->_new(\"1111");
-ok (${$C->_str( scalar $C->_div($x,$y))},3);
-$x = $C->_new(\"33333"); $y = $C->_new(\"1111"); ($x,$y) = $C->_div($x,$y);
-ok (${$C->_str($x)},30); ok (${$C->_str($y)},3);
-$x = $C->_new(\"123"); $y = $C->_new(\"1111");
-($x,$y) = $C->_div($x,$y); ok (${$C->_str($x)},0); ok (${$C->_str($y)},123);
+$x = $C->_new("3333"); $y = $C->_new("1111");
+ok ($C->_str( scalar $C->_div($x,$y)),3);
+$x = $C->_new("33333"); $y = $C->_new("1111"); ($x,$y) = $C->_div($x,$y);
+ok ($C->_str($x),30); ok ($C->_str($y),3);
+$x = $C->_new("123"); $y = $C->_new("1111");
+($x,$y) = $C->_div($x,$y); ok ($C->_str($x),0); ok ($C->_str($y),123);
# _num
-$x = $C->_new(\"12345"); $x = $C->_num($x); ok (ref($x)||'',''); ok ($x,12345);
+$x = $C->_new("12345"); $x = $C->_num($x); ok (ref($x)||'',''); ok ($x,12345);
# _len
-$x = $C->_new(\"12345"); $x = $C->_len($x); ok (ref($x)||'',''); ok ($x,5);
+$x = $C->_new("12345"); $x = $C->_len($x); ok (ref($x)||'',''); ok ($x,5);
# _and, _or, _xor
-$x = $C->_new(\"3"); $y = $C->_new(\"4"); ok (${$C->_str( $C->_or($x,$y))},7);
-$x = $C->_new(\"1"); $y = $C->_new(\"4"); ok (${$C->_str( $C->_xor($x,$y))},5);
-$x = $C->_new(\"7"); $y = $C->_new(\"3"); ok (${$C->_str( $C->_and($x,$y))},3);
+$x = $C->_new("3"); $y = $C->_new("4"); ok ($C->_str( $C->_or($x,$y)),7);
+$x = $C->_new("1"); $y = $C->_new("4"); ok ($C->_str( $C->_xor($x,$y)),5);
+$x = $C->_new("7"); $y = $C->_new("3"); ok ($C->_str( $C->_and($x,$y)),3);
# _pow
-$x = $C->_new(\"2"); $y = $C->_new(\"4"); ok (${$C->_str( $C->_pow($x,$y))},16);
-$x = $C->_new(\"2"); $y = $C->_new(\"5"); ok (${$C->_str( $C->_pow($x,$y))},32);
-$x = $C->_new(\"3"); $y = $C->_new(\"3"); ok (${$C->_str( $C->_pow($x,$y))},27);
+$x = $C->_new("2"); $y = $C->_new("4"); ok ($C->_str( $C->_pow($x,$y)),16);
+$x = $C->_new("2"); $y = $C->_new("5"); ok ($C->_str( $C->_pow($x,$y)),32);
+$x = $C->_new("3"); $y = $C->_new("3"); ok ($C->_str( $C->_pow($x,$y)),27);
-# should not happen:
-# $x = $C->_new(\"-2"); $y = $C->_new(\"4"); ok ($C->_acmp($x,$y),-1);
-
# _check
-$x = $C->_new(\"123456789");
+$x = $C->_new("123456789");
ok ($C->_check($x),0);
ok ($C->_check(123),'123 is not a reference');
diff --git a/lib/Math/BigInt/t/biglog.t b/lib/Math/BigInt/t/biglog.t
index 9ed9c2a3d7..cba26435d3 100644
--- a/lib/Math/BigInt/t/biglog.t
+++ b/lib/Math/BigInt/t/biglog.t
@@ -37,7 +37,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 50;
+ plan tests => 53;
}
use Math::BigFloat;
@@ -45,7 +45,7 @@ use Math::BigInt;
my $cl = "Math::BigFloat";
-# these tests are now really fast, since they collapse to blog(10), basically
+# These tests are now really fast, since they collapse to blog(10), basically
# Don't attempt to run them with older versions. You are warned.
# $x < 0 => NaN
@@ -99,6 +99,11 @@ ok ($cl->new('10')->bpow('0.6',10), '3.981071706');
# blog should handle bigint input
ok (Math::BigFloat::blog(Math::BigInt->new(100),10), 2);
+# some integer results
+ok ($cl->new(2)->bpow(32)->blog(2), '32'); # 2 ** 32
+ok ($cl->new(3)->bpow(32)->blog(3), '32'); # 3 ** 32
+ok ($cl->new(2)->bpow(65)->blog(2), '65'); # 2 ** 65
+
# test for bug in bsqrt() not taking negative _e into account
test_bpow ('200','0.5',10, '14.14213562');
test_bpow ('20','0.5',10, '4.472135955');
@@ -127,7 +132,7 @@ sub test_bpow
{
my ($x,$y,$scale,$result) = @_;
- print "# Tried: $x->bpow($y,$scale);\n"
+ print "# Tried: $x->bpow($y,$scale);\n"
unless ok ($cl->new($x)->bpow($y,$scale),$result);
}
diff --git a/lib/Math/BigInt/t/calling.t b/lib/Math/BigInt/t/calling.t
index 3b0ff41dd4..71c6b48c97 100644
--- a/lib/Math/BigInt/t/calling.t
+++ b/lib/Math/BigInt/t/calling.t
@@ -30,7 +30,7 @@ BEGIN
unshift @INC, $location;
}
print "# INC = @INC\n";
- my $tests = 161;
+ my $tests = 160;
plan tests => $tests;
if ($] < 5.006)
{
@@ -95,11 +95,12 @@ while (<DATA>)
$class = 'Math::BigInt';
+# XXX TODO this test does not work/fail.
# test whether use Math::BigInt qw/version/ works
-$try = "use $class ($version.'1');";
-$try .= ' $x = $class->new(123); $x = "$x";';
-eval $try;
-ok_undef ( $_ ); # should result in error!
+#$try = "use $class ($version.'1');";
+#$try .= ' $x = $class->new(123); $x = "$x";';
+#eval $try;
+#ok_undef ( $x ); # should result in error!
# test whether fallback to calc works
$try = "use $class ($version,'lib','foo, bar , ');";
@@ -122,14 +123,6 @@ $try = "use $class ($version,'LiB','$class\::Scalar');";
$try .= ' $x = 2**10; $x = "$x";';
$ans = eval $try; ok ( $ans, "1024");
-# test wether calc => undef (array element not existing) works
-# no longer supported
-#$try = "use $class ($version,'LIB');";
-#$try = "require $class; $class\::import($version,'CALC');";
-#$try .= " \$x = $class\->new(2)**10; \$x = ".'"$x";';
-#print "$try\n";
-#$ans = eval $try; ok ( $ans, 1024);
-
# all done
###############################################################################
diff --git a/lib/Math/BigInt/t/config.t b/lib/Math/BigInt/t/config.t
index 5c480536bd..da75344f2a 100644
--- a/lib/Math/BigInt/t/config.t
+++ b/lib/Math/BigInt/t/config.t
@@ -51,7 +51,7 @@ $cfg = $mbf->config();
ok (ref($cfg),'HASH');
ok ($cfg->{lib},'Math::BigInt::Calc');
-ok ($cfg->{with},$mbi);
+ok ($cfg->{with},'Math::BigInt::Calc');
ok ($cfg->{lib_version}, $Math::BigInt::Calc::VERSION);
ok ($cfg->{class},$mbf);
ok ($cfg->{upgrade}||'','');
diff --git a/lib/Math/BigInt/t/mbimbf.inc b/lib/Math/BigInt/t/mbimbf.inc
index 192b1cc4bf..b9c94c4900 100644
--- a/lib/Math/BigInt/t/mbimbf.inc
+++ b/lib/Math/BigInt/t/mbimbf.inc
@@ -264,9 +264,9 @@ foreach my $c ($mbi,$mbf)
ok ($c->bpow(2,16),65536);
ok ($c->bpow(2,$c->new(16)),65536);
-# ok ($c->new(2**15)->brsft(1),2**14);
-# ok ($c->brsft(2**15,1),2**14);
-# ok ($c->brsft(2**15,$c->new(1)),2**14);
+ ok ($c->new(2**15)->brsft(1),2**14);
+ ok ($c->brsft(2**15,1),2**14);
+ ok ($c->brsft(2**15,$c->new(1)),2**14);
ok ($c->new(2**13)->blsft(1),2**14);
ok ($c->blsft(2**13,1),2**14);
@@ -544,6 +544,17 @@ $x = $mbf->new('12340'); $x->bfround(2); ok ($x,'12340');
$x = $mbi->new('1234'); $x->accuracy(3); $x->bfround(-2);
ok_undef ($x->{_a});
+# test that bfround() and bround() work with large numbers
+
+$x = $mbf->new(1)->bdiv(5678,undef,-63);
+ok ($x, '0.000176118351532229658330398027474462839027826699542092286016203');
+
+$x = $mbf->new(1)->bdiv(5678,undef,-90);
+ok ($x, '0.000176118351532229658330398027474462839027826699542092286016202888340965128566396618527651');
+
+$x = $mbf->new(1)->bdiv(5678,80);
+ok ($x, '0.00017611835153222965833039802747446283902782669954209228601620288834096512856639662');
+
###############################################################################
# rounding with already set precision/accuracy
@@ -565,8 +576,9 @@ ok ($x->{_a},2);
# mantissa/exponent format and A/P
$x = $mbf->new('12345.678'); $x->accuracy(4);
ok ($x,'12350'); ok ($x->{_a},4); ok_undef ($x->{_p});
-ok_undef ($x->{_m}->{_a}); ok_undef ($x->{_e}->{_a});
-ok_undef ($x->{_m}->{_p}); ok_undef ($x->{_e}->{_p});
+
+#ok_undef ($x->{_m}->{_a}); ok_undef ($x->{_e}->{_a});
+#ok_undef ($x->{_m}->{_p}); ok_undef ($x->{_e}->{_p});
# check for no A/P in case of fallback
# result
@@ -792,7 +804,7 @@ while (<DATA>)
$try .= "\$x->$f(\$y);";
- # print "trying $try\n";
+ # print "trying $try\n";
$rc = eval $try;
# convert hex/binary targets to decimal
if ($ans =~ /^(0x0x|0b0b)/)
diff --git a/lib/Math/BigInt/t/mbimbf.t b/lib/Math/BigInt/t/mbimbf.t
index 17cd712b0f..fae3c8cf9c 100644
--- a/lib/Math/BigInt/t/mbimbf.t
+++ b/lib/Math/BigInt/t/mbimbf.t
@@ -31,12 +31,12 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 679
+ plan tests => 684
+ 23; # own tests
}
-use Math::BigInt 1.63;
-use Math::BigFloat 1.38;
+use Math::BigInt 1.70;
+use Math::BigFloat 1.43;
use vars qw/$mbi $mbf/;
@@ -95,7 +95,6 @@ foreach my $class (qw/Math::BigInt Math::BigFloat/)
$class->accuracy(undef); # reset for further tests
$class->precision(undef);
}
-
# bug with flog(Math::BigFloat,Math::BigInt)
$x = Math::BigFloat->new(100);
$x = $x->blog(Math::BigInt->new(10));
diff --git a/lib/Math/BigInt/t/req_mbfw.t b/lib/Math/BigInt/t/req_mbfw.t
index b216c797d9..025722d277 100644
--- a/lib/Math/BigInt/t/req_mbfw.t
+++ b/lib/Math/BigInt/t/req_mbfw.t
@@ -34,12 +34,13 @@ BEGIN
# normal require that calls import automatically (we thus have MBI afterwards)
require Math::BigFloat; my $x = Math::BigFloat->new(1); ++$x; ok ($x,2);
-ok (Math::BigFloat->config()->{with}, 'Math::BigInt' );
+ok (Math::BigFloat->config()->{with}, 'Math::BigInt::Calc' );
# now override
Math::BigFloat->import ( with => 'Math::BigInt::Subclass' );
-ok (Math::BigFloat->config()->{with}, 'Math::BigInt::Subclass' );
+# thw with argument is ignored
+ok (Math::BigFloat->config()->{with}, 'Math::BigInt::Calc' );
# all tests done
diff --git a/lib/Math/BigInt/t/sub_mbf.t b/lib/Math/BigInt/t/sub_mbf.t
index 91fda9762a..9a8b9a396c 100755
--- a/lib/Math/BigInt/t/sub_mbf.t
+++ b/lib/Math/BigInt/t/sub_mbf.t
@@ -26,7 +26,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 1772
+ plan tests => 1814
+ 6; # + our own tests
}
diff --git a/lib/Math/BigInt/t/sub_mbi.t b/lib/Math/BigInt/t/sub_mbi.t
index 16968d4847..3e831c5fe4 100755
--- a/lib/Math/BigInt/t/sub_mbi.t
+++ b/lib/Math/BigInt/t/sub_mbi.t
@@ -26,7 +26,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 2770
+ plan tests => 2832
+ 5; # +5 own tests
}
diff --git a/lib/Math/BigInt/t/sub_mif.t b/lib/Math/BigInt/t/sub_mif.t
index cbaf06a97c..cd0c863075 100644
--- a/lib/Math/BigInt/t/sub_mif.t
+++ b/lib/Math/BigInt/t/sub_mif.t
@@ -28,7 +28,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 679;
+ plan tests => 684;
}
use Math::BigInt::Subclass;
diff --git a/lib/Math/BigInt/t/upgrade.inc b/lib/Math/BigInt/t/upgrade.inc
index 49dbf91823..4799420fd8 100644
--- a/lib/Math/BigInt/t/upgrade.inc
+++ b/lib/Math/BigInt/t/upgrade.inc
@@ -1263,8 +1263,8 @@ abc:12:NaN
0:0:1
0:1:0
0:2:0
-0:-1:NaN
-0:-2:NaN
+0:-1:inf
+0:-2:inf
1:0:1
1:1:1
1:2:1
@@ -1297,6 +1297,14 @@ abc:12:NaN
-1:-2:1
-1:-3:-1
-1:-4:1
+-2:2:4
+-2:3:-8
+-2:4:16
+-2:5:-32
+-3:2:9
+-3:3:-27
+-3:4:81
+-3:5:-243
10:2:100
10:3:1000
10:4:10000
diff --git a/lib/Math/BigInt/t/upgrade.t b/lib/Math/BigInt/t/upgrade.t
index 3fc4067259..a06aec352e 100644
--- a/lib/Math/BigInt/t/upgrade.t
+++ b/lib/Math/BigInt/t/upgrade.t
@@ -26,7 +26,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 2082
+ plan tests => 2098
+ 2; # our own tests
}
diff --git a/lib/Math/BigInt/t/use_mbfw.t b/lib/Math/BigInt/t/use_mbfw.t
index d58de047f2..c6a047143e 100644
--- a/lib/Math/BigInt/t/use_mbfw.t
+++ b/lib/Math/BigInt/t/use_mbfw.t
@@ -29,7 +29,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 3;
+ plan tests => 2;
}
@@ -41,12 +41,12 @@ BEGIN
use Math::BigFloat with => 'Math::BigInt::Subclass', lib => 'BareCalc';
-ok (Math::BigFloat->config()->{with}, 'Math::BigInt::Subclass' );
+ok (Math::BigFloat->config()->{with}, 'Math::BigInt::BareCalc' );
-ok ($Math::BigInt::Subclass::lib, 'BareCalc' );
+# ok ($Math::BigInt::Subclass::lib, 'BareCalc' );
# it never arrives here, but that is a design decision in SubClass
-ok (Math::BigInt->config->{lib}, 'Math::BigInt::Calc' );
+ok (Math::BigInt->config->{lib}, 'Math::BigInt::BareCalc' );
# all tests done
diff --git a/lib/Math/BigInt/t/with_sub.t b/lib/Math/BigInt/t/with_sub.t
index a3af404f55..d7391d94ae 100644
--- a/lib/Math/BigInt/t/with_sub.t
+++ b/lib/Math/BigInt/t/with_sub.t
@@ -28,7 +28,7 @@ BEGIN
}
print "# INC = @INC\n";
- plan tests => 1772
+ plan tests => 1814
+ 1;
}
@@ -38,6 +38,7 @@ use vars qw ($class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL);
$class = "Math::BigFloat";
$CL = "Math::BigInt::Calc";
-ok (Math::BigFloat->config()->{with}, 'Math::BigInt::Subclass');
+# the with argument is ignored
+ok (Math::BigFloat->config()->{with}, 'Math::BigInt::Calc');
require 'bigfltpm.inc'; # all tests here for sharing