Add Encode's META.yml.
[p5sagit/p5-mst-13.2.git] / t / uni / tr_utf8.t
index 54b9b4f..e623909 100644 (file)
@@ -1,7 +1,8 @@
 #
 # $Id$
 #
-# This script is written intentionally in EUC-JP
+# This script is written intentionally in UTF-8
+# Requires Encode 1.83 or better
 # -- dankogai
 
 BEGIN {
@@ -22,17 +23,19 @@ BEGIN {
         print "1..0 # Skip: PerlIO required\n";
         exit 0;
     }
+    eval 'use Encode';
+    if ($@ =~ /dynamic loading not available/) {
+        print "1..0 # Skip: no dynamic loading, no Encode\n";
+        exit 0;
+    }
     $| = 1;
 }
 
 use strict;
 #use Test::More qw(no_plan);
-use Test::More tests => 6;
+use Test::More tests => 7;
 
-# use encoding 'utf8'; # you can't uncomment this!
-# if you uncomment above, you'll get the following (as of Encode 1.80)
-#  Assertion ((dst)->sv_flags & 0xff) >= SVt_PV failed:
-#  file "Encode.xs", line 255 at t/uni/tr_utf8.t line 35.
+use encoding 'utf8';
 
 my @hiragana =  map {chr} ord("ぁ")..ord("ん");
 my @katakana =  map {chr} ord("ァ")..ord("ン");
@@ -59,4 +62,11 @@ $str = $hiragana; $str =~ s/([ぁ-ん])/$h2k{$1}/go;
 is($str, $katakana, "s/// # hiragana -> katakana");
 $str = $katakana; $str =~ s/([ァ-ン])/$k2h{$1}/go;
 is($str, $hiragana, "s/// # hiragana -> katakana");
+
+{
+  # [perl 16843]
+  my $line = 'abcdefghijklmnopqrstuvwxyz$0123456789';
+  $line =~ tr/bcdeghijklmnprstvwxyz$02578/בצדעגהיײקלמנפּרסטװשכיזשױתײחא/;
+  is($line, "aבצדעfגהיײקלמנoפqּרסuטװשכיזש1ױ34ת6ײח9", "[perl #16843]");
+}
 __END__