3 # "This IS structured code. It's just randomly structured."
24 print "#1\t:$foo: == 2\n";
25 if ($foo == 2) {print "ok 1\n";} else {print "not ok 1\n";}
29 print "#2\t:$foo: == 4\n";
30 if ($foo == 4) {print "ok 2\n";} else {print "not ok 2\n";}
32 $PERL = ($^O eq 'MSWin32') ? '.\perl' : ($^O eq 'MacOS') ? $^X : ($^O eq 'NetWare') ? 'perl' : './perl';
33 $CMD = qq[$PERL -e "goto foo;" 2>&1 ];
36 if ($x =~ /label/) {print "ok 3\n";} else {print "not ok 3\n";}
59 # does goto LABEL handle block contexts correctly?
80 # Does goto work correctly within a for(;;) loop?
81 # (BUG ID 20010309.004)
86 label: print (defined $x?"ok ": "not ok ", "17\n")
89 # Does goto work correctly going *to* a for(;;) loop?
90 # (make sure it doesn't skip the initializer)
93 FORL1: for($y="ok 18\n"; $z;) {print $y; goto TEST19}
94 ($y,$z) = ("not ok 18\n", 1);
97 # Even from within the loop?
100 FORL2: for($y="ok 19\n"; 1;) {
105 ($y, $z) = ("not ok 19\n", 1);
109 # Does goto work correctly within a try block?
110 # (BUG ID 20000313.004)
116 LABEL20: $ok = 1 if $variable;
118 print ($ok&&!$@ ? "ok 20\n" : "not ok 20\n");
120 # And within an eval-string?
127 LABEL21: $ok = 1 if $variable;
129 print ($ok&&!$@ ? "ok 21\n" : "not ok 21\n");
132 # Test that goto works in nested eval-string
145 print ($ok ? "ok 22\n" : "not ok 22\n");
152 # Test autoloading mechanism.
155 ($pack, $file, $line) = caller; # Should indicate original call stats.
156 print "@_ $pack $file $line" eq "1 2 3 main $FILE $LINE"
163 sub one { print "ok 6\n"; goto &two; print "not ok 6\n"; }
169 $LINE = __LINE__ + 1;
173 eval { goto $wherever };
174 print $@ =~ /Can't find label NOWHERE/ ? "ok 8\n" : "not ok 8\n";
176 # see if a modified @_ propagates
179 sub DESTROY { my $s = shift; print "ok $s->[0]\n"; }
180 sub show { print "# @_\nnot ok $_[0][0]\n" if @_ != 5; }
181 sub start { push @_, 1, "foo", {}; goto &show; }
182 for (9..11) { start(bless([$_]), 'bar'); }
189 sub AUTOLOAD { print @_ }