This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
charnames.pm: More refactoring for performance
[perl5.git] / lib / charnames.t
CommitLineData
423cee85 1#!./perl
a0d8d8c5 2use strict;
423cee85 3
da85ecb8
KW
4# Because \N{} is compile time, any warnings will get generated before
5# execution, so have to have an array, and arrange things so no warning
6# is generated twice to verify that in fact a warning did happen
52ea3e69
JH
7my @WARN;
8
423cee85
JH
9BEGIN {
10 unless(grep /blib/, @INC) {
11 chdir 't' if -d 't';
20822f61 12 @INC = '../lib';
423cee85 13 }
52ea3e69 14 $SIG{__WARN__} = sub { push @WARN, @_ };
423cee85
JH
15}
16
84374e30 17our $local_tests = 514;
63c6dcc1 18
ea065648
NC
19# ---- For the alias extensions
20require "../t/lib/common.pl";
423cee85
JH
21
22use charnames ':full';
23
a0d8d8c5 24is("Here\N{EXCLAMATION MARK}?", "Here!?");
423cee85 25
c82a54e6 26{
a0d8d8c5 27 use bytes; # TEST -utf8 can switch utf8 on
c82a54e6 28
a0d8d8c5 29 my $res = eval <<'EOE';
423cee85 30use charnames ":full";
4a2d328f 31"Here: \N{CYRILLIC SMALL LETTER BE}!";
423cee85
JH
321
33EOE
423cee85 34
a0d8d8c5 35 like($@, "above 0xFF");
2974a5b4 36 ok(! defined $res);
a0d8d8c5
KW
37
38 $res = eval <<'EOE';
423cee85 39use charnames 'cyrillic';
4a2d328f 40"Here: \N{Be}!";
423cee85
JH
411
42EOE
a0d8d8c5 43 like($@, "CYRILLIC CAPITAL LETTER BE.*above 0xFF");
16036bcd
KW
44
45 $res = eval <<'EOE';
46use charnames ':full', ":alias" => { BOM => "LATIN SMALL LETTER B" };
47"\N{BOM}";
48EOE
49 is ($@, "");
50 is ($res, 'b', "Verify that can redefine a standard alias");
c82a54e6 51}
423cee85 52
232cbbee
KW
53{
54
4cf086c7 55 use charnames ':full', ":alias" => { mychar1 => "0xE8000",
232cbbee
KW
56 mychar2 => 983040, # U+F0000
57 mychar3 => "U+100000",
58 myctrl => 0x80,
63098191 59 mylarge => "U+111000",
232cbbee
KW
60 };
61 is ("\N{mychar1}", chr(0xE8000), "Verify that can define hex alias");
62 is (charnames::viacode(0xE8000), "mychar1", "And that can get the alias back");
63 is ("\N{mychar2}", chr(0xF0000), "Verify that can define decimal alias");
64 is (charnames::viacode(0xF0000), "mychar2", "And that can get the alias back");
65 is ("\N{mychar3}", chr(0x100000), "Verify that can define U+... alias");
66 is (charnames::viacode(0x100000), "mychar3", "And that can get the alias back");
63098191 67 is ("\N{mylarge}", chr(0x111000), "Verify that can define alias beyond Unicode");
ac046fe1 68 is (charnames::viacode(0x111000), "mylarge", "And that can get the alias back");
232cbbee
KW
69 is (charnames::viacode(0x80), "myctrl", "Verify that can name a nameless control");
70
71}
72
a0d8d8c5
KW
73my $encoded_be;
74my $encoded_alpha;
75my $encoded_bet;
76my $encoded_deseng;
77
423cee85 78# If octal representation of unicode char is \0xyzt, then the utf8 is \3xy\2zt
210db7fc
PP
79if (ord('A') == 65) { # as on ASCII or UTF-8 machines
80 $encoded_be = "\320\261";
81 $encoded_alpha = "\316\261";
82 $encoded_bet = "\327\221";
83 $encoded_deseng = "\360\220\221\215";
84}
85else { # EBCDIC where UTF-EBCDIC may be used (this may be 1047 specific since
86 # UTF-EBCDIC is codepage specific)
87 $encoded_be = "\270\102\130";
88 $encoded_alpha = "\264\130";
89 $encoded_bet = "\270\125\130";
90 $encoded_deseng = "\336\102\103\124";
91}
c5cc3500
GS
92
93sub to_bytes {
f337b084 94 unpack"U0a*", shift;
c5cc3500
GS
95}
96
423cee85
JH
97{
98 use charnames ':full';
423cee85 99
a0d8d8c5 100 is(to_bytes("\N{CYRILLIC SMALL LETTER BE}"), $encoded_be);
423cee85
JH
101
102 use charnames qw(cyrillic greek :short);
103
a0d8d8c5
KW
104 is(to_bytes("\N{be},\N{alpha},\N{hebrew:bet}"),
105 "$encoded_be,$encoded_alpha,$encoded_bet");
423cee85 106}
e1992b6d
GS
107
108{
109 use charnames ':full';
a0d8d8c5
KW
110 is("\x{263a}", "\N{WHITE SMILING FACE}");
111 cmp_ok(length("\x{263a}"), '==', 1);
112 cmp_ok(length("\N{WHITE SMILING FACE}"), '==', 1);
113 is(sprintf("%vx", "\x{263a}"), "263a");
114 is(sprintf("%vx", "\N{WHITE SMILING FACE}"), "263a");
115 is(sprintf("%vx", "\xFF\N{WHITE SMILING FACE}"), "ff.263a");
116 is(sprintf("%vx", "\x{ff}\N{WHITE SMILING FACE}"), "ff.263a");
e1992b6d 117}
c00525d4 118
119{
a0d8d8c5
KW
120 use charnames qw(:full);
121 use utf8;
51cf30b6 122
c00525d4 123 my $x = "\x{221b}";
124 my $named = "\N{CUBE ROOT}";
125
a0d8d8c5 126 cmp_ok(ord($x), '==', ord($named));
c00525d4 127}
128
f9a63242 129{
a0d8d8c5
KW
130 use charnames qw(:full);
131 use utf8;
132 is("\x{100}\N{CENT SIGN}", "\x{100}"."\N{CENT SIGN}");
f9a63242
JH
133}
134
b896c7a5 135{
a0d8d8c5 136 use charnames ':full';
b896c7a5 137
a0d8d8c5 138 is(to_bytes("\N{DESERET SMALL LETTER ENG}"), $encoded_deseng);
4765795a 139}
b896c7a5 140
4765795a 141{
a0d8d8c5
KW
142 # 20001114.001
143
144 no utf8; # naked Latin-1
145
146 use charnames ':full';
147 my $text = "\N{LATIN CAPITAL LETTER A WITH DIAERESIS}";
148 is($text, latin1_to_native("\xc4"));
149
150 # I'm not sure that this tests anything different from the above.
151 cmp_ok(ord($text), '==', ord(latin1_to_native("\xc4")));
b896c7a5
A
152}
153
daf0d493 154{
a0d8d8c5 155 is(charnames::viacode(0x1234), "ETHIOPIC SYLLABLE SEE");
daf0d493 156
63098191
KW
157 # No name
158 ok(! defined charnames::viacode(0xFFFF));
daf0d493
JH
159}
160
161{
5a7fb30a
KW
162 cmp_ok(charnames::vianame("GOTHIC LETTER AHSA"), "==", 0x10330, "Verify vianame \\N{name} returns an ord");
163 is(charnames::vianame("U+10330"), "\x{10330}", "Verify vianame \\N{U+hex} returns a chr");
63098191
KW
164 use warnings;
165 my $warning_count = @WARN;
a0d8d8c5 166 ok (! defined charnames::vianame("NONE SUCH"));
2974a5b4 167 cmp_ok($warning_count, '==', scalar @WARN, "Verify vianame doesn't warn on unknown names");
63098191
KW
168
169 use bytes;
170 is(charnames::vianame("GOTHIC LETTER AHSA"), 0x10330, "Verify vianame \\N{name} is unaffected by 'use bytes'");
5a7fb30a 171 is(charnames::vianame("U+FF"), chr(0xFF), "Verify vianame \\N{U+FF} is unaffected by 'use bytes'");
2974a5b4
KW
172 cmp_ok($warning_count, '==', scalar @WARN, "Verify vianame doesn't warn on legal inputs");
173 ok(! defined charnames::vianame("U+100"), "Verify vianame \\N{U+100} is undef under 'use bytes'");
174 ok($warning_count == scalar @WARN - 1 && $WARN[-1] =~ /above 0xFF/, "Verify vianame gives appropriate warning for previous test");
daf0d493 175}
4e2cda5d
JH
176
177{
178 # check that caching at least hasn't broken anything
179
a0d8d8c5 180 is(charnames::viacode(0x1234), "ETHIOPIC SYLLABLE SEE");
4e2cda5d 181
a0d8d8c5 182 is(sprintf("%04X", charnames::vianame("GOTHIC LETTER AHSA")), "10330");
4e2cda5d
JH
183
184}
301a3cda 185
a0d8d8c5 186is("\N{CHARACTER TABULATION}", "\t");
a2e77dd4 187
a0d8d8c5
KW
188is("\N{ESCAPE}", "\e");
189is("\N{NULL}", "\c@");
190is("\N{LINE FEED (LF)}", "\n");
191is("\N{LINE FEED}", "\n");
192is("\N{LF}", "\n");
52ea3e69 193
a0d8d8c5
KW
194my $nel = latin1_to_native("\x85");
195$nel = qr/^$nel$/;
52ea3e69 196
a0d8d8c5
KW
197like("\N{NEXT LINE (NEL)}", $nel);
198like("\N{NEXT LINE}", $nel);
199like("\N{NEL}", $nel);
200is("\N{BYTE ORDER MARK}", chr(0xFEFF));
201is("\N{BOM}", chr(0xFEFF));
51e9e896 202
52ea3e69
JH
203{
204 use warnings 'deprecated';
205
a0d8d8c5 206 is("\N{HORIZONTAL TABULATION}", "\t");
52ea3e69 207
16036bcd 208 ok(grep { /"HORIZONTAL TABULATION" is deprecated.*CHARACTER TABULATION/ } @WARN);
822ebcc8 209
52ea3e69
JH
210 no warnings 'deprecated';
211
a0d8d8c5 212 is("\N{VERTICAL TABULATION}", "\013");
52ea3e69 213
a0d8d8c5 214 ok(! grep { /"VERTICAL TABULATION" is deprecated/ } @WARN);
52ea3e69 215}
822ebcc8 216
a0d8d8c5 217is(charnames::viacode(0xFEFF), "ZERO WIDTH NO-BREAK SPACE");
a23c04e4 218
872c91ae
JH
219{
220 use warnings;
a0d8d8c5 221 cmp_ok(ord("\N{BOM}"), '==', 0xFEFF);
872c91ae
JH
222}
223
a0d8d8c5 224cmp_ok(ord("\N{ZWNJ}"), '==', 0x200C);
24b5d5cc 225
a0d8d8c5 226cmp_ok(ord("\N{ZWJ}"), '==', 0x200D);
dbc0d4f2 227
a0d8d8c5 228is("\N{U+263A}", "\N{WHITE SMILING FACE}");
dbc0d4f2 229
51b0dbc4 230{
a0d8d8c5
KW
231 cmp_ok( 0x3093, '==', charnames::vianame("HIRAGANA LETTER N"));
232 cmp_ok(0x0397, '==', charnames::vianame("GREEK CAPITAL LETTER ETA"));
51b0dbc4
ST
233}
234
a0d8d8c5
KW
235ok(! defined charnames::viacode(0x110000));
236ok(! grep { /you asked for U+110000/ } @WARN);
e10d7780 237
c8002005
KW
238is(charnames::viacode(0), "NULL");
239is(charnames::viacode("BE"), "VULGAR FRACTION THREE QUARTERS");
240is(charnames::viacode("U+00000000000FEED"), "ARABIC LETTER WAW ISOLATED FORM");
241
16036bcd
KW
242{
243 no warnings 'deprecated';
244 is("\N{LINE FEED}", "\N{LINE FEED (LF)}");
245 is("\N{FORM FEED}", "\N{FORM FEED (FF)}");
246 is("\N{CARRIAGE RETURN}", "\N{CARRIAGE RETURN (CR)}");
247 is("\N{NEXT LINE}", "\N{NEXT LINE (NEL)}");
248 is("\N{NUL}", "\N{NULL}");
249 is("\N{SOH}", "\N{START OF HEADING}");
250 is("\N{STX}", "\N{START OF TEXT}");
251 is("\N{ETX}", "\N{END OF TEXT}");
252 is("\N{EOT}", "\N{END OF TRANSMISSION}");
253 is("\N{ENQ}", "\N{ENQUIRY}");
254 is("\N{ACK}", "\N{ACKNOWLEDGE}");
255 is("\N{BEL}", "\N{BELL}");
256 is("\N{BS}", "\N{BACKSPACE}");
257 is("\N{HT}", "\N{HORIZONTAL TABULATION}");
258 is("\N{LF}", "\N{LINE FEED (LF)}");
259 is("\N{VT}", "\N{VERTICAL TABULATION}");
260 is("\N{FF}", "\N{FORM FEED (FF)}");
261 is("\N{CR}", "\N{CARRIAGE RETURN (CR)}");
262 is("\N{SO}", "\N{SHIFT OUT}");
263 is("\N{SI}", "\N{SHIFT IN}");
264 is("\N{DLE}", "\N{DATA LINK ESCAPE}");
265 is("\N{DC1}", "\N{DEVICE CONTROL ONE}");
266 is("\N{DC2}", "\N{DEVICE CONTROL TWO}");
267 is("\N{DC3}", "\N{DEVICE CONTROL THREE}");
268 is("\N{DC4}", "\N{DEVICE CONTROL FOUR}");
269 is("\N{NAK}", "\N{NEGATIVE ACKNOWLEDGE}");
270 is("\N{SYN}", "\N{SYNCHRONOUS IDLE}");
271 is("\N{ETB}", "\N{END OF TRANSMISSION BLOCK}");
272 is("\N{CAN}", "\N{CANCEL}");
273 is("\N{EOM}", "\N{END OF MEDIUM}");
274 is("\N{SUB}", "\N{SUBSTITUTE}");
275 is("\N{ESC}", "\N{ESCAPE}");
276 is("\N{FS}", "\N{FILE SEPARATOR}");
277 is("\N{GS}", "\N{GROUP SEPARATOR}");
278 is("\N{RS}", "\N{RECORD SEPARATOR}");
279 is("\N{US}", "\N{UNIT SEPARATOR}");
280 is("\N{DEL}", "\N{DELETE}");
281 is("\N{BPH}", "\N{BREAK PERMITTED HERE}");
282 is("\N{NBH}", "\N{NO BREAK HERE}");
283 is("\N{NEL}", "\N{NEXT LINE (NEL)}");
284 is("\N{SSA}", "\N{START OF SELECTED AREA}");
285 is("\N{ESA}", "\N{END OF SELECTED AREA}");
286 is("\N{HTS}", "\N{CHARACTER TABULATION SET}");
287 is("\N{HTJ}", "\N{CHARACTER TABULATION WITH JUSTIFICATION}");
288 is("\N{VTS}", "\N{LINE TABULATION SET}");
289 is("\N{PLD}", "\N{PARTIAL LINE FORWARD}");
290 is("\N{PLU}", "\N{PARTIAL LINE BACKWARD}");
291 is("\N{RI }", "\N{REVERSE LINE FEED}");
292 is("\N{SS2}", "\N{SINGLE SHIFT TWO}");
293 is("\N{SS3}", "\N{SINGLE SHIFT THREE}");
294 is("\N{DCS}", "\N{DEVICE CONTROL STRING}");
295 is("\N{PU1}", "\N{PRIVATE USE ONE}");
296 is("\N{PU2}", "\N{PRIVATE USE TWO}");
297 is("\N{STS}", "\N{SET TRANSMIT STATE}");
298 is("\N{CCH}", "\N{CANCEL CHARACTER}");
299 is("\N{MW }", "\N{MESSAGE WAITING}");
300 is("\N{SPA}", "\N{START OF GUARDED AREA}");
301 is("\N{EPA}", "\N{END OF GUARDED AREA}");
302 is("\N{SOS}", "\N{START OF STRING}");
303 is("\N{SCI}", "\N{SINGLE CHARACTER INTRODUCER}");
304 is("\N{CSI}", "\N{CONTROL SEQUENCE INTRODUCER}");
305 is("\N{ST }", "\N{STRING TERMINATOR}");
306 is("\N{OSC}", "\N{OPERATING SYSTEM COMMAND}");
307 is("\N{PM }", "\N{PRIVACY MESSAGE}");
308 is("\N{APC}", "\N{APPLICATION PROGRAM COMMAND}");
309 is("\N{PADDING CHARACTER}", "\N{PAD}");
310 is("\N{HIGH OCTET PRESET}","\N{HOP}");
311 is("\N{INDEX}", "\N{IND}");
312 is("\N{SINGLE GRAPHIC CHARACTER INTRODUCER}", "\N{SGC}");
313 is("\N{BOM}", "\N{BYTE ORDER MARK}");
314 is("\N{CGJ}", "\N{COMBINING GRAPHEME JOINER}");
315 is("\N{FVS1}", "\N{MONGOLIAN FREE VARIATION SELECTOR ONE}");
316 is("\N{FVS2}", "\N{MONGOLIAN FREE VARIATION SELECTOR TWO}");
317 is("\N{FVS3}", "\N{MONGOLIAN FREE VARIATION SELECTOR THREE}");
318 is("\N{LRE}", "\N{LEFT-TO-RIGHT EMBEDDING}");
319 is("\N{LRM}", "\N{LEFT-TO-RIGHT MARK}");
320 is("\N{LRO}", "\N{LEFT-TO-RIGHT OVERRIDE}");
321 is("\N{MMSP}", "\N{MEDIUM MATHEMATICAL SPACE}");
322 is("\N{MVS}", "\N{MONGOLIAN VOWEL SEPARATOR}");
323 is("\N{NBSP}", "\N{NO-BREAK SPACE}");
324 is("\N{NNBSP}", "\N{NARROW NO-BREAK SPACE}");
325 is("\N{PDF}", "\N{POP DIRECTIONAL FORMATTING}");
326 is("\N{RLE}", "\N{RIGHT-TO-LEFT EMBEDDING}");
327 is("\N{RLM}", "\N{RIGHT-TO-LEFT MARK}");
328 is("\N{RLO}", "\N{RIGHT-TO-LEFT OVERRIDE}");
329 is("\N{SHY}", "\N{SOFT HYPHEN}");
330 is("\N{WJ}", "\N{WORD JOINER}");
331 is("\N{ZWJ}", "\N{ZERO WIDTH JOINER}");
332 is("\N{ZWNJ}", "\N{ZERO WIDTH NON-JOINER}");
333 is("\N{ZWSP}", "\N{ZERO WIDTH SPACE}");
334 is("\N{HORIZONTAL TABULATION}", "\N{CHARACTER TABULATION}");
335 is("\N{VERTICAL TABULATION}", "\N{LINE TABULATION}");
336 is("\N{FILE SEPARATOR}", "\N{INFORMATION SEPARATOR FOUR}");
337 is("\N{GROUP SEPARATOR}", "\N{INFORMATION SEPARATOR THREE}");
338 is("\N{RECORD SEPARATOR}", "\N{INFORMATION SEPARATOR TWO}");
339 is("\N{UNIT SEPARATOR}", "\N{INFORMATION SEPARATOR ONE}");
340 is("\N{HORIZONTAL TABULATION SET}", "\N{CHARACTER TABULATION SET}");
341 is("\N{HORIZONTAL TABULATION WITH JUSTIFICATION}", "\N{CHARACTER TABULATION WITH JUSTIFICATION}");
342 is("\N{PARTIAL LINE DOWN}", "\N{PARTIAL LINE FORWARD}");
343 is("\N{PARTIAL LINE UP}", "\N{PARTIAL LINE BACKWARD}");
344 is("\N{VERTICAL TABULATION SET}", "\N{LINE TABULATION SET}");
345 is("\N{REVERSE INDEX}", "\N{REVERSE LINE FEED}");
346 is("\N{SINGLE-SHIFT 2}", "\N{SINGLE SHIFT TWO}");
347 is("\N{SINGLE-SHIFT 3}", "\N{SINGLE SHIFT THREE}");
348 is("\N{PRIVATE USE 1}", "\N{PRIVATE USE ONE}");
349 is("\N{PRIVATE USE 2}", "\N{PRIVATE USE TWO}");
350 is("\N{START OF PROTECTED AREA}", "\N{START OF GUARDED AREA}");
351 is("\N{END OF PROTECTED AREA}", "\N{END OF GUARDED AREA}");
352 is("\N{VS1}", "\N{VARIATION SELECTOR-1}");
353 is("\N{VS2}", "\N{VARIATION SELECTOR-2}");
354 is("\N{VS3}", "\N{VARIATION SELECTOR-3}");
355 is("\N{VS4}", "\N{VARIATION SELECTOR-4}");
356 is("\N{VS5}", "\N{VARIATION SELECTOR-5}");
357 is("\N{VS6}", "\N{VARIATION SELECTOR-6}");
358 is("\N{VS7}", "\N{VARIATION SELECTOR-7}");
359 is("\N{VS8}", "\N{VARIATION SELECTOR-8}");
360 is("\N{VS9}", "\N{VARIATION SELECTOR-9}");
361 is("\N{VS10}", "\N{VARIATION SELECTOR-10}");
362 is("\N{VS11}", "\N{VARIATION SELECTOR-11}");
363 is("\N{VS12}", "\N{VARIATION SELECTOR-12}");
364 is("\N{VS13}", "\N{VARIATION SELECTOR-13}");
365 is("\N{VS14}", "\N{VARIATION SELECTOR-14}");
366 is("\N{VS15}", "\N{VARIATION SELECTOR-15}");
367 is("\N{VS16}", "\N{VARIATION SELECTOR-16}");
368 is("\N{VS17}", "\N{VARIATION SELECTOR-17}");
369 is("\N{VS18}", "\N{VARIATION SELECTOR-18}");
370 is("\N{VS19}", "\N{VARIATION SELECTOR-19}");
371 is("\N{VS20}", "\N{VARIATION SELECTOR-20}");
372 is("\N{VS21}", "\N{VARIATION SELECTOR-21}");
373 is("\N{VS22}", "\N{VARIATION SELECTOR-22}");
374 is("\N{VS23}", "\N{VARIATION SELECTOR-23}");
375 is("\N{VS24}", "\N{VARIATION SELECTOR-24}");
376 is("\N{VS25}", "\N{VARIATION SELECTOR-25}");
377 is("\N{VS26}", "\N{VARIATION SELECTOR-26}");
378 is("\N{VS27}", "\N{VARIATION SELECTOR-27}");
379 is("\N{VS28}", "\N{VARIATION SELECTOR-28}");
380 is("\N{VS29}", "\N{VARIATION SELECTOR-29}");
381 is("\N{VS30}", "\N{VARIATION SELECTOR-30}");
382 is("\N{VS31}", "\N{VARIATION SELECTOR-31}");
383 is("\N{VS32}", "\N{VARIATION SELECTOR-32}");
384 is("\N{VS33}", "\N{VARIATION SELECTOR-33}");
385 is("\N{VS34}", "\N{VARIATION SELECTOR-34}");
386 is("\N{VS35}", "\N{VARIATION SELECTOR-35}");
387 is("\N{VS36}", "\N{VARIATION SELECTOR-36}");
388 is("\N{VS37}", "\N{VARIATION SELECTOR-37}");
389 is("\N{VS38}", "\N{VARIATION SELECTOR-38}");
390 is("\N{VS39}", "\N{VARIATION SELECTOR-39}");
391 is("\N{VS40}", "\N{VARIATION SELECTOR-40}");
392 is("\N{VS41}", "\N{VARIATION SELECTOR-41}");
393 is("\N{VS42}", "\N{VARIATION SELECTOR-42}");
394 is("\N{VS43}", "\N{VARIATION SELECTOR-43}");
395 is("\N{VS44}", "\N{VARIATION SELECTOR-44}");
396 is("\N{VS45}", "\N{VARIATION SELECTOR-45}");
397 is("\N{VS46}", "\N{VARIATION SELECTOR-46}");
398 is("\N{VS47}", "\N{VARIATION SELECTOR-47}");
399 is("\N{VS48}", "\N{VARIATION SELECTOR-48}");
400 is("\N{VS49}", "\N{VARIATION SELECTOR-49}");
401 is("\N{VS50}", "\N{VARIATION SELECTOR-50}");
402 is("\N{VS51}", "\N{VARIATION SELECTOR-51}");
403 is("\N{VS52}", "\N{VARIATION SELECTOR-52}");
404 is("\N{VS53}", "\N{VARIATION SELECTOR-53}");
405 is("\N{VS54}", "\N{VARIATION SELECTOR-54}");
406 is("\N{VS55}", "\N{VARIATION SELECTOR-55}");
407 is("\N{VS56}", "\N{VARIATION SELECTOR-56}");
408 is("\N{VS57}", "\N{VARIATION SELECTOR-57}");
409 is("\N{VS58}", "\N{VARIATION SELECTOR-58}");
410 is("\N{VS59}", "\N{VARIATION SELECTOR-59}");
411 is("\N{VS60}", "\N{VARIATION SELECTOR-60}");
412 is("\N{VS61}", "\N{VARIATION SELECTOR-61}");
413 is("\N{VS62}", "\N{VARIATION SELECTOR-62}");
414 is("\N{VS63}", "\N{VARIATION SELECTOR-63}");
415 is("\N{VS64}", "\N{VARIATION SELECTOR-64}");
416 is("\N{VS65}", "\N{VARIATION SELECTOR-65}");
417 is("\N{VS66}", "\N{VARIATION SELECTOR-66}");
418 is("\N{VS67}", "\N{VARIATION SELECTOR-67}");
419 is("\N{VS68}", "\N{VARIATION SELECTOR-68}");
420 is("\N{VS69}", "\N{VARIATION SELECTOR-69}");
421 is("\N{VS70}", "\N{VARIATION SELECTOR-70}");
422 is("\N{VS71}", "\N{VARIATION SELECTOR-71}");
423 is("\N{VS72}", "\N{VARIATION SELECTOR-72}");
424 is("\N{VS73}", "\N{VARIATION SELECTOR-73}");
425 is("\N{VS74}", "\N{VARIATION SELECTOR-74}");
426 is("\N{VS75}", "\N{VARIATION SELECTOR-75}");
427 is("\N{VS76}", "\N{VARIATION SELECTOR-76}");
428 is("\N{VS77}", "\N{VARIATION SELECTOR-77}");
429 is("\N{VS78}", "\N{VARIATION SELECTOR-78}");
430 is("\N{VS79}", "\N{VARIATION SELECTOR-79}");
431 is("\N{VS80}", "\N{VARIATION SELECTOR-80}");
432 is("\N{VS81}", "\N{VARIATION SELECTOR-81}");
433 is("\N{VS82}", "\N{VARIATION SELECTOR-82}");
434 is("\N{VS83}", "\N{VARIATION SELECTOR-83}");
435 is("\N{VS84}", "\N{VARIATION SELECTOR-84}");
436 is("\N{VS85}", "\N{VARIATION SELECTOR-85}");
437 is("\N{VS86}", "\N{VARIATION SELECTOR-86}");
438 is("\N{VS87}", "\N{VARIATION SELECTOR-87}");
439 is("\N{VS88}", "\N{VARIATION SELECTOR-88}");
440 is("\N{VS89}", "\N{VARIATION SELECTOR-89}");
441 is("\N{VS90}", "\N{VARIATION SELECTOR-90}");
442 is("\N{VS91}", "\N{VARIATION SELECTOR-91}");
443 is("\N{VS92}", "\N{VARIATION SELECTOR-92}");
444 is("\N{VS93}", "\N{VARIATION SELECTOR-93}");
445 is("\N{VS94}", "\N{VARIATION SELECTOR-94}");
446 is("\N{VS95}", "\N{VARIATION SELECTOR-95}");
447 is("\N{VS96}", "\N{VARIATION SELECTOR-96}");
448 is("\N{VS97}", "\N{VARIATION SELECTOR-97}");
449 is("\N{VS98}", "\N{VARIATION SELECTOR-98}");
450 is("\N{VS99}", "\N{VARIATION SELECTOR-99}");
451 is("\N{VS100}", "\N{VARIATION SELECTOR-100}");
452 is("\N{VS101}", "\N{VARIATION SELECTOR-101}");
453 is("\N{VS102}", "\N{VARIATION SELECTOR-102}");
454 is("\N{VS103}", "\N{VARIATION SELECTOR-103}");
455 is("\N{VS104}", "\N{VARIATION SELECTOR-104}");
456 is("\N{VS105}", "\N{VARIATION SELECTOR-105}");
457 is("\N{VS106}", "\N{VARIATION SELECTOR-106}");
458 is("\N{VS107}", "\N{VARIATION SELECTOR-107}");
459 is("\N{VS108}", "\N{VARIATION SELECTOR-108}");
460 is("\N{VS109}", "\N{VARIATION SELECTOR-109}");
461 is("\N{VS110}", "\N{VARIATION SELECTOR-110}");
462 is("\N{VS111}", "\N{VARIATION SELECTOR-111}");
463 is("\N{VS112}", "\N{VARIATION SELECTOR-112}");
464 is("\N{VS113}", "\N{VARIATION SELECTOR-113}");
465 is("\N{VS114}", "\N{VARIATION SELECTOR-114}");
466 is("\N{VS115}", "\N{VARIATION SELECTOR-115}");
467 is("\N{VS116}", "\N{VARIATION SELECTOR-116}");
468 is("\N{VS117}", "\N{VARIATION SELECTOR-117}");
469 is("\N{VS118}", "\N{VARIATION SELECTOR-118}");
470 is("\N{VS119}", "\N{VARIATION SELECTOR-119}");
471 is("\N{VS120}", "\N{VARIATION SELECTOR-120}");
472 is("\N{VS121}", "\N{VARIATION SELECTOR-121}");
473 is("\N{VS122}", "\N{VARIATION SELECTOR-122}");
474 is("\N{VS123}", "\N{VARIATION SELECTOR-123}");
475 is("\N{VS124}", "\N{VARIATION SELECTOR-124}");
476 is("\N{VS125}", "\N{VARIATION SELECTOR-125}");
477 is("\N{VS126}", "\N{VARIATION SELECTOR-126}");
478 is("\N{VS127}", "\N{VARIATION SELECTOR-127}");
479 is("\N{VS128}", "\N{VARIATION SELECTOR-128}");
480 is("\N{VS129}", "\N{VARIATION SELECTOR-129}");
481 is("\N{VS130}", "\N{VARIATION SELECTOR-130}");
482 is("\N{VS131}", "\N{VARIATION SELECTOR-131}");
483 is("\N{VS132}", "\N{VARIATION SELECTOR-132}");
484 is("\N{VS133}", "\N{VARIATION SELECTOR-133}");
485 is("\N{VS134}", "\N{VARIATION SELECTOR-134}");
486 is("\N{VS135}", "\N{VARIATION SELECTOR-135}");
487 is("\N{VS136}", "\N{VARIATION SELECTOR-136}");
488 is("\N{VS137}", "\N{VARIATION SELECTOR-137}");
489 is("\N{VS138}", "\N{VARIATION SELECTOR-138}");
490 is("\N{VS139}", "\N{VARIATION SELECTOR-139}");
491 is("\N{VS140}", "\N{VARIATION SELECTOR-140}");
492 is("\N{VS141}", "\N{VARIATION SELECTOR-141}");
493 is("\N{VS142}", "\N{VARIATION SELECTOR-142}");
494 is("\N{VS143}", "\N{VARIATION SELECTOR-143}");
495 is("\N{VS144}", "\N{VARIATION SELECTOR-144}");
496 is("\N{VS145}", "\N{VARIATION SELECTOR-145}");
497 is("\N{VS146}", "\N{VARIATION SELECTOR-146}");
498 is("\N{VS147}", "\N{VARIATION SELECTOR-147}");
499 is("\N{VS148}", "\N{VARIATION SELECTOR-148}");
500 is("\N{VS149}", "\N{VARIATION SELECTOR-149}");
501 is("\N{VS150}", "\N{VARIATION SELECTOR-150}");
502 is("\N{VS151}", "\N{VARIATION SELECTOR-151}");
503 is("\N{VS152}", "\N{VARIATION SELECTOR-152}");
504 is("\N{VS153}", "\N{VARIATION SELECTOR-153}");
505 is("\N{VS154}", "\N{VARIATION SELECTOR-154}");
506 is("\N{VS155}", "\N{VARIATION SELECTOR-155}");
507 is("\N{VS156}", "\N{VARIATION SELECTOR-156}");
508 is("\N{VS157}", "\N{VARIATION SELECTOR-157}");
509 is("\N{VS158}", "\N{VARIATION SELECTOR-158}");
510 is("\N{VS159}", "\N{VARIATION SELECTOR-159}");
511 is("\N{VS160}", "\N{VARIATION SELECTOR-160}");
512 is("\N{VS161}", "\N{VARIATION SELECTOR-161}");
513 is("\N{VS162}", "\N{VARIATION SELECTOR-162}");
514 is("\N{VS163}", "\N{VARIATION SELECTOR-163}");
515 is("\N{VS164}", "\N{VARIATION SELECTOR-164}");
516 is("\N{VS165}", "\N{VARIATION SELECTOR-165}");
517 is("\N{VS166}", "\N{VARIATION SELECTOR-166}");
518 is("\N{VS167}", "\N{VARIATION SELECTOR-167}");
519 is("\N{VS168}", "\N{VARIATION SELECTOR-168}");
520 is("\N{VS169}", "\N{VARIATION SELECTOR-169}");
521 is("\N{VS170}", "\N{VARIATION SELECTOR-170}");
522 is("\N{VS171}", "\N{VARIATION SELECTOR-171}");
523 is("\N{VS172}", "\N{VARIATION SELECTOR-172}");
524 is("\N{VS173}", "\N{VARIATION SELECTOR-173}");
525 is("\N{VS174}", "\N{VARIATION SELECTOR-174}");
526 is("\N{VS175}", "\N{VARIATION SELECTOR-175}");
527 is("\N{VS176}", "\N{VARIATION SELECTOR-176}");
528 is("\N{VS177}", "\N{VARIATION SELECTOR-177}");
529 is("\N{VS178}", "\N{VARIATION SELECTOR-178}");
530 is("\N{VS179}", "\N{VARIATION SELECTOR-179}");
531 is("\N{VS180}", "\N{VARIATION SELECTOR-180}");
532 is("\N{VS181}", "\N{VARIATION SELECTOR-181}");
533 is("\N{VS182}", "\N{VARIATION SELECTOR-182}");
534 is("\N{VS183}", "\N{VARIATION SELECTOR-183}");
535 is("\N{VS184}", "\N{VARIATION SELECTOR-184}");
536 is("\N{VS185}", "\N{VARIATION SELECTOR-185}");
537 is("\N{VS186}", "\N{VARIATION SELECTOR-186}");
538 is("\N{VS187}", "\N{VARIATION SELECTOR-187}");
539 is("\N{VS188}", "\N{VARIATION SELECTOR-188}");
540 is("\N{VS189}", "\N{VARIATION SELECTOR-189}");
541 is("\N{VS190}", "\N{VARIATION SELECTOR-190}");
542 is("\N{VS191}", "\N{VARIATION SELECTOR-191}");
543 is("\N{VS192}", "\N{VARIATION SELECTOR-192}");
544 is("\N{VS193}", "\N{VARIATION SELECTOR-193}");
545 is("\N{VS194}", "\N{VARIATION SELECTOR-194}");
546 is("\N{VS195}", "\N{VARIATION SELECTOR-195}");
547 is("\N{VS196}", "\N{VARIATION SELECTOR-196}");
548 is("\N{VS197}", "\N{VARIATION SELECTOR-197}");
549 is("\N{VS198}", "\N{VARIATION SELECTOR-198}");
550 is("\N{VS199}", "\N{VARIATION SELECTOR-199}");
551 is("\N{VS200}", "\N{VARIATION SELECTOR-200}");
552 is("\N{VS201}", "\N{VARIATION SELECTOR-201}");
553 is("\N{VS202}", "\N{VARIATION SELECTOR-202}");
554 is("\N{VS203}", "\N{VARIATION SELECTOR-203}");
555 is("\N{VS204}", "\N{VARIATION SELECTOR-204}");
556 is("\N{VS205}", "\N{VARIATION SELECTOR-205}");
557 is("\N{VS206}", "\N{VARIATION SELECTOR-206}");
558 is("\N{VS207}", "\N{VARIATION SELECTOR-207}");
559 is("\N{VS208}", "\N{VARIATION SELECTOR-208}");
560 is("\N{VS209}", "\N{VARIATION SELECTOR-209}");
561 is("\N{VS210}", "\N{VARIATION SELECTOR-210}");
562 is("\N{VS211}", "\N{VARIATION SELECTOR-211}");
563 is("\N{VS212}", "\N{VARIATION SELECTOR-212}");
564 is("\N{VS213}", "\N{VARIATION SELECTOR-213}");
565 is("\N{VS214}", "\N{VARIATION SELECTOR-214}");
566 is("\N{VS215}", "\N{VARIATION SELECTOR-215}");
567 is("\N{VS216}", "\N{VARIATION SELECTOR-216}");
568 is("\N{VS217}", "\N{VARIATION SELECTOR-217}");
569 is("\N{VS218}", "\N{VARIATION SELECTOR-218}");
570 is("\N{VS219}", "\N{VARIATION SELECTOR-219}");
571 is("\N{VS220}", "\N{VARIATION SELECTOR-220}");
572 is("\N{VS221}", "\N{VARIATION SELECTOR-221}");
573 is("\N{VS222}", "\N{VARIATION SELECTOR-222}");
574 is("\N{VS223}", "\N{VARIATION SELECTOR-223}");
575 is("\N{VS224}", "\N{VARIATION SELECTOR-224}");
576 is("\N{VS225}", "\N{VARIATION SELECTOR-225}");
577 is("\N{VS226}", "\N{VARIATION SELECTOR-226}");
578 is("\N{VS227}", "\N{VARIATION SELECTOR-227}");
579 is("\N{VS228}", "\N{VARIATION SELECTOR-228}");
580 is("\N{VS229}", "\N{VARIATION SELECTOR-229}");
581 is("\N{VS230}", "\N{VARIATION SELECTOR-230}");
582 is("\N{VS231}", "\N{VARIATION SELECTOR-231}");
583 is("\N{VS232}", "\N{VARIATION SELECTOR-232}");
584 is("\N{VS233}", "\N{VARIATION SELECTOR-233}");
585 is("\N{VS234}", "\N{VARIATION SELECTOR-234}");
586 is("\N{VS235}", "\N{VARIATION SELECTOR-235}");
587 is("\N{VS236}", "\N{VARIATION SELECTOR-236}");
588 is("\N{VS237}", "\N{VARIATION SELECTOR-237}");
589 is("\N{VS238}", "\N{VARIATION SELECTOR-238}");
590 is("\N{VS239}", "\N{VARIATION SELECTOR-239}");
591 is("\N{VS240}", "\N{VARIATION SELECTOR-240}");
592 is("\N{VS241}", "\N{VARIATION SELECTOR-241}");
593 is("\N{VS242}", "\N{VARIATION SELECTOR-242}");
594 is("\N{VS243}", "\N{VARIATION SELECTOR-243}");
595 is("\N{VS244}", "\N{VARIATION SELECTOR-244}");
596 is("\N{VS245}", "\N{VARIATION SELECTOR-245}");
597 is("\N{VS246}", "\N{VARIATION SELECTOR-246}");
598 is("\N{VS247}", "\N{VARIATION SELECTOR-247}");
599 is("\N{VS248}", "\N{VARIATION SELECTOR-248}");
600 is("\N{VS249}", "\N{VARIATION SELECTOR-249}");
601 is("\N{VS250}", "\N{VARIATION SELECTOR-250}");
602 is("\N{VS251}", "\N{VARIATION SELECTOR-251}");
603 is("\N{VS252}", "\N{VARIATION SELECTOR-252}");
604 is("\N{VS253}", "\N{VARIATION SELECTOR-253}");
605 is("\N{VS254}", "\N{VARIATION SELECTOR-254}");
606 is("\N{VS255}", "\N{VARIATION SELECTOR-255}");
607 is("\N{VS256}", "\N{VARIATION SELECTOR-256}");
608}
609
e5c3f898
MG
610# [perl #30409] charnames.pm clobbers default variable
611$_ = 'foobar';
612eval "use charnames ':full';";
a0d8d8c5 613is($_, 'foobar');
e5c3f898 614
c776535e
NC
615# Unicode slowdown noted by Phil Pennock, traced to a bug fix in index
616# SADAHIRO Tomoyuki's suggestion is to ensure that the UTF-8ness of both
617# arguments are indentical before calling index.
618# To do this can take advantage of the fact that unicore/Name.pl is 7 bit
e5d6fe1e
KW
619# (or at least should be). So assert that that it's true here. EBCDIC
620# may be a problem (khw).
c776535e
NC
621
622my $names = do "unicore/Name.pl";
a0d8d8c5
KW
623ok(defined $names);
624my $non_ascii = native_to_latin1($names) =~ tr/\0-\177//c;
5a7fb30a 625ok(! $non_ascii, "Verify all official names are ASCII-only");
c776535e 626
eb915052
RGS
627# Verify that charnames propagate to eval("")
628my $evaltry = eval q[ "Eval: \N{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}" ];
629if ($@) {
a0d8d8c5
KW
630 fail('charnames failed to propagate to eval("")');
631 fail('next test also fails to make the same number of tests');
eb915052 632} else {
a0d8d8c5
KW
633 pass('charnames propagated to eval("")');
634 is($evaltry, "Eval: \N{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}");
eb915052 635}
c776535e 636
ae6979a8 637# Verify that db includes the normative NameAliases.txt names
a0d8d8c5 638is("\N{U+1D0C5}", "\N{BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA VASIS}");
ae6979a8 639
ec34a119
DM
640# [perl #73174] use of \N{FOO} used to reset %^H
641
642{
643 use charnames ":full";
644 my $res;
645 BEGIN { $^H{73174} = "foo" }
646 BEGIN { $res = ($^H{73174} // "") }
647 # forces loading of utf8.pm, which used to reset %^H
648 $res .= '-1' if ":" =~ /\N{COLON}/i;
649 BEGIN { $res .= '-' . ($^H{73174} // "") }
650 $res .= '-' . ($^H{73174} // "");
651 $res .= '-2' if ":" =~ /\N{COLON}/;
652 $res .= '-3' if ":" =~ /\N{COLON}/i;
a0d8d8c5 653 is($res, "foo-foo-1--2-3");
ec34a119 654}
84374e30
KW
655
656{
657 # Test scoping. Outer block sets up some things; inner blocks
658 # override them, and then see if get restored.
659
660 use charnames ":full",
661 ":alias" => {
662 mychar1 => "LATIN SMALL LETTER E",
663 mychar2 => "LATIN CAPITAL LETTER A",
664 myprivate1 => 0xE8000, # Private use area
665 myprivate2 => 0x100000, # Private use area
666 },
667 ":short",
668 qw( katakana ),
669 ;
670
671 my $hiragana_be = "\N{HIRAGANA LETTER BE}";
672
673 is("\N{mychar1}", "e", "Outer block: verify that \\N{mychar1} works");
674 is(charnames::vianame("mychar1"), ord("e"), "Outer block: verify that vianame(mychar1) works");
675 is("\N{mychar2}", "A", "Outer block: verify that \\N{mychar2} works");
676 is(charnames::vianame("mychar2"), ord("A"), "Outer block: verify that vianame(mychar2) works");
677 is("\N{myprivate1}", "\x{E8000}", "Outer block: verify that \\N{myprivate1} works");
678 cmp_ok(charnames::vianame("myprivate1"), "==", 0xE8000, "Outer block: verify that vianame(myprivate1) works");
679 is(charnames::viacode(0xE8000), "myprivate1", "Outer block: verify that myprivate1 viacode works");
680 is("\N{myprivate2}", "\x{100000}", "Outer block: verify that \\N{myprivate2} works");
681 cmp_ok(charnames::vianame("myprivate2"), "==", 0x100000, "Outer block: verify that vianame(myprivate2) works");
682 is(charnames::viacode(0x100000), "myprivate2", "Outer block: verify that myprivate2 viacode works");
683 is("\N{BE}", "\N{KATAKANA LETTER BE}", "Outer block: verify that \\N uses the correct script ");
684 cmp_ok(charnames::vianame("BE"), "==", ord("\N{KATAKANA LETTER BE}"), "Outer block: verify that vianame uses the correct script");
e3cca8af
KW
685 is("\N{Hiragana: BE}", $hiragana_be, "Outer block: verify that :short works with \\N");
686 cmp_ok(charnames::vianame("Hiragana: BE"), "==", ord($hiragana_be), "Outer block: verify that :short works with vianame");
84374e30
KW
687
688 {
689 use charnames ":full",
690 ":alias" => {
691 mychar1 => "LATIN SMALL LETTER F",
692 myprivate1 => 0xE8001, # Private use area
693 },
694
695 # BE is in both hiragana and katakana; see if
696 # different default script delivers different
697 # letter.
698 qw( hiragana ),
699 ;
700 is("\N{mychar1}", "f", "Inner block: verify that \\N{mychar1} is redefined");
701 is(charnames::vianame("mychar1"), ord("f"), "Inner block: verify that vianame(mychar1) is redefined");
702 is("\N{mychar2}", "\x{FFFD}", "Inner block: verify that \\N{mychar2} outer definition didn't leak");
703 ok( ! defined charnames::vianame("mychar2"), "Inner block: verify that vianame(mychar2) outer definition didn't leak");
704 is("\N{myprivate1}", "\x{E8001}", "Inner block: verify that \\N{myprivate1} is redefined ");
705 cmp_ok(charnames::vianame("myprivate1"), "==", 0xE8001, "Inner block: verify that vianame(myprivate1) is redefined");
706 is(charnames::viacode(0xE8001), "myprivate1", "Inner block: verify that myprivate1 viacode is redefined");
707 ok(! defined charnames::viacode(0xE8000), "Inner block: verify that outer myprivate1 viacode didn't leak");
708 is("\N{myprivate2}", "\x{FFFD}", "Inner block: verify that \\N{myprivate2} outer definition didn't leak");
709 ok(! defined charnames::vianame("myprivate2"), "Inner block: verify that vianame(myprivate2) outer definition didn't leak");
710 ok(! defined charnames::viacode(0x100000), "Inner block: verify that myprivate2 viacode outer definition didn't leak");
711 is("\N{BE}", $hiragana_be, "Inner block: verify that \\N uses the correct script");
712 cmp_ok(charnames::vianame("BE"), "==", ord($hiragana_be), "Inner block: verify that vianame uses the correct script");
e3cca8af
KW
713 is("\N{Hiragana: BE}", "\x{FFFD}", "Inner block without :short: \\N with short doesn't work");
714 ok(! defined charnames::vianame("Hiragana: BE"), "Inner block without :short: verify that vianame with short doesn't work");
84374e30
KW
715
716 { # An inner block where only :short definitions are valid.
717 use charnames ":short";
718 is("\N{mychar1}", "\x{FFFD}", "Inner inner block: verify that mychar1 outer definition didn't leak with \\N");
719 ok( ! defined charnames::vianame("mychar1"), "Inner inner block: verify that mychar1 outer definition didn't leak with vianame");
720 is("\N{mychar2}", "\x{FFFD}", "Inner inner block: verify that mychar2 outer definition didn't leak with \\N");
721 ok( ! defined charnames::vianame("mychar2"), "Inner inner block: verify that mychar2 outer definition didn't leak with vianame");
722 is("\N{myprivate1}", "\x{FFFD}", "Inner inner block: verify that myprivate1 outer definition didn't leak with \\N");
723 ok(! defined charnames::vianame("myprivate1"), "Inner inner block: verify that myprivate1 outer definition didn't leak with vianame");
724 is("\N{myprivate2}", "\x{FFFD}", "Inner inner block: verify that myprivate2 outer definition didn't leak with \\N");
725 ok(! defined charnames::vianame("myprivate2"), "Inner inner block: verify that myprivate2 outer definition didn't leak with vianame");
726 ok(! defined charnames::viacode(0xE8000), "Inner inner block: verify that mychar1 outer outer definition didn't leak with viacode");
727 ok(! defined charnames::viacode(0xE8001), "Inner inner block: verify that mychar1 outer definition didn't leak with viacode");
728 ok(! defined charnames::viacode(0x100000), "Inner inner block: verify that mychar2 outer definition didn't leak with viacode");
729 is("\N{BE}", "\x{FFFD}", "Inner inner block without script: verify that outer :script didn't leak with \\N");
730 ok(! defined charnames::vianame("BE"), "Inner inner block without script: verify that outer :script didn't leak with vianames");
731 is("\N{HIRAGANA LETTER BE}", "\x{FFFD}", "Inner inner block without :full: verify that outer :full didn't leak with \\N");
e3cca8af
KW
732 is("\N{Hiragana: BE}", $hiragana_be, "Inner inner block with :short: verify that \\N works with :short");
733 cmp_ok(charnames::vianame("Hiragana: BE"), "==", ord($hiragana_be), "Inner inner block with :short: verify that vianame works with :short");
84374e30
KW
734 }
735
736 # Back to previous block. All previous tests should work again.
737 is("\N{mychar1}", "f", "Inner block: verify that \\N{mychar1} is redefined");
738 is(charnames::vianame("mychar1"), ord("f"), "Inner block: verify that vianame(mychar1) is redefined");
739 is("\N{mychar2}", "\x{FFFD}", "Inner block: verify that \\N{mychar2} outer definition didn't leak");
740 ok( ! defined charnames::vianame("mychar2"), "Inner block: verify that vianame(mychar2) outer definition didn't leak");
741 is("\N{myprivate1}", "\x{E8001}", "Inner block: verify that \\N{myprivate1} is redefined ");
742 cmp_ok(charnames::vianame("myprivate1"), "==", 0xE8001, "Inner block: verify that vianame(myprivate1) is redefined");
743 is(charnames::viacode(0xE8001), "myprivate1", "Inner block: verify that myprivate1 viacode is redefined");
744 ok(! defined charnames::viacode(0xE8000), "Inner block: verify that outer myprivate1 viacode didn't leak");
745 is("\N{myprivate2}", "\x{FFFD}", "Inner block: verify that \\N{myprivate2} outer definition didn't leak");
746 ok(! defined charnames::vianame("myprivate2"), "Inner block: verify that vianame(myprivate2) outer definition didn't leak");
747 ok(! defined charnames::viacode(0x100000), "Inner block: verify that myprivate2 viacode outer definition didn't leak");
748 is("\N{BE}", $hiragana_be, "Inner block: verify that \\N uses the correct script");
749 cmp_ok(charnames::vianame("BE"), "==", ord($hiragana_be), "Inner block: verify that vianame uses the correct script");
e3cca8af
KW
750 is("\N{Hiragana: BE}", "\x{FFFD}", "Inner block without :short: \\N with short doesn't work");
751 ok(! defined charnames::vianame("Hiragana: BE"), "Inner block without :short: verify that vianame with short doesn't work");
84374e30
KW
752 }
753
754 # Back to previous block. All tests from that block should work again.
755 is("\N{mychar1}", "e", "Outer block: verify that \\N{mychar1} works");
756 is(charnames::vianame("mychar1"), ord("e"), "Outer block: verify that vianame(mychar1) works");
757 is("\N{mychar2}", "A", "Outer block: verify that \\N{mychar2} works");
758 is(charnames::vianame("mychar2"), ord("A"), "Outer block: verify that vianame(mychar2) works");
759 is("\N{myprivate1}", "\x{E8000}", "Outer block: verify that \\N{myprivate1} works");
760 cmp_ok(charnames::vianame("myprivate1"), "==", 0xE8000, "Outer block: verify that vianame(myprivate1) works");
761 is(charnames::viacode(0xE8000), "myprivate1", "Outer block: verify that myprivate1 viacode works");
762 is("\N{myprivate2}", "\x{100000}", "Outer block: verify that \\N{myprivate2} works");
763 cmp_ok(charnames::vianame("myprivate2"), "==", 0x100000, "Outer block: verify that vianame(myprivate2) works");
764 is(charnames::viacode(0x100000), "myprivate2", "Outer block: verify that myprivate2 viacode works");
765 is("\N{BE}", "\N{KATAKANA LETTER BE}", "Outer block: verify that \\N uses the correct script ");
766 cmp_ok(charnames::vianame("BE"), "==", ord("\N{KATAKANA LETTER BE}"), "Outer block: verify that vianame uses the correct script");
e3cca8af
KW
767 is("\N{Hiragana: BE}", $hiragana_be, "Outer block: verify that :short works with \\N");
768 cmp_ok(charnames::vianame("Hiragana: BE"), "==", ord($hiragana_be), "Outer block: verify that :short works with vianame");
84374e30 769}