From: Nicholas Clark Date: Tue, 2 Dec 2008 20:16:33 +0000 (+0000) Subject: Codify the current behaviour of evals which define subroutines before X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=99d3381e871dbd1d94b47516b4475d85b3935ac6;p=p5sagit%2Fp5-mst-13.2.git Codify the current behaviour of evals which define subroutines before failing (due to syntax errors). p4raw-id: //depot/perl@34984 --- diff --git a/t/comp/retainedlines.t b/t/comp/retainedlines.t index b0f999f..14e6d04 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