3 # $RCSfile: each.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:47 $
9 $h{'jkl','mno'} = "JKL\034MNO";
10 $h{'a',2,3,4,5} = join("\034",'A',2,3,4,5);
41 if ($#keys == 29 && $#values == 29) {print "ok 1\n";} else {print "not ok 1\n";}
43 $i = 0; # stop -w complaints
45 while (($key,$value) = each(%h)) {
46 if ($key eq $keys[$i] && $value eq $values[$i]
47 && (('a' lt 'A' && $key lt $value) || $key gt $value)) {
49 $i++ if $key eq $value;
53 if ($i == 30) {print "ok 2\n";} else {print "not ok 2\n";}
55 @keys = ('blurfl', keys(%h), 'dyick');
56 if ($#keys == 31) {print "ok 3\n";} else {print "not ok 3\n";}
58 $size = ((split('/',scalar %h))[1]);
60 $newsize = ((split('/',scalar %h))[1]);
61 if ($newsize == $size * 8) {print "ok 4\n";} else {print "not ok 4\n";}
63 $size = ((split('/',scalar %h))[1]);
64 if ($size == $newsize) {print "ok 5\n";} else {print "not ok 5\n";}
66 $size = ((split('/',scalar %h))[1]);
67 if ($size == $newsize) {print "ok 6\n";} else {print "not ok 6\n";}
70 $size = ((split('/',scalar %h))[1]);
71 if ($size == 8) {print "ok 7\n";} else {print "not ok 7\n";}
76 $total += $key while $key = each %hash;
77 print "# Scalar each is bad.\nnot " unless $total == 100;
80 for (1..3) { @foo = each %hash }
83 $total += $key while $key = each %hash;
84 print "# Scalar keys isn't resetting the iterator.\nnot " if $total != 100;
87 for (1..3) { @foo = each %hash }
89 $total += $key while $key = each %hash;
90 print "# Iterator of each isn't being maintained.\nnot " if $total == 100;
93 for (1..3) { @foo = each %hash }
96 $total += $key while $key = each %hash;
97 print "# Scalar values isn't resetting the iterator.\nnot " if $total != 100;
100 $size = (split('/', scalar %hash))[1];
101 keys(%hash) = $size / 2;
102 print "not " if $size != (split('/', scalar %hash))[1];
104 keys(%hash) = $size + 100;
105 print "not " if $size == (split('/', scalar %hash))[1];
108 print "not " if keys(%hash) != 10;
111 print keys(hash) != 10 ? "not ok 15\n" : "ok 15\n";
114 %h = (a => A, b => B, c=> C, d => D, abc => ABC);
117 while (($key, $value) = each(h)) {
118 if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
122 if ($i == 5) { print "ok 16\n" } else { print "not ok\n" }