#!./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.)
$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
$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";
# tests 51 onwards aren't all warnings clean. (intentionally)
-print "1..71\n";
+print "1..77\n";
my $test = 1;
print "ok $test # $act $string\n";
} else {
my ($valstr, $resstr);
- if ($act eq 'hex' or $string =~ /x/) {
+ if ($act eq 'hex' or $string =~ /x/i) {
$valstr = sprintf "0x%X", $value;
$resstr = sprintf "0x%X", $result;
- } elsif ($string =~ /b/) {
+ } elsif ($string =~ /b/i) {
$valstr = sprintf "0b%b", $value;
$resstr = sprintf "0b%b", $result;
} else {
eval '$a = hex "ab\x{100}"';
print $@ =~ /Wide character/ ? "ok $test\n" : "not ok $test\n"; $test++;
+
+# Allow uppercase base markers (#76296)
+
+test ('hex', "0XCAFE", 0xCAFE);
+test ('hex', "XCAFE", 0xCAFE);
+test ('oct', "0XCAFE", 0xCAFE);
+test ('oct', "XCAFE", 0xCAFE);
+test ('oct', "0B101001", 0b101001);
+test ('oct', "B101001", 0b101001);