1 Tests for use charnames with compilation errors and aliases.
5 use charnames ":scoobydoo";
6 "Here: \N{e_ACUTE}!\n";
9 unsupported special ':scoobydoo' in charnames at
11 # NAME autoload doesn't get vianame
12 print "Here: \N{DIGIT ONE}\n";
13 charnames::vianame("DIGIT TWO");
16 Undefined subroutine &charnames::vianame called at - line \d+.
19 # NAME autoload doesn't get viacode
20 print "Here: \N{DIGIT THREE}\n";
21 charnames::viacode(utf8::unicode_to_native(0x34));
24 Undefined subroutine &charnames::viacode called at - line \d+.
27 # NAME autoload doesn't get string_vianame
28 print "Here: \N{DIGIT FOUR}\n";
29 charnames::string_vianame("DIGIT FIVE");
32 Undefined subroutine &charnames::string_vianame called at - line \d+.
35 # NAME wrong type of alias (missing colon)
37 use charnames "alias";
38 "Here: \N{e_ACUTE}!\n";
41 Unknown charname 'e_ACUTE' at - line \d+, within string
43 # NAME alias without an argument
45 use charnames ":alias";
46 "Here: \N{e_ACUTE}!\n";
49 :alias needs an argument in charnames at
51 # NAME reversed sequence
53 use charnames ":alias" => ":full";
54 "Here: \N{e_ACUTE}!\n";
57 :alias cannot use existing pragma :full \(reversed order\?\) at
59 # NAME alias with hashref but with :short
62 use charnames ":short", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
63 "Here: \N{e_ACUTE}!\n";
66 Unknown charname 'e_ACUTE' at - line \d+, within string
68 # NAME alias with hashref to :full OK
71 use charnames ":full", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
72 "Here: \N{e_ACUTE}!\n";
77 # NAME alias with hashref to :loose OK
80 use charnames ":loose", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
81 "Here: \N{e_ACUTE}!\n";
86 # NAME alias with :loose requires :full type name
89 use charnames ":loose", ":alias" => { e_ACUTE => "latin SMALL LETTER E WITH ACUTE" };
90 "Here: \N{e_ACUTE}!\n";
93 Unknown charname 'e_ACUTE' at - line \d+, within string
95 # NAME alias with hashref to :short but using :full
98 use charnames ":full", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" };
99 "Here: \N{e_ACUTE}!\n";
102 Unknown charname 'e_ACUTE' at - line \d+, within string
104 # NAME alias with hashref to :short OK
107 use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" };
108 "Here: \N{e_ACUTE}!\n";
113 # NAME alias with bad hashref
116 use charnames ":short", ":alias" => "e_ACUTE";
117 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
120 unicore/e_ACUTE_alias.pl cannot be used as alias file for charnames at
122 # NAME alias with arrayref
125 use charnames ":short", ":alias" => [ e_ACUTE => "LATIN:e WITH ACUTE" ];
126 "Here: \N{e_ACUTE}!\n";
129 Only HASH reference supported as argument to :alias at
131 # NAME alias with bad hashref
133 use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE", "a_ACUTE" };
134 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
137 Unknown charname 'a_ACUTE' at
139 # NAME alias with hashref two aliases
142 use charnames ":short", ":alias" => {
143 e_ACUTE => "LATIN:e WITH ACUTE",
146 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
149 Unknown charname 'a_ACUTE' at - line \d+, within string
151 # NAME alias with hashref two aliases
154 use charnames ":short", ":alias" => {
155 e_ACUTE => "LATIN:e WITH ACUTE",
156 a_ACUTE => "LATIN:a WITH ACUTE",
158 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
163 # NAME alias with hashref using mixed aliases
165 use charnames ":short", ":alias" => {
166 e_ACUTE => "LATIN:e WITH ACUTE",
167 a_ACUTE => "LATIN SMALL LETTER A WITH ACUT",
169 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
172 Unknown charname 'a_ACUTE' at - line \d+, within string
174 # NAME alias with hashref using mixed aliases
176 use charnames ":short", ":alias" => {
177 e_ACUTE => "LATIN:e WITH ACUTE",
178 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
180 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
183 Unknown charname 'a_ACUTE' at - line \d+, within string
185 # NAME alias with hashref using mixed aliases
188 use charnames ":full", ":alias" => {
189 e_ACUTE => "LATIN:e WITH ACUTE",
190 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
192 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
195 Unknown charname 'e_ACUTE' at - line \d+, within string
197 # NAME alias with nonexisting file
200 use charnames ":full", ":alias" => "non_existing_xyzzy";
201 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
204 unicore/non_existing_xyzzy_alias.pl cannot be used as alias file for charnames at
206 # NAME alias with bad file name
209 use charnames ":full", ":alias" => "xy 7-";
210 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
213 Charnames alias file names can only have identifier characters at
215 # NAME alias with non_absolute (existing) file name (which it should /not/ use)
218 use charnames ":full", ":alias" => "perl";
219 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
222 unicore/perl_alias.pl cannot be used as alias file for charnames at
224 # NAME alias with bad file
225 --FILE-- ../../lib/unicore/xyzzy_alias.pl
231 use charnames ":full", ":alias" => "xyzzy";
232 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
235 unicore/xyzzy_alias.pl did not return a \(valid\) list of alias pairs at
237 # NAME alias with file with empty list
238 --FILE-- ../../lib/unicore/xyzzy_alias.pl
244 use charnames ":full", ":alias" => "xyzzy";
245 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
248 Unknown charname 'e_ACUTE' at - line \d+, within string
250 # NAME alias with file OK but file has :short aliases
251 --FILE-- ../../lib/unicore/xyzzy_alias.pl
253 ( e_ACUTE => "LATIN:e WITH ACUTE",
254 a_ACUTE => "LATIN:a WITH ACUTE",
259 use charnames ":full", ":alias" => "xyzzy";
260 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
263 Unknown charname 'e_ACUTE' at - line \d+, within string
265 # NAME alias with :short and file OK
266 --FILE-- ../../lib/unicore/xyzzy_alias.pl
268 ( e_ACUTE => "LATIN:e WITH ACUTE",
269 a_ACUTE => "LATIN:a WITH ACUTE",
274 use charnames ":short", ":alias" => "xyzzy";
275 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
280 # NAME alias with :short and file OK has :long aliases
281 --FILE-- ../../lib/unicore/xyzzy_alias.pl
283 ( e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
284 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
289 use charnames ":short", ":alias" => "xyzzy";
290 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
293 Unknown charname 'e_ACUTE' at - line \d+, within string
295 # NAME alias with file implicit :full but file has :short aliases
296 --FILE-- ../../lib/unicore/xyzzy_alias.pl
298 ( e_ACUTE => "LATIN:e WITH ACUTE",
299 a_ACUTE => "LATIN:a WITH ACUTE",
304 use charnames ":alias" => ":xyzzy";
305 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
308 Unknown charname 'e_ACUTE' at - line \d+, within string
310 # NAME alias with file implicit :full and file has :long aliases
311 --FILE-- ../../lib/unicore/xyzzy_alias.pl
313 ( e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
314 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
319 use charnames ":alias" => ":xyzzy";
320 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
325 # NAME charnames with no import still works for runtime functions
329 charnames::vianame('SPACE');
330 charnames::viacode(utf8::unicode_to_native(0x41));
335 # NAME no extraneous warning [perl #11560]
338 print charnames::viacode(utf8::unicode_to_native(0x80)), "\n";
343 # NAME A wrong character in :alias is an error
344 # These next tests could be combined, but the messages can come out in
345 # different orders on EBCDIC vs ASCII, and can't have both 'random' and 'regex'
346 # options, and need 'regex' to avoid 'at line X' getting in the way.
347 use charnames ":full", ":alias" => {
348 "4e_ACUTE" => "LATIN SMALL LETTER E WITH ACUTE",
352 Invalid character in charnames alias definition; marked by <-- HERE in '4<-- HERE e_ACUTE'
354 # NAME Another wrong character in :alias is an error
355 use charnames ":full", ":alias" => {
356 "e_A,CUTE" => "LATIN SMALL LETTER E WITH ACUTE",
360 Invalid character in charnames alias definition; marked by <-- HERE in 'e_A,<-- HERE CUTE'
362 # NAME Another wrong character in :alias is an error
363 # The EXPECT regex matches both the UTF-8 and non-UTF-8 form.
364 # This is because under some circumstances the message gets output as UTF-8.
365 # We use \xab, as that is invalid in both ASCII and EBCDIC platforms, and we
366 # accept both UTF-8 and 1047 UTF-EBCDIC.
367 use charnames ":full", ":alias" => {
368 "e_ACUT\x{ab}E" => "LATIN SMALL LETTER E WITH ACUTE",
372 Invalid character in charnames alias definition; marked by <-- HERE in 'e_ACUT(?:\x{ab}|\x{C2}\x{AB}|\x{80\x{73})<-- HERE E'
375 # NAME \N{...} interprets ... as octets rather than UTF-8
377 use open qw( :utf8 :std );
378 use charnames ":full", ":alias" => { "自転車に乗る人" => "BICYCLIST" };
379 print "ok\n" if "\N{自転車に乗る人}" eq "\x{1F6B4}";
383 # NAME Misspelled \N{} UTF-8 names are errors
385 use open qw( :utf8 :std );
386 use charnames ":full", ":alias" => { "自転車に乗る人" => "BICYCLIST" };
387 print "ok\n" if "\N{転車に乗る人}" eq "\x{1F6B4}";
390 Unknown charname '転車に乗る人' at - line \d+, within string
392 # NAME various wrong UTF-8 characters in :alias are errors
393 # First has a punctuation, KATAKANA MIDDLE DOT, in it; second begins with a
394 # digit: ARABIC-INDIC DIGIT FOUR
395 # Note that output order is alphabetical by character name
397 use open qw( :utf8 :std );
398 use charnames ":full", ":alias" => { "自転車・に乗る人" => "BICYCLIST",
399 "٤転車に乗る人" => "BICYCLIST",
400 "TOO MANY SPACES" => "NO ENTRY SIGN",
401 "TRAILING SPACE " => "FACE WITH NO GOOD GESTURE"
403 print "ok\n" if "\N{TOO MANY SPACES}" eq "\x{1F6AB}";
404 print "ok\n" if "\N{TRAILING SPACE }" eq "\x{1F645}";
405 print "ok\n" if "\N{自転車・に乗る人}" eq "\x{1F6B4}";
406 print "ok\n" if "\N{٤転車に乗る人}" eq "\x{1F6B4}";
409 charnames alias definitions may not contain a sequence of multiple spaces; marked by <-- HERE in 'TOO <-- HERE MANY SPACES'
410 charnames alias definitions may not contain trailing white-space; marked by <-- HERE in 'TRAILING SPACE <-- HERE '
411 Invalid character in charnames alias definition; marked by <-- HERE in '٤<-- HERE 転車に乗る人'
412 Invalid character in charnames alias definition; marked by <-- HERE in '自転車・<-- HERE に乗る人' at - line \d+
414 # NAME Using NBSP in :alias names is deprecated
416 use open qw( :utf8 :std );
417 use charnames ":alias" => { "NBSP SEPARATED SPACE" => "BLACK SMILING FACE" };
418 print "ok\n" if "\N{NBSP SEPARATED SPACE}" eq "\x{263B}";
421 Invalid character in charnames alias definition; marked by <-- HERE in 'NBSP <-- HERE SEPARATED SPACE' at - line 3