Commit | Line | Data |
0d55c8f7 |
1 | # |
2 | # $Id$ |
3 | # |
b536bf57 |
4 | # This script is written intentionally in UTF-8 |
5 | # Requires Encode 1.83 or better |
0d55c8f7 |
6 | # -- dankogai |
7 | |
8 | BEGIN { |
9 | if ($ENV{'PERL_CORE'}){ |
10 | chdir 't'; |
11 | unshift @INC, '../lib'; |
12 | } |
13 | require Config; import Config; |
14 | if ($Config{'extensions'} !~ /\bEncode\b/) { |
15 | print "1..0 # Skip: Encode was not built\n"; |
16 | exit 0; |
17 | } |
18 | if (ord("A") == 193) { |
19 | print "1..0 # Skip: EBCDIC\n"; |
20 | exit 0; |
21 | } |
22 | unless (PerlIO::Layer->find('perlio')){ |
23 | print "1..0 # Skip: PerlIO required\n"; |
24 | exit 0; |
25 | } |
26 | $| = 1; |
27 | } |
28 | |
29 | use strict; |
30 | #use Test::More qw(no_plan); |
3a2263fe |
31 | use Test::More tests => 7; |
0d55c8f7 |
32 | |
b536bf57 |
33 | use encoding 'utf8'; |
0d55c8f7 |
34 | |
35 | my @hiragana = map {chr} ord("ぁ")..ord("ん"); |
36 | my @katakana = map {chr} ord("ァ")..ord("ン"); |
37 | my $hiragana = join('' => @hiragana); |
38 | my $katakana = join('' => @katakana); |
39 | my %h2k; @h2k{@hiragana} = @katakana; |
40 | my %k2h; @k2h{@katakana} = @hiragana; |
41 | |
42 | # print @hiragana, "\n"; |
43 | |
44 | my $str; |
45 | |
46 | $str = $hiragana; $str =~ tr/ぁ-ん/ァ-ン/; |
47 | is($str, $katakana, "tr// # hiragana -> katakana"); |
48 | $str = $katakana; $str =~ tr/ァ-ン/ぁ-ん/; |
49 | is($str, $hiragana, "tr// # hiragana -> katakana"); |
50 | |
51 | $str = $hiragana; eval qq(\$str =~ tr/ぁ-ん/ァ-ン/); |
52 | is($str, $katakana, "eval qq(tr//) # hiragana -> katakana"); |
53 | $str = $katakana; eval qq(\$str =~ tr/ァ-ン/ぁ-ん/); |
54 | is($str, $hiragana, "eval qq(tr//) # hiragana -> katakana"); |
55 | |
56 | $str = $hiragana; $str =~ s/([ぁ-ん])/$h2k{$1}/go; |
57 | is($str, $katakana, "s/// # hiragana -> katakana"); |
58 | $str = $katakana; $str =~ s/([ァ-ン])/$k2h{$1}/go; |
59 | is($str, $hiragana, "s/// # hiragana -> katakana"); |
3a2263fe |
60 | |
61 | { |
62 | # [perl 16843] |
63 | my $line = 'abcdefghijklmnopqrstuvwxyz$0123456789'; |
64 | $line =~ tr/bcdeghijklmnprstvwxyz$02578/בצדעגהיײקלמנפּרסטװשכיזשױתײחא/; |
88632417 |
65 | is($line, "aבצדעfגהיײקלמנoפqּרסuטװשכיזש1ױ34ת6ײח9", "[perl #16843]"); |
3a2263fe |
66 | } |
0d55c8f7 |
67 | __END__ |