Make C<undef ~~ 0> and C<undef ~~ ""> not match (like in 5.10.0)
[p5sagit/p5-mst-13.2.git] / t / op / goto.t
old mode 100755 (executable)
new mode 100644 (file)
index 7f502bd..c79b424
@@ -10,7 +10,8 @@ BEGIN {
 
 use warnings;
 use strict;
-plan tests => 56;
+plan tests => 58;
+our $TODO;
 
 our $foo;
 while ($?) {
@@ -204,7 +205,7 @@ is($ok, 1, 'goto in for(;;) with continuation');
 
 # bug #22299 - goto in require doesn't find label
 
-open my $f, ">goto01.pm" or die;
+open my $f, ">Op_goto01.pm" or die;
 print $f <<'EOT';
 package goto01;
 goto YYY;
@@ -214,9 +215,9 @@ YYY: print "OK\n";
 EOT
 close $f;
 
-$r = runperl(prog => 'use goto01; print qq[DONE\n]');
+$r = runperl(prog => 'use Op_goto01; print qq[DONE\n]');
 is($r, "OK\nDONE\n", "goto within use-d file"); 
-unlink "goto01.pm";
+unlink "Op_goto01.pm";
 
 # test for [perl #24108]
 $ok = 1;
@@ -416,16 +417,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 +437,25 @@ 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");
+}
+
+TODO: {
+    local $TODO = "[perl #43403] goto() from an if to an else doesn't undo local () changes";
+    our $global = "unmodified";
+    if ($global) { # true but not constant-folded
+         local $global = "modified";
+         goto ELSE;
+    } else {
+         ELSE: is($global, "unmodified");
+    }
+}
+