[shell changes from patch from perl5.003_16 to perl5.003_17]
[p5sagit/p5-mst-13.2.git] / t / op / each.t
1 #!./perl
2
3 # $RCSfile: each.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:47 $
4
5 print "1..7\n";
6
7 $h{'abc'} = 'ABC';
8 $h{'def'} = 'DEF';
9 $h{'jkl','mno'} = "JKL\034MNO";
10 $h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
11 $h{'a'} = 'A';
12 $h{'b'} = 'B';
13 $h{'c'} = 'C';
14 $h{'d'} = 'D';
15 $h{'e'} = 'E';
16 $h{'f'} = 'F';
17 $h{'g'} = 'G';
18 $h{'h'} = 'H';
19 $h{'i'} = 'I';
20 $h{'j'} = 'J';
21 $h{'k'} = 'K';
22 $h{'l'} = 'L';
23 $h{'m'} = 'M';
24 $h{'n'} = 'N';
25 $h{'o'} = 'O';
26 $h{'p'} = 'P';
27 $h{'q'} = 'Q';
28 $h{'r'} = 'R';
29 $h{'s'} = 'S';
30 $h{'t'} = 'T';
31 $h{'u'} = 'U';
32 $h{'v'} = 'V';
33 $h{'w'} = 'W';
34 $h{'x'} = 'X';
35 $h{'y'} = 'Y';
36 $h{'z'} = 'Z';
37
38 @keys = keys %h;
39 @values = values %h;
40
41 if ($#keys == 29 && $#values == 29) {print "ok 1\n";} else {print "not ok 1\n";}
42
43 $i = 0;         # stop -w complaints
44
45 while (($key,$value) = each(%h)) {
46     if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
47         $key =~ y/a-z/A-Z/;
48         $i++ if $key eq $value;
49     }
50 }
51
52 if ($i == 30) {print "ok 2\n";} else {print "not ok 2\n";}
53
54 @keys = ('blurfl', keys(%h), 'dyick');
55 if ($#keys == 31) {print "ok 3\n";} else {print "not ok 3\n";}
56
57 $size = ((split('/',scalar %h))[1]);
58 keys %h = $size * 5;
59 $newsize = ((split('/',scalar %h))[1]);
60 if ($newsize == $size * 8) {print "ok 4\n";} else {print "not ok 4\n";}
61 keys %h = 1;
62 $size = ((split('/',scalar %h))[1]);
63 if ($size == $newsize) {print "ok 5\n";} else {print "not ok 5\n";}
64 %h = (1,1);
65 $size = ((split('/',scalar %h))[1]);
66 if ($size == $newsize) {print "ok 6\n";} else {print "not ok 6\n";}
67 undef %h;
68 %h = (1,1);
69 $size = ((split('/',scalar %h))[1]);
70 if ($size == 8) {print "ok 7\n";} else {print "not ok 7\n";}