summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorPeter John Acklam <pjacklam@online.no>2011-03-05 14:38:36 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-03-05 17:16:20 -0800
commit02916adf982e17a20465ed6e7008686ec9499a1e (patch)
tree8c91fe960dc524310cc88efcfa0b725a44795602 /dist
parent6bd767fbea22eb93805d6b5257c8283931aac3db (diff)
downloadperl-02916adf982e17a20465ed6e7008686ec9499a1e.tar.gz
[perl #85476] Add tests to confirm fix of RT #49569.
Confirm that numify() on a value that can be represented exactly as a Perl scalar integer is not converted to a floating point number, e.g., that it returns 18446744073709551615, not 1.84467440737096e+19.
Diffstat (limited to 'dist')
-rw-r--r--dist/Math-BigInt/t/bare_mbi.t2
-rw-r--r--dist/Math-BigInt/t/bigintpm.inc21
-rw-r--r--dist/Math-BigInt/t/bigintpm.t2
-rw-r--r--dist/Math-BigInt/t/sub_mbi.t2
4 files changed, 24 insertions, 3 deletions
diff --git a/dist/Math-BigInt/t/bare_mbi.t b/dist/Math-BigInt/t/bare_mbi.t
index a73fd12337..d7139dd1a6 100644
--- a/dist/Math-BigInt/t/bare_mbi.t
+++ b/dist/Math-BigInt/t/bare_mbi.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 3619;
+use Test::More tests => 3623;
BEGIN { unshift @INC, 't'; }
diff --git a/dist/Math-BigInt/t/bigintpm.inc b/dist/Math-BigInt/t/bigintpm.inc
index f5f0fd2812..e52a2713d3 100644
--- a/dist/Math-BigInt/t/bigintpm.inc
+++ b/dist/Math-BigInt/t/bigintpm.inc
@@ -524,6 +524,27 @@ is (ref($x),'Math::Foo');
$x = $class->new('+inf'); is ($x,'inf');
###############################################################################
+# numify() and 64 bit integer support
+
+require Config;
+SKIP: {
+ skip("no 64 bit integer support", 4)
+ unless $Config::Config{use64bitint} || $Config::Config{use64bitall};
+
+ # The following should not give "1.84467440737096e+19".
+
+ $x = $class -> new(2) -> bpow(64) -> bdec();
+ is($x -> bstr(), "18446744073709551615", "bigint 2**64-1 as string");
+ is($x -> numify(), "18446744073709551615", "bigint 2**64-1 as number");
+
+ # The following should not give "-9.22337203685478e+18".
+
+ $x = $class -> new(2) -> bpow(63) -> bneg();
+ is($x -> bstr(), "-9223372036854775808", "bigint -2**63 as string");
+ is($x -> numify(), "-9223372036854775808", "bigint -2**63 as number");
+};
+
+###############################################################################
###############################################################################
# the following tests only make sense with Math::BigInt::Calc or BareCalc or
# FastCalc
diff --git a/dist/Math-BigInt/t/bigintpm.t b/dist/Math-BigInt/t/bigintpm.t
index d16844b347..cacdb8e2ec 100644
--- a/dist/Math-BigInt/t/bigintpm.t
+++ b/dist/Math-BigInt/t/bigintpm.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 3619 + 6;
+use Test::More tests => 3623 + 6;
use Math::BigInt lib => 'Calc';
diff --git a/dist/Math-BigInt/t/sub_mbi.t b/dist/Math-BigInt/t/sub_mbi.t
index a999c0982b..668fd1979e 100644
--- a/dist/Math-BigInt/t/sub_mbi.t
+++ b/dist/Math-BigInt/t/sub_mbi.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 3619
+use Test::More tests => 3623
+ 5; # +5 own tests
BEGIN { unshift @INC, 't'; }