From 02916adf982e17a20465ed6e7008686ec9499a1e Mon Sep 17 00:00:00 2001 From: Peter John Acklam Date: Sat, 5 Mar 2011 14:38:36 -0800 Subject: [PATCH] [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. --- dist/Math-BigInt/t/bare_mbi.t | 2 +- dist/Math-BigInt/t/bigintpm.inc | 21 +++++++++++++++++++++ dist/Math-BigInt/t/bigintpm.t | 2 +- dist/Math-BigInt/t/sub_mbi.t | 2 +- 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 a73fd12..d7139dd 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 f5f0fd2..e52a271 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 d16844b..cacdb8e 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 a999c09..668fd19 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'; } -- 2.7.4