integrate cfgperl contents into mainline
[p5sagit/p5-mst-13.2.git] / t / op / each.t
index b92dd17..879c0d0 100755 (executable)
@@ -1,8 +1,6 @@
 #!./perl
 
-# $RCSfile: each.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:47 $
-
-print "1..14\n";
+print "1..19\n";
 
 $h{'abc'} = 'ABC';
 $h{'def'} = 'DEF';
@@ -43,7 +41,8 @@ if ($#keys == 29 && $#values == 29) {print "ok 1\n";} else {print "not ok 1\n";}
 $i = 0;                # stop -w complaints
 
 while (($key,$value) = each(%h)) {
-    if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
+    if ($key eq $keys[$i] && $value eq $values[$i]
+        && (('a' lt 'A' && $key lt $value) || $key gt $value)) {
        $key =~ y/a-z/A-Z/;
        $i++ if $key eq $value;
     }
@@ -107,3 +106,28 @@ print "ok 13\n";
 print "not " if keys(%hash) != 10;
 print "ok 14\n";
 
+print keys(hash) != 10 ? "not ok 15\n" : "ok 15\n";
+
+$i = 0;
+%h = (a => A, b => B, c=> C, d => D, abc => ABC);
+@keys = keys(h);
+@values = values(h);
+while (($key, $value) = each(h)) {
+       if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
+               $i++;
+       }
+}
+if ($i == 5) { print "ok 16\n" } else { print "not ok\n" }
+
+{
+    package Obj;
+    sub DESTROY { print "ok 18\n"; }
+    {
+       my $h = { A => bless [], __PACKAGE__ };
+        while (my($k,$v) = each %$h) {
+           print "ok 17\n" if $k eq 'A' and ref($v) eq 'Obj';
+       }
+    }
+    print "ok 19\n";
+}
+