Commit | Line | Data |
93a17b20 |
1 | #!./perl |
2 | |
a6006777 |
3 | # $RCSfile: my.t,v $ |
93a17b20 |
4 | |
a6006777 |
5 | print "1..28\n"; |
93a17b20 |
6 | |
7 | sub foo { |
8 | my($a, $b) = @_; |
9 | my $c; |
10 | my $d; |
11 | $c = "ok 3\n"; |
12 | $d = "ok 4\n"; |
13 | { my($a,$c) = ("ok 9\n", "ok 10\n"); ($x, $y) = ($a, $c); } |
14 | print $a, $b; |
15 | $c . $d; |
16 | } |
17 | |
18 | $a = "ok 5\n"; |
19 | $b = "ok 6\n"; |
20 | $c = "ok 7\n"; |
21 | $d = "ok 8\n"; |
22 | |
23 | print &foo("ok 1\n","ok 2\n"); |
24 | |
25 | print $a,$b,$c,$d,$x,$y; |
26 | |
27 | # same thing, only with arrays and associative arrays |
28 | |
29 | sub foo2 { |
30 | my($a, @b) = @_; |
31 | my(@c, %d); |
32 | @c = "ok 13\n"; |
33 | $d{''} = "ok 14\n"; |
34 | { my($a,@c) = ("ok 19\n", "ok 20\n"); ($x, $y) = ($a, @c); } |
35 | print $a, @b; |
36 | $c[0] . $d{''}; |
37 | } |
38 | |
39 | $a = "ok 15\n"; |
40 | @b = "ok 16\n"; |
41 | @c = "ok 17\n"; |
42 | $d{''} = "ok 18\n"; |
43 | |
44 | print &foo2("ok 11\n","ok 12\n"); |
45 | |
46 | print $a,@b,@c,%d,$x,$y; |
a6006777 |
47 | |
48 | my $i = "outer"; |
49 | |
50 | if (my $i = "inner") { |
51 | print "not " if $i ne "inner"; |
52 | } |
53 | print "ok 21\n"; |
54 | |
55 | if ((my $i = 1) == 0) { |
56 | print "not "; |
57 | } |
58 | else { |
59 | print "not" if $i != 1; |
60 | } |
61 | print "ok 22\n"; |
62 | |
63 | my $j = 5; |
64 | while (my $i = --$j) { |
65 | print("not "), last unless $i > 0; |
66 | } |
67 | continue { |
68 | print("not "), last unless $i > 0; |
69 | } |
70 | print "ok 23\n"; |
71 | |
72 | $j = 5; |
73 | for (my $i = 0; (my $k = $i) < $j; ++$i) { |
74 | print("not "), last unless $i >= 0 && $i < $j && $i == $k; |
75 | } |
76 | print "ok 24\n"; |
77 | print "not " if defined $k; |
78 | print "ok 25\n"; |
79 | |
80 | foreach my $i (26, 27) { |
81 | print "ok $i\n"; |
82 | } |
83 | |
84 | print "not " if $i ne "outer"; |
85 | print "ok 28\n"; |