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' : './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);
114 # Test autoloading mechanism.
117 ($pack, $file, $line) = caller; # Should indicate original call stats.
118 print "@_ $pack $file $line" eq "1 2 3 main $FILE $LINE"
125 sub one { print "ok 6\n"; goto &two; print "not ok 6\n"; }
131 $LINE = __LINE__ + 1;
135 eval { goto $wherever };
136 print $@ =~ /Can't find label NOWHERE/ ? "ok 8\n" : "not ok 8\n";
138 # see if a modified @_ propagates
141 sub DESTROY { my $s = shift; print "ok $s->[0]\n"; }
142 sub show { print "# @_\nnot ok $_[0][0]\n" if @_ != 5; }
143 sub start { push @_, 1, "foo", {}; goto &show; }
144 for (9..11) { start(bless([$_]), 'bar'); }
151 sub AUTOLOAD { print @_ }