summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorBo Lindbergh <blgl@stacken.kth.se>2010-07-05 00:04:46 +0200
committerDavid Golden <dagolden@cpan.org>2010-07-06 08:01:39 -0400
commit333f87f24de2f15740185612410ef911ccfed6a3 (patch)
tree0eb5cf49b613d51b7b716d3070879b6266355c5d /t
parent8d4088782934a96fb4c8a4688f9c24f45ea353fa (diff)
downloadperl-333f87f24de2f15740185612410ef911ccfed6a3.tar.gz
Tests for allowing uppercase X/B in hexadecimal/binary numbers (#76296).
Signed-off-by: David Golden <dagolden@cpan.org>
Diffstat (limited to 't')
-rw-r--r--t/base/num.t15
-rw-r--r--t/op/oct.t15
2 files changed, 26 insertions, 4 deletions
diff --git a/t/base/num.t b/t/base/num.t
index 06eea527f7..fbeddc9434 100644
--- a/t/base/num.t
+++ b/t/base/num.t
@@ -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
@@ -196,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";
diff --git a/t/op/oct.t b/t/op/oct.t
index f996b48975..dcd2256777 100644
--- a/t/op/oct.t
+++ b/t/op/oct.t
@@ -2,7 +2,7 @@
# tests 51 onwards aren't all warnings clean. (intentionally)
-print "1..71\n";
+print "1..77\n";
my $test = 1;
@@ -25,10 +25,10 @@ sub test ($$$) {
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 {
@@ -150,3 +150,12 @@ print $@ =~ /Wide character/ ? "ok $test\n" : "not ok $test\n"; $test++;
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);