summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2019-06-20 11:06:13 +1000
committerTony Cook <tony@develop-help.com>2019-06-27 09:53:57 +1000
commit1ef28cc363aecc46572509c9acfcd02ed416d226 (patch)
treed2fadd0525a278cd2928ac16250a3a8e58313ffc /t
parentc4d7a63389c79059f9f3d318c4166a3b11bb0974 (diff)
downloadperl-1ef28cc363aecc46572509c9acfcd02ed416d226.tar.gz
(perl #134125) make no digits after 0x/0b fatal
My original change in 7259f4194 silently adjusted the parse position to immediately after the 0 in an incomplete hex or binary literal. In most cases this leads to a syntax error, but in some cases, especially with 0x, this can lead to a silent change in behaviour. So throw an error instead.
Diffstat (limited to 't')
-rw-r--r--t/lib/croak/toke14
-rw-r--r--t/op/hexfp.t4
2 files changed, 7 insertions, 11 deletions
diff --git a/t/lib/croak/toke b/t/lib/croak/toke
index e7bf609637..4ef6f726fc 100644
--- a/t/lib/croak/toke
+++ b/t/lib/croak/toke
@@ -507,16 +507,12 @@ Execution of - aborted due to compilation errors.
0x x 2;
0xx 2;
0x_;
+0b;
EXPECT
-Number found where operator expected at - line 1, near "x 2"
- (Do you need to predeclare x?)
-Bareword found where operator expected at - line 2, near "0xx"
- (Missing operator before xx?)
-Number found where operator expected at - line 2, near "xx 2"
- (Do you need to predeclare xx?)
-Bareword found where operator expected at - line 3, near "0x_"
- (Missing operator before x_?)
-syntax error at - line 1, near "x 2"
+No digits found for hexadecimal literal at - line 1, near "0x "
+No digits found for hexadecimal literal at - line 2, near "0xx"
+No digits found for hexadecimal literal at - line 3, near "0x_;"
+No digits found for binary literal at - line 4, near "0b;"
Execution of - aborted due to compilation errors.
########
# NAME [perl #130585] close paren in subparse
diff --git a/t/op/hexfp.t b/t/op/hexfp.t
index 8904c48d29..eeb2c9d364 100644
--- a/t/op/hexfp.t
+++ b/t/op/hexfp.t
@@ -138,7 +138,7 @@ sub get_warn() {
{ # Test certain things that are not hexfloats and should stay that way.
eval '0xp3';
- like(get_warn(), qr/Missing operator before xp3/);
+ like(get_warn(), qr/Missing operator before p3/);
eval '5p3';
like(get_warn(), qr/Missing operator before p3/);
@@ -149,7 +149,7 @@ sub get_warn() {
undef $a;
eval '$a = eval "0x.3"';
- is($a, ''); # 0 x .3
+ is($a, undef); # throws an error
undef $a;
eval '$a = eval "0xc.3"';