Change 28404 broke the construct s/foo/<<BAR/e. So, try to be more
[p5sagit/p5-mst-13.2.git] / t / op / goto.t
index 7f502bd..a034682 100755 (executable)
@@ -10,7 +10,7 @@ BEGIN {
 
 use warnings;
 use strict;
-plan tests => 56;
+plan tests => 57;
 
 our $foo;
 while ($?) {
@@ -416,16 +416,16 @@ a32039();
     my $r = runperl(
                stderr => 1,
                prog =>
-'for ($_=0;$_<3;$_++){A: if($_==1){next} if($_==2){$_++;goto A}}print qq(ok)'
+'for ($_=0;$_<3;$_++){A: if($_==1){next} if($_==2){$_++;goto A}}print qq(ok\n)'
     );
-    is($r, "ok", 'next and goto');
+    is($r, "ok\n", 'next and goto');
 
     $r = runperl(
                stderr => 1,
                prog =>
-'for ($_=0;$_<3;$_++){A: if($_==1){$_++;redo} if($_==2){$_++;goto A}}print qq(ok)'
+'for ($_=0;$_<3;$_++){A: if($_==1){$_++;redo} if($_==2){$_++;goto A}}print qq(ok\n)'
     );
-    is($r, "ok", 'redo and goto');
+    is($r, "ok\n", 'redo and goto');
 }
 
 # goto &foo not allowed in evals
@@ -436,3 +436,13 @@ eval 'goto &null';
 like($@, qr/Can't goto subroutine from an eval-string/, 'eval string');
 eval { goto &null };
 like($@, qr/Can't goto subroutine from an eval-block/, 'eval block');
+
+# [perl #36521] goto &foo in warn handler could defeat recursion avoider
+
+{
+    my $r = runperl(
+               stderr => 1,
+               prog => 'my $d; my $w = sub { return if $d++; warn q(bar)}; local $SIG{__WARN__} = sub { goto &$w; }; warn q(foo);'
+    );
+    like($r, qr/bar/, "goto &foo in warn");
+}