This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
lib/Unicode/UCD.t @INC oddity
[perl5.git] / lib / Unicode / UCD.t
CommitLineData
8b731da2
JH
1BEGIN {
2 if (ord("A") == 193) {
3 print "1..0 # Skip: EBCDIC\n";
4 exit 0;
5 }
a778afa6
AD
6 chdir 't' if -d 't';
7 @INC = '../lib';
8b731da2
JH
8}
9
a778afa6
AD
10use strict;
11use Unicode::UCD;
8b731da2
JH
12use Test;
13
74f8133e 14BEGIN { plan tests => 162 };
561c79ed 15
55d7b906 16use Unicode::UCD 'charinfo';
561c79ed 17
b08cd201
JH
18my $charinfo;
19
20$charinfo = charinfo(0x41);
21
22ok($charinfo->{code}, '0041');
23ok($charinfo->{name}, 'LATIN CAPITAL LETTER A');
24ok($charinfo->{category}, 'Lu');
25ok($charinfo->{combining}, '0');
26ok($charinfo->{bidi}, 'L');
27ok($charinfo->{decomposition}, '');
28ok($charinfo->{decimal}, '');
29ok($charinfo->{digit}, '');
30ok($charinfo->{numeric}, '');
31ok($charinfo->{mirrored}, 'N');
32ok($charinfo->{unicode10}, '');
33ok($charinfo->{comment}, '');
34ok($charinfo->{upper}, '');
35ok($charinfo->{lower}, '0061');
36ok($charinfo->{title}, '');
37ok($charinfo->{block}, 'Basic Latin');
38ok($charinfo->{script}, 'Latin');
39
40$charinfo = charinfo(0x100);
41
42ok($charinfo->{code}, '0100');
43ok($charinfo->{name}, 'LATIN CAPITAL LETTER A WITH MACRON');
44ok($charinfo->{category}, 'Lu');
45ok($charinfo->{combining}, '0');
46ok($charinfo->{bidi}, 'L');
47ok($charinfo->{decomposition}, '0041 0304');
48ok($charinfo->{decimal}, '');
49ok($charinfo->{digit}, '');
50ok($charinfo->{numeric}, '');
51ok($charinfo->{mirrored}, 'N');
52ok($charinfo->{unicode10}, 'LATIN CAPITAL LETTER A MACRON');
53ok($charinfo->{comment}, '');
54ok($charinfo->{upper}, '');
55ok($charinfo->{lower}, '0101');
56ok($charinfo->{title}, '');
57ok($charinfo->{block}, 'Latin Extended-A');
58ok($charinfo->{script}, 'Latin');
a196fbfd
JH
59
60# 0x0590 is in the Hebrew block but unused.
561c79ed 61
b08cd201
JH
62$charinfo = charinfo(0x590);
63
64ok($charinfo->{code}, undef);
65ok($charinfo->{name}, undef);
66ok($charinfo->{category}, undef);
67ok($charinfo->{combining}, undef);
68ok($charinfo->{bidi}, undef);
69ok($charinfo->{decomposition}, undef);
70ok($charinfo->{decimal}, undef);
71ok($charinfo->{digit}, undef);
72ok($charinfo->{numeric}, undef);
73ok($charinfo->{mirrored}, undef);
74ok($charinfo->{unicode10}, undef);
75ok($charinfo->{comment}, undef);
76ok($charinfo->{upper}, undef);
77ok($charinfo->{lower}, undef);
78ok($charinfo->{title}, undef);
79ok($charinfo->{block}, undef);
80ok($charinfo->{script}, undef);
a196fbfd
JH
81
82# 0x05d0 is in the Hebrew block and used.
561c79ed 83
b08cd201
JH
84$charinfo = charinfo(0x5d0);
85
86ok($charinfo->{code}, '05D0');
87ok($charinfo->{name}, 'HEBREW LETTER ALEF');
88ok($charinfo->{category}, 'Lo');
89ok($charinfo->{combining}, '0');
90ok($charinfo->{bidi}, 'R');
91ok($charinfo->{decomposition}, '');
92ok($charinfo->{decimal}, '');
93ok($charinfo->{digit}, '');
94ok($charinfo->{numeric}, '');
95ok($charinfo->{mirrored}, 'N');
96ok($charinfo->{unicode10}, '');
97ok($charinfo->{comment}, '');
98ok($charinfo->{upper}, '');
99ok($charinfo->{lower}, '');
100ok($charinfo->{title}, '');
101ok($charinfo->{block}, 'Hebrew');
102ok($charinfo->{script}, 'Hebrew');
561c79ed 103
74f8133e 104# An open syllable in Hangul.
a6fa416b
TS
105
106$charinfo = charinfo(0xAC00);
107
108ok($charinfo->{code}, 'AC00');
ac5ea531 109ok($charinfo->{name}, 'HANGUL SYLLABLE-AC00');
a6fa416b
TS
110ok($charinfo->{category}, 'Lo');
111ok($charinfo->{combining}, '0');
112ok($charinfo->{bidi}, 'L');
ac5ea531 113ok($charinfo->{decomposition}, undef);
a6fa416b
TS
114ok($charinfo->{decimal}, '');
115ok($charinfo->{digit}, '');
116ok($charinfo->{numeric}, '');
117ok($charinfo->{mirrored}, 'N');
118ok($charinfo->{unicode10}, '');
119ok($charinfo->{comment}, '');
120ok($charinfo->{upper}, '');
121ok($charinfo->{lower}, '');
122ok($charinfo->{title}, '');
123ok($charinfo->{block}, 'Hangul Syllables');
124ok($charinfo->{script}, 'Hangul');
125
74f8133e 126# A closed syllable in Hangul.
a6fa416b
TS
127
128$charinfo = charinfo(0xAE00);
129
130ok($charinfo->{code}, 'AE00');
ac5ea531 131ok($charinfo->{name}, 'HANGUL SYLLABLE-AE00');
a6fa416b
TS
132ok($charinfo->{category}, 'Lo');
133ok($charinfo->{combining}, '0');
134ok($charinfo->{bidi}, 'L');
ac5ea531 135ok($charinfo->{decomposition}, undef);
a6fa416b
TS
136ok($charinfo->{decimal}, '');
137ok($charinfo->{digit}, '');
138ok($charinfo->{numeric}, '');
139ok($charinfo->{mirrored}, 'N');
140ok($charinfo->{unicode10}, '');
141ok($charinfo->{comment}, '');
142ok($charinfo->{upper}, '');
143ok($charinfo->{lower}, '');
144ok($charinfo->{title}, '');
145ok($charinfo->{block}, 'Hangul Syllables');
146ok($charinfo->{script}, 'Hangul');
147
148$charinfo = charinfo(0x1D400);
149
150ok($charinfo->{code}, '1D400');
151ok($charinfo->{name}, 'MATHEMATICAL BOLD CAPITAL A');
152ok($charinfo->{category}, 'Lu');
153ok($charinfo->{combining}, '0');
154ok($charinfo->{bidi}, 'L');
155ok($charinfo->{decomposition}, '<font> 0041');
156ok($charinfo->{decimal}, '');
157ok($charinfo->{digit}, '');
158ok($charinfo->{numeric}, '');
159ok($charinfo->{mirrored}, 'N');
160ok($charinfo->{unicode10}, '');
161ok($charinfo->{comment}, '');
162ok($charinfo->{upper}, '');
163ok($charinfo->{lower}, '');
164ok($charinfo->{title}, '');
165ok($charinfo->{block}, 'Mathematical Alphanumeric Symbols');
166ok($charinfo->{script}, undef);
167
55d7b906 168use Unicode::UCD qw(charblock charscript);
a196fbfd
JH
169
170# 0x0590 is in the Hebrew block but unused.
561c79ed
JH
171
172ok(charblock(0x590), 'Hebrew');
a196fbfd 173ok(charscript(0x590), undef);
561c79ed 174
b08cd201
JH
175$charinfo = charinfo(0xbe);
176
177ok($charinfo->{code}, '00BE');
178ok($charinfo->{name}, 'VULGAR FRACTION THREE QUARTERS');
179ok($charinfo->{category}, 'No');
180ok($charinfo->{combining}, '0');
181ok($charinfo->{bidi}, 'ON');
182ok($charinfo->{decomposition}, '<fraction> 0033 2044 0034');
183ok($charinfo->{decimal}, '');
184ok($charinfo->{digit}, '');
185ok($charinfo->{numeric}, '3/4');
186ok($charinfo->{mirrored}, 'N');
187ok($charinfo->{unicode10}, 'FRACTION THREE QUARTERS');
188ok($charinfo->{comment}, '');
189ok($charinfo->{upper}, '');
190ok($charinfo->{lower}, '');
191ok($charinfo->{title}, '');
192ok($charinfo->{block}, 'Latin-1 Supplement');
193ok($charinfo->{script}, undef);
10a6ecd2 194
55d7b906 195use Unicode::UCD qw(charblocks charscripts);
10a6ecd2 196
b08cd201 197my $charblocks = charblocks();
10a6ecd2 198
b08cd201
JH
199ok(exists $charblocks->{Thai});
200ok($charblocks->{Thai}->[0]->[0], hex('0e00'));
201ok(!exists $charblocks->{PigLatin});
10a6ecd2 202
b08cd201 203my $charscripts = charscripts();
10a6ecd2 204
b08cd201
JH
205ok(exists $charscripts->{Armenian});
206ok($charscripts->{Armenian}->[0]->[0], hex('0531'));
207ok(!exists $charscripts->{PigLatin});
10a6ecd2
JH
208
209my $charscript;
210
211$charscript = charscript("12ab");
212ok($charscript, 'Ethiopic');
213
214$charscript = charscript("0x12ab");
215ok($charscript, 'Ethiopic');
216
217$charscript = charscript("U+12ab");
218ok($charscript, 'Ethiopic');
219
220my $ranges;
221
222$ranges = charscript('Ogham');
223ok($ranges->[0]->[0], hex('1681'));
224ok($ranges->[0]->[1], hex('169a'));
225
55d7b906 226use Unicode::UCD qw(charinrange);
10a6ecd2
JH
227
228$ranges = charscript('Cherokee');
229ok(!charinrange($ranges, "139f"));
230ok( charinrange($ranges, "13a0"));
231ok( charinrange($ranges, "13f4"));
232ok(!charinrange($ranges, "13f5"));
233
f499c386 234ok(Unicode::UCD::UnicodeVersion, '3.1.1');
b08cd201 235
55d7b906 236use Unicode::UCD qw(compexcl);
b08cd201
JH
237
238ok(!compexcl(0x0100));
239ok( compexcl(0x0958));
240
55d7b906 241use Unicode::UCD qw(casefold);
b08cd201
JH
242
243my $casefold;
244
245$casefold = casefold(0x41);
246
247ok($casefold->{code} eq '0041' &&
248 $casefold->{status} eq 'C' &&
249 $casefold->{mapping} eq '0061');
250
251$casefold = casefold(0xdf);
252
253ok($casefold->{code} eq '00DF' &&
254 $casefold->{status} eq 'F' &&
255 $casefold->{mapping} eq '0073 0073');
256
257ok(!casefold(0x20));
258
55d7b906 259use Unicode::UCD qw(casespec);
b08cd201
JH
260
261my $casespec;
262
263ok(!casespec(0x41));
264
265$casespec = casespec(0xdf);
266
267ok($casespec->{code} eq '00DF' &&
268 $casespec->{lower} eq '00DF' &&
269 $casespec->{title} eq '0053 0073' &&
270 $casespec->{upper} eq '0053 0053' &&
271 $casespec->{condition} eq undef);
272
273$casespec = casespec(0x307);
274
f499c386
JH
275ok($casespec->{az}->{code} eq '0307' &&
276 $casespec->{az}->{lower} eq '' &&
277 $casespec->{az}->{title} eq '0307' &&
278 $casespec->{az}->{upper} eq '0307' &&
279 $casespec->{az}->{condition} eq 'az AFTER_i NOT_MORE_ABOVE');