[perl #85476] Add tests to confirm fix of RT #49569.
authorPeter John Acklam <pjacklam@online.no>
Sat, 5 Mar 2011 22:38:36 +0000 (14:38 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 6 Mar 2011 01:16:20 +0000 (17:16 -0800)
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.

dist/Math-BigInt/t/bare_mbi.t
dist/Math-BigInt/t/bigintpm.inc
dist/Math-BigInt/t/bigintpm.t
dist/Math-BigInt/t/sub_mbi.t

index a73fd12..d7139dd 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 use strict;
-use Test::More tests => 3619;
+use Test::More tests => 3623;
 
 BEGIN { unshift @INC, 't'; }
 
index f5f0fd2..e52a271 100644 (file)
@@ -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
index d16844b..cacdb8e 100644 (file)
@@ -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';
 
index a999c09..668fd19 100644 (file)
@@ -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'; }