summaryrefslogtreecommitdiff
path: root/t/op/goto.t
diff options
context:
space:
mode:
authorRobin Houston <robin@cpan.org>2001-03-14 00:43:45 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-14 02:40:50 +0000
commit36c66720946952b050ad9db88444230a58b3c69d (patch)
tree695d8454479dd4db316880a24d7e7e4135014018 /t/op/goto.t
parent30def704cafa11862a4b1be8a6e882e725a22b02 (diff)
downloadperl-36c66720946952b050ad9db88444230a58b3c69d.tar.gz
Re: [ID 20010309.004] my-variables lose values while goto'ing within a for(;;)-loop
Message-ID: <20010314004345.A15892@puffinry.freeserve.co.uk> p4raw-id: //depot/perl@9139
Diffstat (limited to 't/op/goto.t')
-rwxr-xr-xt/op/goto.t32
1 files changed, 31 insertions, 1 deletions
diff --git a/t/op/goto.t b/t/op/goto.t
index 96bb8ddb55..246184c56b 100755
--- a/t/op/goto.t
+++ b/t/op/goto.t
@@ -2,7 +2,7 @@
# "This IS structured code. It's just randomly structured."
-print "1..16\n";
+print "1..19\n";
while ($?) {
$foo = 1;
@@ -76,6 +76,36 @@ for (1) {
}
}
print "ok 16\n";
+
+# Does goto work correctly within a for(;;) loop?
+# (BUG ID 20010309.004)
+
+for(my $i=0;!$i++;) {
+ my $x=1;
+ goto label;
+ label: print (defined $x?"ok ": "not ok ", "17\n")
+}
+
+# Does goto work correctly going *to* a for(;;) loop?
+# (make sure it doesn't skip the initializer)
+
+my ($z, $y) = (0);
+FORL1: for($y="ok 18\n"; $z;) {print $y; goto TEST19}
+($y,$z) = ("not ok 18\n", 1);
+goto FORL1;
+
+# Even from within the loop?
+
+TEST19: $z = 0;
+FORL2: for($y="ok 19\n"; 1;) {
+ if ($z) {
+ print $y;
+ last;
+ }
+ ($y, $z) = ("not ok 19\n", 1);
+ goto FORL2;
+}
+
exit;
bypass: