develooper Front page | perl.perl5.porters | Postings from March 2011

[perl #85476] [PATCH] Add tests to confirm fix of RT #49569.

Thread Previous
From:
perlbug-followup
Date:
March 5, 2011 12:37
Subject:
[perl #85476] [PATCH] Add tests to confirm fix of RT #49569.
Message ID:
rt-3.6.HEAD-28241-1299349486-1439.85476-75-0@perl.org
# New Ticket Created by  (Peter J. Acklam) 
# Please include the string:  [perl #85476]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=85476 >


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'; }
-- 
1.7.4


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About