X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Feval.t;h=d64504c1ee89442de534bc282951ef8670186eaf;hb=0dd3f902b059d48560ea071c6510375fd9426efb;hp=8e8f69c0b8cb35b96b68ed50d9f88dedd1d35031;hpb=7e736055d1d6da7ec885d3dacef1bcc5e5ef4282;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/eval.t b/t/op/eval.t index 8e8f69c..d64504c 100755 --- a/t/op/eval.t +++ b/t/op/eval.t @@ -5,7 +5,7 @@ BEGIN { @INC = '../lib'; } -print "1..87\n"; +print "1..92\n"; eval 'print "ok 1\n";'; @@ -419,3 +419,33 @@ $test++; $test++; } } + +sub Foo {} print Foo(eval {}); +print "ok ",$test++," - #20798 (used to dump core)\n"; + +# check for context in string eval +{ + my(@r,$r,$c); + sub context { defined(wantarray) ? (wantarray ? ($c='A') : ($c='S')) : ($c='V') } + + my $code = q{ context() }; + @r = qw( a b ); + $r = 'ab'; + @r = eval $code; + print "@r$c" eq 'AA' ? "ok " : "# '@r$c' ne 'AA'\nnot ok ", $test++, "\n"; + $r = eval $code; + print "$r$c" eq 'SS' ? "ok " : "# '$r$c' ne 'SS'\nnot ok ", $test++, "\n"; + eval $code; + print $c eq 'V' ? "ok " : "# '$c' ne 'V'\nnot ok ", $test++, "\n"; +} + +# [perl #34682] escaping an eval with last could coredump or dup output + +$got = runperl ( + prog => + 'sub A::TIEARRAY { L: { eval { last L } } } tie @a, A; warn qq(ok\n)', +stderr => 1); + +print "not " unless $got eq "ok\n"; +print "ok $test - eval and last\n"; $test++; +