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] && $key eq lc($value)) {
48 $i++ if $key eq $value;
52 if ($i == 30) {print "ok 2\n";} else {print "not ok 2\n";}
54 @keys = ('blurfl', keys(%h), 'dyick');
55 if ($#keys == 31) {print "ok 3\n";} else {print "not ok 3\n";}
57 $size = ((split('/',scalar %h))[1]);
59 $newsize = ((split('/',scalar %h))[1]);
60 if ($newsize == $size * 8) {print "ok 4\n";} else {print "not ok 4\n";}
62 $size = ((split('/',scalar %h))[1]);
63 if ($size == $newsize) {print "ok 5\n";} else {print "not ok 5\n";}
65 $size = ((split('/',scalar %h))[1]);
66 if ($size == $newsize) {print "ok 6\n";} else {print "not ok 6\n";}
69 $size = ((split('/',scalar %h))[1]);
70 if ($size == 8) {print "ok 7\n";} else {print "not ok 7\n";}
75 $total += $key while $key = each %hash;
76 print "# Scalar each is bad.\nnot " unless $total == 100;
79 for (1..3) { @foo = each %hash }
82 $total += $key while $key = each %hash;
83 print "# Scalar keys isn't resetting the iterator.\nnot " if $total != 100;
86 for (1..3) { @foo = each %hash }
88 $total += $key while $key = each %hash;
89 print "# Iterator of each isn't being maintained.\nnot " if $total == 100;
92 for (1..3) { @foo = each %hash }
95 $total += $key while $key = each %hash;
96 print "# Scalar values isn't resetting the iterator.\nnot " if $total != 100;
99 $size = (split('/', scalar %hash))[1];
100 keys(%hash) = $size / 2;
101 print "not " if $size != (split('/', scalar %hash))[1];
103 keys(%hash) = $size + 100;
104 print "not " if $size == (split('/', scalar %hash))[1];
107 print "not " if keys(%hash) != 10;
110 print keys(hash) != 10 ? "not ok 15\n" : "ok 15\n";
113 %h = (a => A, b => B, c=> C, d => D, abc => ABC);
116 while (($key, $value) = each(h)) {
117 if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
121 if ($i == 5) { print "ok 16\n" } else { print "not ok\n" }