[ID 20011126.150] t/op/pack patch to fix Useless use of unpack in void context at...
[p5sagit/p5-mst-13.2.git] / t / op / each.t
index 879c0d0..eb2dce0 100755 (executable)
@@ -1,6 +1,12 @@
 #!./perl
 
-print "1..19\n";
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '.';
+    push @INC, '../lib';
+}
+
+print "1..27\n";
 
 $h{'abc'} = 'ABC';
 $h{'def'} = 'DEF';
@@ -131,3 +137,44 @@ if ($i == 5) { print "ok 16\n" } else { print "not ok\n" }
     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";
+
+# on EBCDIC chars are mapped differently so pick something that needs encoding
+# there too.
+$d = pack("U*", 0xe3, 0x81, 0xAF);
+{ use bytes; $ol = bytes::length($d) }
+print "not " unless $ol > 3;
+print "ok 25\n";
+%u = ($d => "downgrade");
+for (keys %u) {
+    print "not " if length ne 3 or $_ ne "\xe3\x81\xAF";
+    print "ok 26\n";
+}
+{
+    { use bytes; print "not " if bytes::length($d) != $ol }
+    print "ok 27\n";
+}