[patch: perl@8211]VMS: add -Duseperlio capacity to configure.com
[p5sagit/p5-mst-13.2.git] / t / op / each.t
index 420fdc0..35792ab 100755 (executable)
@@ -1,8 +1,6 @@
 #!./perl
 
-# $RCSfile: each.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:47 $
-
-print "1..16\n";
+print "1..24\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;
     }
@@ -119,3 +118,41 @@ while (($key, $value) = each(h)) {
        }
 }
 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";
+}
+
+# Check for Unicode hash keys.
+%u = ("\x{12}", "f", "\x{123}", "fo", "\x{1234}",  "foo");
+$u{"\x{12345}"}  = "bar";
+@u{"\x{123456}"} = "zap";
+
+foreach (keys %u) {
+    unless (length() == 1) {
+       print "not ";
+       last;
+    }
+}
+print "ok 20\n";
+
+$a = "\xe3\x81\x82"; $A = "\x{3042}";
+%b = ( $a => "non-utf8");
+%u = ( $A => "utf8");
+
+print "not " if exists $b{$A};
+print "ok 21\n";
+print "not " if exists $u{$a};
+print "ok 22\n";
+print "#$b{$_}\n" for keys %b; # Used to core dump before change #8056.
+print "ok 23\n";
+print "#$u{$_}\n" for keys %u; # Used to core dump before change #8056.
+print "ok 24\n";