summaryrefslogtreecommitdiff
path: root/t/op/goto.t
diff options
context:
space:
mode:
Diffstat (limited to 't/op/goto.t')
-rw-r--r--t/op/goto.t76
1 files changed, 75 insertions, 1 deletions
diff --git a/t/op/goto.t b/t/op/goto.t
index a98e35496d..12bade9b13 100644
--- a/t/op/goto.t
+++ b/t/op/goto.t
@@ -10,7 +10,7 @@ BEGIN {
use warnings;
use strict;
-plan tests => 68;
+plan tests => 74;
our $TODO;
my $deprecated = 0;
@@ -489,3 +489,77 @@ die "You can't get here";
wham_eth: 1 if 0;
ouch_eth: pass('labels persist even if their statement is optimised away');
+
+$foo = "(0)";
+if($foo eq $foo) {
+ goto bungo;
+}
+$foo .= "(9)";
+bungo:
+format CHOLET =
+wellington
+.
+$foo .= "(1)";
+my $cholet;
+open(CHOLET, ">", \$cholet);
+write CHOLET;
+close CHOLET;
+$foo .= "(".$cholet.")";
+is($foo, "(0)(1)(wellington\n)", "label before format decl");
+
+$foo = "(A)";
+if($foo eq $foo) {
+ goto orinoco;
+}
+$foo .= "(X)";
+orinoco:
+sub alderney { return "tobermory"; }
+$foo .= "(B)";
+$foo .= "(".alderney().")";
+is($foo, "(A)(B)(tobermory)", "label before sub decl");
+
+$foo = "[0:".__PACKAGE__."]";
+if($foo eq $foo) {
+ goto bulgaria;
+}
+$foo .= "[9]";
+bulgaria:
+package Tomsk;
+$foo .= "[1:".__PACKAGE__."]";
+$foo .= "[2:".__PACKAGE__."]";
+package main;
+$foo .= "[3:".__PACKAGE__."]";
+is($foo, "[0:main][1:Tomsk][2:Tomsk][3:main]", "label before package decl");
+
+$foo = "[A:".__PACKAGE__."]";
+if($foo eq $foo) {
+ goto adelaide;
+}
+$foo .= "[Z]";
+adelaide:
+package Cairngorm {
+ $foo .= "[B:".__PACKAGE__."]";
+}
+$foo .= "[C:".__PACKAGE__."]";
+is($foo, "[A:main][B:Cairngorm][C:main]", "label before package block");
+
+our $obidos;
+$foo = "{0}";
+if($foo eq $foo) {
+ goto shansi;
+}
+$foo .= "{9}";
+shansi:
+BEGIN { $obidos = "x"; }
+$foo .= "{1$obidos}";
+is($foo, "{0}{1x}", "label before BEGIN block");
+
+$foo = "{A:".(1.5+1.5)."}";
+if($foo eq $foo) {
+ goto stepney;
+}
+$foo .= "{Z}";
+stepney:
+use integer;
+$foo .= "{B:".(1.5+1.5)."}";
+is($foo, "{A:3}{B:2}", "label before use decl");