Commit | Line | Data |
---|---|---|
a687059c LW |
1 | #!./perl |
2 | ||
79072805 | 3 | # $RCSfile: range.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:14 $ |
a687059c | 4 | |
0f85fab0 | 5 | print "1..8\n"; |
a687059c LW |
6 | |
7 | print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n"; | |
8 | ||
9 | @foo = (1,2,3,4,5,6,7,8,9); | |
10 | @foo[2..4] = ('c','d','e'); | |
11 | ||
12 | print join(':',@foo[$foo[0]..5]) eq '2:c:d:e:6' ? "ok 2\n" : "not ok 2\n"; | |
13 | ||
14 | @bar[2..4] = ('c','d','e'); | |
15 | print join(':',@bar[1..5]) eq ':c:d:e:' ? "ok 3\n" : "not ok 3\n"; | |
16 | ||
17 | ($a,@bcd[0..2],$e) = ('a','b','c','d','e'); | |
18 | print join(':',$a,@bcd[0..2],$e) eq 'a:b:c:d:e' ? "ok 4\n" : "not ok 4\n"; | |
19 | ||
20 | $x = 0; | |
21 | for (1..100) { | |
22 | $x += $_; | |
23 | } | |
24 | print $x == 5050 ? "ok 5\n" : "not ok 5 $x\n"; | |
25 | ||
26 | $x = 0; | |
27 | for ((100,2..99,1)) { | |
28 | $x += $_; | |
29 | } | |
30 | print $x == 5050 ? "ok 6\n" : "not ok 6 $x\n"; | |
0f85fab0 LW |
31 | |
32 | $x = join('','a'..'z'); | |
33 | print $x eq 'abcdefghijklmnopqrstuvwxyz' ? "ok 7\n" : "not ok 7 $x\n"; | |
34 | ||
35 | @x = 'A'..'ZZ'; | |
36 | print @x == 27 * 26 ? "ok 8\n" : "not ok 8\n"; |