X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/c9de86d555b2cc844acfe134ffe61228163a50ea..fd909433c7437296:/t/comp/parser.t diff --git a/t/comp/parser.t b/t/comp/parser.t index 6cbba9b..65315bc 100644 --- a/t/comp/parser.t +++ b/t/comp/parser.t @@ -3,7 +3,7 @@ # Checks if the parser behaves correctly in edge cases # (including weird syntax errors) -print "1..104\n"; +print "1..118\n"; sub failed { my ($got, $expected, $name) = @_; @@ -285,6 +285,59 @@ like($@, qr/BEGIN failed--compilation aborted/, 'BEGIN 6' ); eval q[ BEGIN {\&foo4; die } ] for 1..10; like($@, qr/BEGIN failed--compilation aborted/, 'BEGIN 7' ); +{ + # RT #70934 + # check both the specific case in the ticket, and a few other paths into + # S_scan_ident() + # simplify long ids + my $x100 = "x" x 256; + my $xFE = "x" x 254; + my $xFD = "x" x 253; + my $xFC = "x" x 252; + my $xFB = "x" x 251; + + eval qq[ \$#$xFB ]; + is($@, "", "251 character \$# sigil ident ok"); + eval qq[ \$#$xFC ]; + like($@, qr/Identifier too long/, "too long id in \$# sigil ctx"); + + eval qq[ \$$xFB ]; + is($@, "", "251 character \$ sigil ident ok"); + eval qq[ \$$xFC ]; + like($@, qr/Identifier too long/, "too long id in \$ sigil ctx"); + + eval qq[ %$xFB ]; + is($@, "", "251 character % sigil ident ok"); + eval qq[ %$xFC ]; + like($@, qr/Identifier too long/, "too long id in % sigil ctx"); + + eval qq[ \\&$xFC ]; # take a ref since I don't want to call it + is($@, "", "252 character & sigil ident ok"); + eval qq[ \\&$xFD ]; + like($@, qr/Identifier too long/, "too long id in & sigil ctx"); + + eval qq[ *$xFC ]; + is($@, "", "252 character glob ident ok"); + eval qq[ *$xFD ]; + like($@, qr/Identifier too long/, "too long id in glob ctx"); + + eval qq[ for $xFD ]; + like($@, qr/Missing \$ on loop variable/, + "253 char id ok, but a different error"); + eval qq[ for $xFE; ]; + like($@, qr/Identifier too long/, "too long id in for ctx"); + + # the specific case from the ticket + my $x = "x" x 257; + eval qq[ for $x ]; + like($@, qr/Identifier too long/, "too long id ticket case"); +} + +{ + eval qq[ {sub zlonk} ]; + is($@, '', 'sub declaration followed by a closing curly'); +} + # Add new tests HERE: # More awkward tests for #line. Keep these at the end, as they will screw