Suppress a few compilation warnings in pp_hot.c.
[p5sagit/p5-mst-13.2.git] / t / cmd / switch.t
CommitLineData
a687059c 1#!./perl
2
79072805 3# $RCSfile: switch.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:14 $
a687059c 4
5print "1..18\n";
6
7sub foo1 {
8 $_ = shift(@_);
9 $a = 0;
10 until ($a++) {
11 next if $_ eq 1;
12 next if $_ eq 2;
13 next if $_ eq 3;
14 next if $_ eq 4;
15 return 20;
16 }
17 continue {
18 return $_;
19 }
20}
21
22print do foo1(0) == 20 ? "ok 1\n" : "not ok 1\n";
23print do foo1(1) == 1 ? "ok 2\n" : "not ok 2\n";
24print do foo1(2) == 2 ? "ok 3\n" : "not ok 3\n";
25print do foo1(3) == 3 ? "ok 4\n" : "not ok 4\n";
26print do foo1(4) == 4 ? "ok 5\n" : "not ok 5\n";
27print do foo1(5) == 20 ? "ok 6\n" : "not ok 6\n";
28
29sub foo2 {
30 $_ = shift(@_);
31 {
32 last if $_ == 1;
33 last if $_ == 2;
34 last if $_ == 3;
35 last if $_ == 4;
36 }
37 continue {
38 return 20;
39 }
40 return $_;
41}
42
79072805 43print do foo2(0) == 20 ? "ok 7\n" : "not ok 7\n";
a687059c 44print do foo2(1) == 1 ? "ok 8\n" : "not ok 8\n";
45print do foo2(2) == 2 ? "ok 9\n" : "not ok 9\n";
46print do foo2(3) == 3 ? "ok 10\n" : "not ok 10\n";
47print do foo2(4) == 4 ? "ok 11\n" : "not ok 11\n";
48print do foo2(5) == 20 ? "ok 12\n" : "not ok 12\n";
49
50sub foo3 {
51 $_ = shift(@_);
52 if (/^1/) {
53 return 1;
54 }
55 elsif (/^2/) {
56 return 2;
57 }
58 elsif (/^3/) {
59 return 3;
60 }
61 elsif (/^4/) {
62 return 4;
63 }
64 else {
65 return 20;
66 }
67 return 40;
68}
69
70print do foo3(0) == 20 ? "ok 13\n" : "not ok 13\n";
71print do foo3(1) == 1 ? "ok 14\n" : "not ok 14\n";
72print do foo3(2) == 2 ? "ok 15\n" : "not ok 15\n";
73print do foo3(3) == 3 ? "ok 16\n" : "not ok 16\n";
74print do foo3(4) == 4 ? "ok 17\n" : "not ok 17\n";
75print do foo3(5) == 20 ? "ok 18\n" : "not ok 18\n";