[patch: perl@8211]VMS: add -Duseperlio capacity to configure.com
[p5sagit/p5-mst-13.2.git] / t / op / 64bitint.t
index ac37716..47779dd 100644 (file)
@@ -3,11 +3,11 @@
 BEGIN {
        eval { my $q = pack "q", 0 };
        if ($@) {
-               print "1..0\n# no 64-bit types\n";
+               print "1..0\n# Skip: no 64-bit types\n";
                exit(0);
        }
        chdir 't' if -d 't';
-       unshift @INC, '../lib';
+       @INC = '../lib';
 }
 
 # This could use many more tests.
@@ -16,7 +16,7 @@ BEGIN {
 # 32+ bit integers don't cause noise
 no warnings qw(overflow portable);
 
-print "1..52\n";
+print "1..57\n";
 
 my $q = 12345678901;
 my $r = 23456789012;
@@ -127,25 +127,17 @@ if ($^O ne 'unicos') {
     $x = $q * 1234567;
     print "not " unless $x == 15241567763770867 && $x > $f;
     print "ok 23\n";
-} else {
-    # Unicos has imprecise doubles (14 decimal digits or so),
-    # the multiplication mangles the low-order bits.
-    $x = $q * 1234;
-    print "not " unless $x == 15234567763834 && $x > $f;
-    print "ok 23\n";
-}
 
-$x /= 1234567;
-print "not " unless $x == $q && $x > $f;
-print "ok 24\n";
-
-$x = 98765432109 % 12345678901;
-print "not " unless $x == 901;
-print "ok 25\n";
+    $x /= 1234567;
+    print "not " unless $x == $q && $x > $f;
+    print "ok 24\n";
 
-# The following 12 tests adapted from op/inc.
+    $x = 98765432109 % 12345678901;
+    print "not " unless $x == 901;
+    print "ok 25\n";
+    
+    # The following 12 tests adapted from op/inc.
 
-if ($^O ne 'unicos') {
     $a = 9223372036854775807;
     $c = $a++;
     print "not " unless $a == 9223372036854775808;
@@ -225,10 +217,10 @@ if ($^O ne 'unicos') {
 
 } else {
     # Unicos has imprecise doubles (14 decimal digits or so),
-    # near the UV/IV limites the low-order bits become mangled
-    # even by simple additions and subtractions.
-    for (26..37) {
-       print "ok #_ # skipped: too imprecise numbers\n";
+    # especially if operating near the UV/IV limits the low-order bits
+    # become mangled even by simple arithmetic operations.
+    for (23..37) {
+       print "ok $_ # skipped: too imprecise numbers\n";
     }
 }
 
@@ -287,4 +279,45 @@ print "ok 51\n";
 print "not " unless (sprintf "%u", ~0)    eq '18446744073709551615';
 print "ok 52\n";
 
+# If the 53..55 fail you have problems in the parser's string->int conversion,
+# see toke.c:scan_num().
+
+$q = -9223372036854775808;
+print "# $q ne\n# -9223372036854775808\nnot " unless "$q" eq "-9223372036854775808";
+print "ok 53\n";
+
+$q =  9223372036854775807;
+print "# $q ne\n# 9223372036854775807\nnot " unless "$q" eq "9223372036854775807";
+print "ok 54\n";
+
+$q = 18446744073709551615;
+print "# $q ne\n# 18446744073709551615\nnot " unless "$q" eq "18446744073709551615";
+print "ok 55\n";
+
+# Test that sv_2nv then sv_2iv is the same as sv_2iv direct
+# fails if whatever Atol is defined as can't actually cope with >32 bits.
+my $num = 4294967297;
+my $string = "4294967297";
+{
+  use integer;
+  $num += 0;
+  $string += 0;
+}
+if ($num eq $string) {
+  print "ok 56\n";
+} else {
+  print "not ok 56 # \"$num\" ne \"$string\"\n";
+}
+
+# Test that sv_2nv then sv_2uv is the same as sv_2uv direct
+$num = 4294967297;
+$string = "4294967297";
+$num &= 0;
+$string &= 0;
+if ($num eq $string) {
+  print "ok 57\n";
+} else {
+  print "not ok 57 # \"$num\" ne \"$string\"\n";
+}
+
 # eof