Commit | Line | Data |
---|---|---|
10a6ecd2 | 1 | use Unicode::UCD; |
561c79ed JH |
2 | |
3 | use Test; | |
4 | use strict; | |
5 | ||
10a6ecd2 | 6 | BEGIN { plan tests => 103 }; |
561c79ed JH |
7 | |
8 | use Unicode::UCD 'charinfo'; | |
9 | ||
10 | my %charinfo; | |
11 | ||
12 | %charinfo = charinfo(0x41); | |
13 | ||
14 | ok($charinfo{code}, '0041'); | |
15 | ok($charinfo{name}, 'LATIN CAPITAL LETTER A'); | |
16 | ok($charinfo{category}, 'Lu'); | |
17 | ok($charinfo{combining}, '0'); | |
18 | ok($charinfo{bidi}, 'L'); | |
19 | ok($charinfo{decomposition}, ''); | |
20 | ok($charinfo{decimal}, ''); | |
21 | ok($charinfo{digit}, ''); | |
22 | ok($charinfo{numeric}, ''); | |
23 | ok($charinfo{mirrored}, 'N'); | |
24 | ok($charinfo{unicode10}, ''); | |
25 | ok($charinfo{comment}, ''); | |
26 | ok($charinfo{upper}, ''); | |
27 | ok($charinfo{lower}, '0061'); | |
28 | ok($charinfo{title}, ''); | |
29 | ok($charinfo{block}, 'Basic Latin'); | |
32a424d2 | 30 | ok($charinfo{script}, 'Latin'); |
561c79ed JH |
31 | |
32 | %charinfo = charinfo(0x100); | |
33 | ||
34 | ok($charinfo{code}, '0100'); | |
35 | ok($charinfo{name}, 'LATIN CAPITAL LETTER A WITH MACRON'); | |
36 | ok($charinfo{category}, 'Lu'); | |
37 | ok($charinfo{combining}, '0'); | |
38 | ok($charinfo{bidi}, 'L'); | |
39 | ok($charinfo{decomposition}, '0041 0304'); | |
40 | ok($charinfo{decimal}, ''); | |
41 | ok($charinfo{digit}, ''); | |
42 | ok($charinfo{numeric}, ''); | |
43 | ok($charinfo{mirrored}, 'N'); | |
44 | ok($charinfo{unicode10}, 'LATIN CAPITAL LETTER A MACRON'); | |
45 | ok($charinfo{comment}, ''); | |
46 | ok($charinfo{upper}, ''); | |
47 | ok($charinfo{lower}, '0101'); | |
48 | ok($charinfo{title}, ''); | |
49 | ok($charinfo{block}, 'Latin Extended-A'); | |
32a424d2 | 50 | ok($charinfo{script}, 'Latin'); |
a196fbfd JH |
51 | |
52 | # 0x0590 is in the Hebrew block but unused. | |
561c79ed JH |
53 | |
54 | %charinfo = charinfo(0x590); | |
55 | ||
56 | ok($charinfo{code}, undef); | |
57 | ok($charinfo{name}, undef); | |
58 | ok($charinfo{category}, undef); | |
59 | ok($charinfo{combining}, undef); | |
60 | ok($charinfo{bidi}, undef); | |
61 | ok($charinfo{decomposition}, undef); | |
62 | ok($charinfo{decimal}, undef); | |
63 | ok($charinfo{digit}, undef); | |
64 | ok($charinfo{numeric}, undef); | |
65 | ok($charinfo{mirrored}, undef); | |
66 | ok($charinfo{unicode10}, undef); | |
67 | ok($charinfo{comment}, undef); | |
68 | ok($charinfo{upper}, undef); | |
69 | ok($charinfo{lower}, undef); | |
70 | ok($charinfo{title}, undef); | |
71 | ok($charinfo{block}, undef); | |
a196fbfd JH |
72 | ok($charinfo{script}, undef); |
73 | ||
74 | # 0x05d0 is in the Hebrew block and used. | |
561c79ed JH |
75 | |
76 | %charinfo = charinfo(0x5d0); | |
77 | ||
78 | ok($charinfo{code}, '05D0'); | |
79 | ok($charinfo{name}, 'HEBREW LETTER ALEF'); | |
80 | ok($charinfo{category}, 'Lo'); | |
81 | ok($charinfo{combining}, '0'); | |
82 | ok($charinfo{bidi}, 'R'); | |
83 | ok($charinfo{decomposition}, ''); | |
84 | ok($charinfo{decimal}, ''); | |
85 | ok($charinfo{digit}, ''); | |
86 | ok($charinfo{numeric}, ''); | |
87 | ok($charinfo{mirrored}, 'N'); | |
88 | ok($charinfo{unicode10}, ''); | |
89 | ok($charinfo{comment}, ''); | |
90 | ok($charinfo{upper}, ''); | |
91 | ok($charinfo{lower}, ''); | |
92 | ok($charinfo{title}, ''); | |
93 | ok($charinfo{block}, 'Hebrew'); | |
10a6ecd2 | 94 | ok($charinfo{script}, 'Hebrew'); |
561c79ed | 95 | |
a196fbfd JH |
96 | use Unicode::UCD qw(charblock charscript); |
97 | ||
98 | # 0x0590 is in the Hebrew block but unused. | |
561c79ed JH |
99 | |
100 | ok(charblock(0x590), 'Hebrew'); | |
a196fbfd | 101 | ok(charscript(0x590), undef); |
561c79ed JH |
102 | |
103 | %charinfo = charinfo(0xbe); | |
104 | ||
105 | ok($charinfo{code}, '00BE'); | |
106 | ok($charinfo{name}, 'VULGAR FRACTION THREE QUARTERS'); | |
107 | ok($charinfo{category}, 'No'); | |
108 | ok($charinfo{combining}, '0'); | |
109 | ok($charinfo{bidi}, 'ON'); | |
110 | ok($charinfo{decomposition}, '<fraction> 0033 2044 0034'); | |
111 | ok($charinfo{decimal}, ''); | |
112 | ok($charinfo{digit}, ''); | |
113 | ok($charinfo{numeric}, '3/4'); | |
114 | ok($charinfo{mirrored}, 'N'); | |
115 | ok($charinfo{unicode10}, 'FRACTION THREE QUARTERS'); | |
116 | ok($charinfo{comment}, ''); | |
117 | ok($charinfo{upper}, ''); | |
118 | ok($charinfo{lower}, ''); | |
119 | ok($charinfo{title}, ''); | |
120 | ok($charinfo{block}, 'Latin-1 Supplement'); | |
a196fbfd | 121 | ok($charinfo{script}, undef); |
10a6ecd2 JH |
122 | |
123 | use Unicode::UCD qw(charblocks charscripts); | |
124 | ||
125 | my %charblocks = charblocks(); | |
126 | ||
127 | ok(exists $charblocks{Thai}); | |
128 | ok($charblocks{Thai}->[0]->[0], hex('0e00')); | |
129 | ok(!exists $charblocks{PigLatin}); | |
130 | ||
131 | my %charscripts = charscripts(); | |
132 | ||
133 | ok(exists $charscripts{Armenian}); | |
134 | ok($charscripts{Armenian}->[0]->[0], hex('0531')); | |
135 | ok(!exists $charscripts{PigLatin}); | |
136 | ||
137 | my $charscript; | |
138 | ||
139 | $charscript = charscript("12ab"); | |
140 | ok($charscript, 'Ethiopic'); | |
141 | ||
142 | $charscript = charscript("0x12ab"); | |
143 | ok($charscript, 'Ethiopic'); | |
144 | ||
145 | $charscript = charscript("U+12ab"); | |
146 | ok($charscript, 'Ethiopic'); | |
147 | ||
148 | my $ranges; | |
149 | ||
150 | $ranges = charscript('Ogham'); | |
151 | ok($ranges->[0]->[0], hex('1681')); | |
152 | ok($ranges->[0]->[1], hex('169a')); | |
153 | ||
154 | use Unicode::UCD qw(charinrange); | |
155 | ||
156 | $ranges = charscript('Cherokee'); | |
157 | ok(!charinrange($ranges, "139f")); | |
158 | ok( charinrange($ranges, "13a0")); | |
159 | ok( charinrange($ranges, "13f4")); | |
160 | ok(!charinrange($ranges, "13f5")); | |
161 | ||
162 | ok(Unicode::UCD::UnicodeVersion, 3.1); |