summaryrefslogtreecommitdiff
path: root/t/comp/retainedlines.t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-12-02 20:16:33 +0000
committerNicholas Clark <nick@ccl4.org>2008-12-02 20:16:33 +0000
commit99d3381e871dbd1d94b47516b4475d85b3935ac6 (patch)
tree9e7344caffd441d0918da0802cf3da5aac4cd396 /t/comp/retainedlines.t
parent21efc95700e8bb4aff8b05f9b9541dde292aec92 (diff)
downloadperl-99d3381e871dbd1d94b47516b4475d85b3935ac6.tar.gz
Codify the current behaviour of evals which define subroutines before
failing (due to syntax errors). p4raw-id: //depot/perl@34984
Diffstat (limited to 't/comp/retainedlines.t')
-rw-r--r--t/comp/retainedlines.t23
1 files changed, 22 insertions, 1 deletions
diff --git a/t/comp/retainedlines.t b/t/comp/retainedlines.t
index b0f999fa53..14e6d04314 100644
--- a/t/comp/retainedlines.t
+++ b/t/comp/retainedlines.t
@@ -10,7 +10,7 @@ BEGIN {
use strict;
-plan (tests => 55);
+plan (tests => 57);
$^P = 0xA;
@@ -54,6 +54,27 @@ for my $sep (' ', "\0") {
$name++;
}
+{
+ # This contains a syntax error
+ my $prog = "sub $name {
+ 'This is $name'
+ }
+1 +
+";
+
+ eval $prog and die;
+
+ is (eval "$name()", "This is $name", "Subroutine was compiled, despite error")
+ or diag $@;
+
+ my @after = grep { /eval/ } keys %::;
+
+ is (@after, 0 + keys %seen,
+ "current behaviour is that errors in eval trump subroutine definitions");
+
+ $name++;
+}
+
foreach my $flags (0x0, 0x800, 0x1000, 0x1800) {
local $^P = $^P | $flags;
# This is easier if we accept that the guts eval will add a trailing \n