Commit | Line | Data |
---|---|---|
a687059c LW |
1 | #!./perl |
2 | ||
a687059c LW |
3 | print "1..18\n"; |
4 | ||
5 | sub foo1 { | |
6 | $_ = shift(@_); | |
7 | $a = 0; | |
8 | until ($a++) { | |
9 | next if $_ eq 1; | |
10 | next if $_ eq 2; | |
11 | next if $_ eq 3; | |
12 | next if $_ eq 4; | |
13 | return 20; | |
14 | } | |
15 | continue { | |
16 | return $_; | |
17 | } | |
18 | } | |
19 | ||
2a70d4f6 NC |
20 | print foo1(0) == 20 ? "ok 1\n" : "not ok 1\n"; |
21 | print foo1(1) == 1 ? "ok 2\n" : "not ok 2\n"; | |
22 | print foo1(2) == 2 ? "ok 3\n" : "not ok 3\n"; | |
23 | print foo1(3) == 3 ? "ok 4\n" : "not ok 4\n"; | |
24 | print foo1(4) == 4 ? "ok 5\n" : "not ok 5\n"; | |
25 | print foo1(5) == 20 ? "ok 6\n" : "not ok 6\n"; | |
a687059c LW |
26 | |
27 | sub foo2 { | |
28 | $_ = shift(@_); | |
29 | { | |
30 | last if $_ == 1; | |
31 | last if $_ == 2; | |
32 | last if $_ == 3; | |
33 | last if $_ == 4; | |
34 | } | |
35 | continue { | |
36 | return 20; | |
37 | } | |
38 | return $_; | |
39 | } | |
40 | ||
2a70d4f6 NC |
41 | print foo2(0) == 20 ? "ok 7\n" : "not ok 7\n"; |
42 | print foo2(1) == 1 ? "ok 8\n" : "not ok 8\n"; | |
43 | print foo2(2) == 2 ? "ok 9\n" : "not ok 9\n"; | |
44 | print foo2(3) == 3 ? "ok 10\n" : "not ok 10\n"; | |
45 | print foo2(4) == 4 ? "ok 11\n" : "not ok 11\n"; | |
46 | print foo2(5) == 20 ? "ok 12\n" : "not ok 12\n"; | |
a687059c LW |
47 | |
48 | sub foo3 { | |
49 | $_ = shift(@_); | |
50 | if (/^1/) { | |
51 | return 1; | |
52 | } | |
53 | elsif (/^2/) { | |
54 | return 2; | |
55 | } | |
56 | elsif (/^3/) { | |
57 | return 3; | |
58 | } | |
59 | elsif (/^4/) { | |
60 | return 4; | |
61 | } | |
62 | else { | |
63 | return 20; | |
64 | } | |
65 | return 40; | |
66 | } | |
67 | ||
2a70d4f6 NC |
68 | print foo3(0) == 20 ? "ok 13\n" : "not ok 13\n"; |
69 | print foo3(1) == 1 ? "ok 14\n" : "not ok 14\n"; | |
70 | print foo3(2) == 2 ? "ok 15\n" : "not ok 15\n"; | |
71 | print foo3(3) == 3 ? "ok 16\n" : "not ok 16\n"; | |
72 | print foo3(4) == 4 ? "ok 17\n" : "not ok 17\n"; | |
73 | print foo3(5) == 20 ? "ok 18\n" : "not ok 18\n"; |