@INC = '../lib';
}
-print "1..87\n";
+print "1..95\n";
eval 'print "ok 1\n";';
$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++;
+
+# eval undef should be the same as eval "" barring any warnings
+
+{
+ local $@ = "foo";
+ eval undef;
+ print "not " unless $@ eq "";
+ print "ok $test # eval undef \n"; $test++;
+}
+
+{
+ no warnings;
+ eval "/ /a;";
+ print "not " unless $@ =~ /^syntax error/;
+ print "ok $test # eval syntax error, no warnings \n"; $test++;
+}
+
+
+# a syntax error in an eval called magically 9eg vie tie or overload)
+# resulted in an assertion failure in S_docatch, since doeval had already
+# poppedthe EVAL context due to the failure, but S_docatch expected the
+# context to still be there.
+
+{
+ my $ok = 0;
+ package Eval1;
+ sub STORE { eval '('; $ok = 1 }
+ sub TIESCALAR { bless [] }
+
+ my $x;
+ tie $x, bless [];
+ $x = 1;
+ print "not " unless $ok;
+ print "ok $test # eval docatch \n"; $test++;
+}
+
+
+