like $@, "^Identifier too long at ", 'ident buffer overflow';
eval'for my a1b $i (1) {}';
# ng: 'Missing $ on loop variable'
like $@, "^No such class a1b at ", 'TYPE of my of for statement';
eval'method {} {$_,undef}';
like $@, qq/^Can't call method "method" on unblessed reference at /,
'method BLOCK {...} does not try to disambiguate';
eval'#line 1 maggapom
if($a>3) { $a++; }
else{printf(1/0);}';
is $@, "Illegal division by zero at maggapom line 2.\n",
'else {foo} line number (no space after {) [perl #122695]';
# parentheses needed for this to fail an assertion in S_maybe_multideref
is +(${[{a=>214}]}[0])->{a}, 214, '($array[...])->{...}';
# This used to fail an assertion because of the OPf_SPECIAL flag on an
# OP_GV that started out as an OP_CONST.
subFILE1 () { 1 }
subdummy { tellFILE1 }
# More potential multideref assertion failures
# OPf_PARENS on OP_RV2SV in subscript
$x[($_)];
is(1,1, "PASS: Previous line successfully parsed. OPf_PARENS on OP_RV2SV");
# OPf_SPECIAL on OP_GV in subscript
$x[FILE1->[0]];
is(1,1, "PASS: Previous line successfully parsed. OPf_SPECIAL on OP_GV");
# Used to crash [perl #123542]
eval's /${<>{}) //';
# Also used to crash [perl #123652]
eval{$1=eval{a:}};
# Used to fail assertions [perl #123753]
eval"map+map";
eval"grep+grep";
# ALso failed an assertion [perl #123848]
{
local$SIG{__WARN__} = sub{};
eval'my $_; m// ~~ 0';
}
# Used to crash [perl #125679]
eval'BEGIN {$^H=-1} \eval=time';
# Used to fail an assertion [perl #129073]
{
local$SIG{__WARN__} = sub{};
eval'${p{};sub p}()';
}
# RT #124207 syntax error during stringify can leave stringify op
# with multiple children and assertion failures
eval'qq{@{0]}${}},{})';
is(1, 1, "RT #124207");
# RT #127993 version control conflict markers
" this should keep working
<<<<<<<
" =~ /
>>>>>>>
/;
formy$marker(qw(
<<<<<<<
=======
>>>>>>>
)) {
eval"$marker";
like $@, qr/^Version control conflict marker at \(eval \d+\) line 1, near "$marker"/, "VCS marker '$marker' at beginning";
eval"\$_\n$marker";
like $@, qr/^Version control conflict marker at \(eval \d+\) line 2, near "$marker"/, "VCS marker '$marker' after value";
eval"\n\$_ =\n$marker";
like $@, qr/^Version control conflict marker at \(eval \d+\) line 3, near "$marker"/, "VCS marker '$marker' after operator";
}
# keys assignments in weird contexts (mentioned in perl #128260)
eval'keys(%h) .= "00"';
is $@, "", 'keys .=';
eval'sub { read $fh, keys %h, 0 }';
is $@, "", 'read into keys';
eval'substr keys(%h),0,=3';
is $@, "", 'substr keys assignment';
{ # very large utf8 char in error message was overflowing buffer
if(lengthsprintf("%x", ~0) <= 8) {
is 1, 1, "skip because overflows on 32-bit machine";
}
else{
nowarnings;
eval"q". chr(100000000064);
like $@, qr/Can't find string terminator "."anywhere beforeEOF/,
'RT 128952';
}
}
# RT #130311: many parser shifts before a reduce
{
eval'['. ('{'x 300);
like $@, qr/Missing right curly or square bracket/, 'RT #130311';
}
# RT #130815: crash in ck_return for malformed code
{
eval'm(@{if(0){sub d{]]])}return';
like $@, qr/^syntax error at \(eval \d+\) line 1, near "\{\]"/,
'RT #130815: null pointer deref';
}
# Add new tests HERE (above this line)
# bug #74022: Loop on characters in \p{OtherIDContinue}
# This test hangs if it fails.
evalchr0x387; # forces loading of utf8.pm
is(1,1, '[perl #74022] Parser looping on OtherIDContinue chars');
# More awkward tests for #line. Keep these at the end, as they will screw
# with sane line reporting for any other test failures
subcheck ($$$) {
my($file, $line, $name) = @_;
my(undef, $got_file, $got_line) = caller;
like ($got_file, $file, "file of $name");
is ($got_line, $line, "line of $name");
}
my$this_file= qr/parser\.t(?:\.[bl]eb?)?$/;
#line 3
1 unless
1;
check($this_file, 5, "[perl #118931]");
#line 3
check($this_file, 3, "bare line");
# line 5
check($this_file, 5, "bare line with leading space");
#line 7
check($this_file, 7, "trailing space still valid");
# line 11
check($this_file, 11, "leading and trailing");
# line 13
check($this_file, 13, "leading tab");
#line 17
check($this_file, 17, "middle tab");
#line 19
check($this_file, 19, "loadsaspaces");
#line 23 KASHPRITZA
check(qr/^KASHPRITZA$/, 23, "bare filename");
#line 29 "KAHEEEE"
check(qr/^KAHEEEE$/, 29, "filename in quotes");
#line 31 "CLINK CLOINK BZZT"
check(qr/^CLINK CLOINK BZZT$/, 31, "filename with spaces in quotes");
#line 37 "THOOM THOOM"
check(qr/^THOOM THOOM$/, 37, "filename with tabs in quotes");
#line 41 "GLINK PLINK GLUNK DINK"
check(qr/^GLINK PLINK GLUNK DINK$/, 41, "a space after the quotes");
#line 43 "BBFRPRAFPGHPP
check(qr/^"BBFRPRAFPGHPP$/, 43, "actually missing a quote is still valid");
#line 47 bang eth
check(qr/^"BBFRPRAFPGHPP$/, 46, "but spaces aren't allowed without quotes");
#line 77sevenseven
check(qr/^"BBFRPRAFPGHPP$/, 49, "need a space afterthe line number");
eval<<'EOSTANZA'; die$@ if$@;
#line 51 "With wonderful deathless ditties|We build up the world's great cities,|And out of a fabulous story|We fashion an empire's glory:|One man with a dream, at pleasure,|Shall go forth and conquer a crown;|And three with a new song's measure|Can trample a kingdom down."
check(qr/^With.*down\.$/, 51, "Overflow the second small buffer check");
EOSTANZA
# And now, turn on the debugger flag for long names
$^P = 0x100;
#line 53 "For we are afar with the dawning|And the suns that are not yet high,|And out of the infinite morning|Intrepid you hear us cry-|How, spite of your human scorning,|Once more God's future draws nigh,|And already goes forth the warning|That ye of the past must die."
check(qr/^For we.*must die\.$/, 53, "Our long line is set up");
eval<<'EOT'; die$@ if$@;
#line 59 " "
check(qr/^ $/, 59, "Overflow the first small buffer check only");
EOT
eval<<'EOSTANZA'; die$@ if$@;
#line 61 "Great hail! we cry to the comers|From the dazzling unknown shore;|Bring us hither your sun and your summers;|And renew our world as of yore;|You shall teach us your song's new numbers,|And things that we dreamed not before:|Yea, in spite of a dreamer who slumbers,|And a singer who sings no more."
check(qr/^Great hail!.*no more\.$/, 61, "Overflow both small buffer checks");
EOSTANZA
subcheck_line ($$) {
my($line, $name) = @_;
my(undef, undef, $got_line) = caller;
is ($got_line, $line, $name);
}
#line 531 parser.t
<<EOU; check_line(531, 'on same line as heredoc');
EOU
s//<<EOV/e if0;
EOV
check_line(535, 'after here-doc in quotes');
<<EOW; <<EOX;
${check_line(537, 'first line of interp in here-doc');;
check_line(538, 'second line of interp in here-doc');}
EOW
${check_line(540, 'first line of interp in second here-doc on same line');;
check_line(541, 'second line of interp in second heredoc on same line');}
EOX
eval<<'EVAL';
#line 545
"${<<EOY; <<EOZ}";
${check_line(546, 'first line of interp in here-doc in quotes in eval');;
check_line(547, 'second line of interp in here-doc in quotes in eval');}
EOY
${check_line(549, '1st line of interp in 2nd hd, same line in q in eval');;
check_line(550, '2nd line of interp in 2nd hd, same line in q in eval');}
EOZ
EVAL
time
#line 42
;check_line(42, 'line number after "nullary\n#line"');
"${
#line 53
_}";
check_line(54, 'line number after qq"${#line}"');
#line 24
"
${check_line(25, 'line number inside qq/<newline>${...}/')}";
<<"END";
${;
#line 625
}
END
check_line(627, 'line number after heredoc containing #line');
#line 638
<<ENE . ${
ENE
"bar"};
check_line(642, 'line number after ${expr} surrounding heredoc body');
__END__
# Don't add new tests HERE. See "Add new tests HERE" above.
Keyboard Shortcuts
Global
s
Focus search bar
?
Bring up this help dialog
GitHub
gp
Go to pull requests
gi
go to github issues (only if github is preferred repository)