This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Eliminate tryAMAGICunW() by refactoring tryAMAGICun{DEREF,TARGET}
[perl5.git] / t / base / num.t
index f915281..fbeddc9 100644 (file)
@@ -1,6 +1,6 @@
 #!./perl
 
-print "1..50\n";
+print "1..53\n";
 
 # First test whether the number stringification works okay.
 # (Testing with == would exercize the IV/NV part, not the PV.)
@@ -50,6 +50,8 @@ print $a eq "256"     ? "ok 14\n" : "not ok 14 # $a\n";
 $a = 1000; "$a";
 print $a eq "1000"    ? "ok 15\n" : "not ok 15 # $a\n";
 
+# more hex and binary tests below starting at 51
+
 # Okay, now test the numerics.
 # We may be assuming too much, given the painfully well-known floating
 # point sloppiness, but the following are still quite reasonable
@@ -164,7 +166,7 @@ print $a eq "123.456" ? "ok 44\n" : "not ok 44 # $a\n";
 
 $a = 1e34; "$a";
 unless ($^O eq 'posix-bc')
-{ print $a eq "1e+34" || $a eq "1e+034" ? "ok 45\n" : "not ok 45 $a\n"; }
+{ print $a eq "1e+34" || $a eq "1e+034" ? "ok 45\n" : "not ok 45 $a\n"; }
 else
 { print "ok 45 # skipped on $^O\n"; }
 
@@ -174,8 +176,11 @@ $a = 0.00049999999999999999999999999999999999999;
 $b = 0.0005000000000000000104;
 print $a <= $b ? "ok 46\n" : "not ok 46\n";
 
-if ($^O eq 'ultrix') {
-  # Ultrix enters looong nirvana over this.
+if ($^O eq 'ultrix' || $^O eq 'VMS') {
+  # Ultrix enters looong nirvana over this. VMS blows up when configured with
+  # D_FLOAT (but with G_FLOAT or IEEE works fine).  The test should probably
+  # make the number of 0's a function of NV_DIG, but that's not in Config and 
+  # we probably don't want to suck Config into a base test anyway.
   print "ok 47\n";
 } else {
   $a = 0.00000000000000000000000000000000000000000000000000000000000000000001;
@@ -193,3 +198,14 @@ print $a == 10.0 ? "ok 49\n" : "not ok 49\n";
 $a = 57.295779513082320876798154814169;
 print ok($a*10,572.95779513082320876798154814169,1e-10) ? "ok 50\n" :
   "not ok 50 # $a\n";
+
+# Allow uppercase base markers (#76296)
+
+$a = 0Xabcdef; "$a";
+print $a eq "11259375"     ? "ok 51\n" : "not ok 51 # $a\n";
+
+$a = 0XFEDCBA; "$a";
+print $a eq "16702650"     ? "ok 52\n" : "not ok 52 # $a\n";
+
+$a = 0B1101; "$a";
+print $a eq "13"           ? "ok 53\n" : "not ok 53 # $a\n";