Commit | Line | Data |
---|---|---|
fbb93542 | 1 | Tests for use charnames with compilation errors and aliases. |
ea065648 | 2 | __END__ |
22dc4229 | 3 | # NAME illegal :pragma |
8f852052 | 4 | use warnings; |
ea065648 NC |
5 | use charnames ":scoobydoo"; |
6 | "Here: \N{e_ACUTE}!\n"; | |
7 | EXPECT | |
8 | OPTIONS regex | |
9 | unsupported special ':scoobydoo' in charnames at | |
10 | ######## | |
fbb93542 KW |
11 | # NAME autoload doesn't get vianame |
12 | print "Here: \N{DIGIT ONE}\n"; | |
13 | charnames::vianame("DIGIT TWO"); | |
14 | EXPECT | |
1015ff30 KW |
15 | OPTIONS regex |
16 | Undefined subroutine &charnames::vianame called at - line \d+. | |
fbb93542 KW |
17 | Here: 1 |
18 | ######## | |
19 | # NAME autoload doesn't get viacode | |
20 | print "Here: \N{DIGIT THREE}\n"; | |
27c3afbd | 21 | charnames::viacode(utf8::unicode_to_native(0x34)); |
fbb93542 KW |
22 | EXPECT |
23 | OPTIONS regex | |
1015ff30 | 24 | Undefined subroutine &charnames::viacode called at - line \d+. |
fbb93542 KW |
25 | Here: 3 |
26 | ######## | |
27 | # NAME autoload doesn't get string_vianame | |
28 | print "Here: \N{DIGIT FOUR}\n"; | |
29 | charnames::string_vianame("DIGIT FIVE"); | |
30 | EXPECT | |
31 | OPTIONS regex | |
1015ff30 | 32 | Undefined subroutine &charnames::string_vianame called at - line \d+. |
fbb93542 KW |
33 | Here: 4 |
34 | ######## | |
22dc4229 | 35 | # NAME wrong type of alias (missing colon) |
8f852052 | 36 | no warnings; |
ea065648 NC |
37 | use charnames "alias"; |
38 | "Here: \N{e_ACUTE}!\n"; | |
39 | EXPECT | |
1015ff30 KW |
40 | OPTIONS regex fatal |
41 | Unknown charname 'e_ACUTE' at - line \d+, within string | |
ea065648 | 42 | ######## |
22dc4229 | 43 | # NAME alias without an argument |
8f852052 | 44 | use warnings; |
ea065648 NC |
45 | use charnames ":alias"; |
46 | "Here: \N{e_ACUTE}!\n"; | |
47 | EXPECT | |
48 | OPTIONS regex | |
49 | :alias needs an argument in charnames at | |
50 | ######## | |
22dc4229 | 51 | # NAME reversed sequence |
8f852052 | 52 | use warnings; |
ea065648 NC |
53 | use charnames ":alias" => ":full"; |
54 | "Here: \N{e_ACUTE}!\n"; | |
55 | EXPECT | |
56 | OPTIONS regex | |
57 | :alias cannot use existing pragma :full \(reversed order\?\) at | |
58 | ######## | |
22dc4229 | 59 | # NAME alias with hashref but with :short |
8f852052 KW |
60 | use warnings; |
61 | no warnings 'void'; | |
ea065648 NC |
62 | use charnames ":short", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" }; |
63 | "Here: \N{e_ACUTE}!\n"; | |
64 | EXPECT | |
1015ff30 KW |
65 | OPTIONS regex fatal |
66 | Unknown charname 'e_ACUTE' at - line \d+, within string | |
ea065648 | 67 | ######## |
22dc4229 | 68 | # NAME alias with hashref to :full OK |
8f852052 KW |
69 | use warnings; |
70 | no warnings 'void'; | |
ea065648 NC |
71 | use charnames ":full", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" }; |
72 | "Here: \N{e_ACUTE}!\n"; | |
73 | EXPECT | |
74 | OPTIONS regex | |
75 | $ | |
76 | ######## | |
22dc4229 | 77 | # NAME alias with hashref to :loose OK |
38f4139d KW |
78 | use warnings; |
79 | no warnings 'void'; | |
80 | use charnames ":loose", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" }; | |
81 | "Here: \N{e_ACUTE}!\n"; | |
82 | EXPECT | |
83 | OPTIONS regex | |
84 | $ | |
85 | ######## | |
22dc4229 | 86 | # NAME alias with :loose requires :full type name |
38f4139d KW |
87 | use warnings; |
88 | no warnings 'void'; | |
89 | use charnames ":loose", ":alias" => { e_ACUTE => "latin SMALL LETTER E WITH ACUTE" }; | |
90 | "Here: \N{e_ACUTE}!\n"; | |
91 | EXPECT | |
1015ff30 KW |
92 | OPTIONS regex fatal |
93 | Unknown charname 'e_ACUTE' at - line \d+, within string | |
38f4139d | 94 | ######## |
22dc4229 | 95 | # NAME alias with hashref to :short but using :full |
8f852052 KW |
96 | use warnings; |
97 | no warnings 'void'; | |
ea065648 NC |
98 | use charnames ":full", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" }; |
99 | "Here: \N{e_ACUTE}!\n"; | |
100 | EXPECT | |
1015ff30 KW |
101 | OPTIONS regex fatal |
102 | Unknown charname 'e_ACUTE' at - line \d+, within string | |
ea065648 | 103 | ######## |
22dc4229 | 104 | # NAME alias with hashref to :short OK |
8f852052 KW |
105 | use warnings; |
106 | no warnings 'void'; | |
ea065648 NC |
107 | use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" }; |
108 | "Here: \N{e_ACUTE}!\n"; | |
109 | EXPECT | |
110 | OPTIONS regex | |
111 | $ | |
112 | ######## | |
22dc4229 | 113 | # NAME alias with bad hashref |
8f852052 KW |
114 | use warnings; |
115 | no warnings 'void'; | |
ea065648 NC |
116 | use charnames ":short", ":alias" => "e_ACUTE"; |
117 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
118 | EXPECT | |
119 | OPTIONS regex | |
120 | unicore/e_ACUTE_alias.pl cannot be used as alias file for charnames at | |
121 | ######## | |
22dc4229 | 122 | # NAME alias with arrayref |
8f852052 KW |
123 | use warnings; |
124 | no warnings 'void'; | |
ea065648 NC |
125 | use charnames ":short", ":alias" => [ e_ACUTE => "LATIN:e WITH ACUTE" ]; |
126 | "Here: \N{e_ACUTE}!\n"; | |
127 | EXPECT | |
128 | OPTIONS regex | |
129 | Only HASH reference supported as argument to :alias at | |
130 | ######## | |
22dc4229 | 131 | # NAME alias with bad hashref |
8f852052 | 132 | no warnings; |
ea065648 NC |
133 | use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE", "a_ACUTE" }; |
134 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
135 | EXPECT | |
136 | OPTIONS regex | |
84374e30 | 137 | Unknown charname 'a_ACUTE' at |
ea065648 | 138 | ######## |
22dc4229 | 139 | # NAME alias with hashref two aliases |
8f852052 KW |
140 | use warnings; |
141 | no warnings 'void'; | |
ea065648 NC |
142 | use charnames ":short", ":alias" => { |
143 | e_ACUTE => "LATIN:e WITH ACUTE", | |
144 | a_ACUTE => "", | |
145 | }; | |
146 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
147 | EXPECT | |
1015ff30 KW |
148 | OPTIONS regex fatal |
149 | Unknown charname 'a_ACUTE' at - line \d+, within string | |
ea065648 | 150 | ######## |
22dc4229 | 151 | # NAME alias with hashref two aliases |
8f852052 KW |
152 | use warnings; |
153 | no warnings 'void'; | |
ea065648 NC |
154 | use charnames ":short", ":alias" => { |
155 | e_ACUTE => "LATIN:e WITH ACUTE", | |
156 | a_ACUTE => "LATIN:a WITH ACUTE", | |
157 | }; | |
158 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
159 | EXPECT | |
160 | OPTIONS regex | |
161 | $ | |
162 | ######## | |
22dc4229 | 163 | # NAME alias with hashref using mixed aliases |
8f852052 | 164 | use warnings; |
ea065648 NC |
165 | use charnames ":short", ":alias" => { |
166 | e_ACUTE => "LATIN:e WITH ACUTE", | |
167 | a_ACUTE => "LATIN SMALL LETTER A WITH ACUT", | |
168 | }; | |
169 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
170 | EXPECT | |
1015ff30 KW |
171 | OPTIONS regex fatal |
172 | Unknown charname 'a_ACUTE' at - line \d+, within string | |
ea065648 | 173 | ######## |
22dc4229 | 174 | # NAME alias with hashref using mixed aliases |
8f852052 | 175 | use warnings; |
ea065648 NC |
176 | use charnames ":short", ":alias" => { |
177 | e_ACUTE => "LATIN:e WITH ACUTE", | |
178 | a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE", | |
179 | }; | |
180 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
181 | EXPECT | |
1015ff30 KW |
182 | OPTIONS regex fatal |
183 | Unknown charname 'a_ACUTE' at - line \d+, within string | |
ea065648 | 184 | ######## |
22dc4229 | 185 | # NAME alias with hashref using mixed aliases |
8f852052 KW |
186 | use warnings; |
187 | no warnings 'void'; | |
ea065648 NC |
188 | use charnames ":full", ":alias" => { |
189 | e_ACUTE => "LATIN:e WITH ACUTE", | |
190 | a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE", | |
191 | }; | |
192 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
193 | EXPECT | |
1015ff30 KW |
194 | OPTIONS regex fatal |
195 | Unknown charname 'e_ACUTE' at - line \d+, within string | |
ea065648 | 196 | ######## |
22dc4229 | 197 | # NAME alias with nonexisting file |
8f852052 KW |
198 | use warnings; |
199 | no warnings 'void'; | |
34ea573b | 200 | use charnames ":full", ":alias" => "non_existing_xyzzy"; |
ea065648 NC |
201 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; |
202 | EXPECT | |
203 | OPTIONS regex | |
34ea573b | 204 | unicore/non_existing_xyzzy_alias.pl cannot be used as alias file for charnames at |
ea065648 | 205 | ######## |
22dc4229 | 206 | # NAME alias with bad file name |
8f852052 KW |
207 | use warnings; |
208 | no warnings 'void'; | |
ea065648 NC |
209 | use charnames ":full", ":alias" => "xy 7-"; |
210 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
211 | EXPECT | |
212 | OPTIONS regex | |
013b94b6 | 213 | Charnames alias file names can only have identifier characters at |
ea065648 | 214 | ######## |
22dc4229 | 215 | # NAME alias with non_absolute (existing) file name (which it should /not/ use) |
8f852052 KW |
216 | use warnings; |
217 | no warnings 'void'; | |
ea065648 NC |
218 | use charnames ":full", ":alias" => "perl"; |
219 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
220 | EXPECT | |
221 | OPTIONS regex | |
222 | unicore/perl_alias.pl cannot be used as alias file for charnames at | |
223 | ######## | |
99bc9185 | 224 | # NAME alias with bad file |
463cf062 | 225 | --FILE-- ../../lib/unicore/xyzzy_alias.pl |
ea065648 NC |
226 | #!perl |
227 | 0; | |
228 | --FILE-- | |
8f852052 KW |
229 | use warnings; |
230 | no warnings 'void'; | |
ea065648 NC |
231 | use charnames ":full", ":alias" => "xyzzy"; |
232 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
233 | EXPECT | |
234 | OPTIONS regex | |
235 | unicore/xyzzy_alias.pl did not return a \(valid\) list of alias pairs at | |
236 | ######## | |
99bc9185 | 237 | # NAME alias with file with empty list |
463cf062 | 238 | --FILE-- ../../lib/unicore/xyzzy_alias.pl |
ea065648 NC |
239 | #!perl |
240 | (); | |
241 | --FILE-- | |
8f852052 KW |
242 | use warnings; |
243 | no warnings 'void'; | |
ea065648 NC |
244 | use charnames ":full", ":alias" => "xyzzy"; |
245 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
246 | EXPECT | |
1015ff30 KW |
247 | OPTIONS regex fatal |
248 | Unknown charname 'e_ACUTE' at - line \d+, within string | |
ea065648 | 249 | ######## |
99bc9185 | 250 | # NAME alias with file OK but file has :short aliases |
463cf062 | 251 | --FILE-- ../../lib/unicore/xyzzy_alias.pl |
ea065648 NC |
252 | #!perl |
253 | ( e_ACUTE => "LATIN:e WITH ACUTE", | |
254 | a_ACUTE => "LATIN:a WITH ACUTE", | |
255 | ); | |
256 | --FILE-- | |
8f852052 KW |
257 | use warnings; |
258 | no warnings 'void'; | |
ea065648 NC |
259 | use charnames ":full", ":alias" => "xyzzy"; |
260 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
261 | EXPECT | |
1015ff30 KW |
262 | OPTIONS regex fatal |
263 | Unknown charname 'e_ACUTE' at - line \d+, within string | |
ea065648 | 264 | ######## |
99bc9185 | 265 | # NAME alias with :short and file OK |
463cf062 | 266 | --FILE-- ../../lib/unicore/xyzzy_alias.pl |
ea065648 NC |
267 | #!perl |
268 | ( e_ACUTE => "LATIN:e WITH ACUTE", | |
269 | a_ACUTE => "LATIN:a WITH ACUTE", | |
270 | ); | |
271 | --FILE-- | |
8f852052 KW |
272 | use warnings; |
273 | no warnings 'void'; | |
ea065648 NC |
274 | use charnames ":short", ":alias" => "xyzzy"; |
275 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
276 | EXPECT | |
277 | OPTIONS regex | |
278 | $ | |
279 | ######## | |
99bc9185 | 280 | # NAME alias with :short and file OK has :long aliases |
463cf062 | 281 | --FILE-- ../../lib/unicore/xyzzy_alias.pl |
ea065648 NC |
282 | #!perl |
283 | ( e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE", | |
284 | a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE", | |
285 | ); | |
286 | --FILE-- | |
8f852052 KW |
287 | use warnings; |
288 | no warnings 'void'; | |
ea065648 NC |
289 | use charnames ":short", ":alias" => "xyzzy"; |
290 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
291 | EXPECT | |
1015ff30 KW |
292 | OPTIONS regex fatal |
293 | Unknown charname 'e_ACUTE' at - line \d+, within string | |
ea065648 | 294 | ######## |
99bc9185 | 295 | # NAME alias with file implicit :full but file has :short aliases |
463cf062 | 296 | --FILE-- ../../lib/unicore/xyzzy_alias.pl |
ea065648 NC |
297 | #!perl |
298 | ( e_ACUTE => "LATIN:e WITH ACUTE", | |
299 | a_ACUTE => "LATIN:a WITH ACUTE", | |
300 | ); | |
301 | --FILE-- | |
8f852052 KW |
302 | use warnings; |
303 | no warnings 'void'; | |
ea065648 NC |
304 | use charnames ":alias" => ":xyzzy"; |
305 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
306 | EXPECT | |
1015ff30 KW |
307 | OPTIONS regex fatal |
308 | Unknown charname 'e_ACUTE' at - line \d+, within string | |
ea065648 | 309 | ######## |
99bc9185 | 310 | # NAME alias with file implicit :full and file has :long aliases |
463cf062 | 311 | --FILE-- ../../lib/unicore/xyzzy_alias.pl |
ea065648 NC |
312 | #!perl |
313 | ( e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE", | |
314 | a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE", | |
315 | ); | |
316 | --FILE-- | |
8f852052 KW |
317 | use warnings; |
318 | no warnings 'void'; | |
ea065648 NC |
319 | use charnames ":alias" => ":xyzzy"; |
320 | "Here: \N{e_ACUTE}\N{a_ACUTE}!\n"; | |
321 | EXPECT | |
322 | OPTIONS regex | |
323 | $ | |
03f95285 | 324 | ######## |
22dc4229 | 325 | # NAME charnames with no import still works for runtime functions |
03f95285 KW |
326 | use warnings; |
327 | no warnings 'void'; | |
328 | use charnames (); | |
329 | charnames::vianame('SPACE'); | |
27c3afbd | 330 | charnames::viacode(utf8::unicode_to_native(0x41)); |
03f95285 KW |
331 | EXPECT |
332 | OPTIONS regex | |
333 | $ | |
424313d4 KW |
334 | ######## |
335 | # NAME no extraneous warning [perl #11560] | |
336 | use warnings; | |
337 | use charnames (); | |
27c3afbd | 338 | print charnames::viacode(utf8::unicode_to_native(0x80)), "\n"; |
424313d4 KW |
339 | EXPECT |
340 | OPTIONS regex | |
341 | PADDING CHARACTER | |
225fb84f | 342 | ######## |
27c3afbd KW |
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. | |
225fb84f KW |
347 | use charnames ":full", ":alias" => { |
348 | "4e_ACUTE" => "LATIN SMALL LETTER E WITH ACUTE", | |
225fb84f KW |
349 | }; |
350 | EXPECT | |
351 | OPTIONS regex | |
352 | Invalid character in charnames alias definition; marked by <-- HERE in '4<-- HERE e_ACUTE' | |
27c3afbd KW |
353 | ######## |
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", | |
357 | }; | |
358 | EXPECT | |
359 | OPTIONS regex | |
225fb84f | 360 | Invalid character in charnames alias definition; marked by <-- HERE in 'e_A,<-- HERE CUTE' |
27c3afbd KW |
361 | ######## |
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", | |
369 | }; | |
370 | EXPECT | |
371 | OPTIONS regex | |
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' | |
dd2b1b72 | 373 | ######## |
bde9e88d KW |
374 | # RT#73022 |
375 | # NAME \N{...} interprets ... as octets rather than UTF-8 | |
dd2b1b72 BF |
376 | use utf8; |
377 | use open qw( :utf8 :std ); | |
bde9e88d KW |
378 | use charnames ":full", ":alias" => { "自転車に乗る人" => "BICYCLIST" }; |
379 | print "ok\n" if "\N{自転車に乗る人}" eq "\x{1F6B4}"; | |
dd2b1b72 BF |
380 | EXPECT |
381 | ok | |
bde9e88d KW |
382 | ######## |
383 | # NAME Misspelled \N{} UTF-8 names are errors | |
384 | use utf8; | |
385 | use open qw( :utf8 :std ); | |
386 | use charnames ":full", ":alias" => { "自転車に乗る人" => "BICYCLIST" }; | |
387 | print "ok\n" if "\N{転車に乗る人}" eq "\x{1F6B4}"; | |
388 | EXPECT | |
389 | OPTIONS regex | |
390 | Unknown charname '転車に乗る人' at - line \d+, within string | |
391 | ######## | |
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 | |
8ecb76b6 | 395 | # Note that output order is alphabetical by character name |
bde9e88d KW |
396 | use utf8; |
397 | use open qw( :utf8 :std ); | |
398 | use charnames ":full", ":alias" => { "自転車・に乗る人" => "BICYCLIST", | |
399 | "٤転車に乗る人" => "BICYCLIST", | |
2d8eb851 KW |
400 | "TOO MANY SPACES" => "NO ENTRY SIGN", |
401 | "TRAILING SPACE " => "FACE WITH NO GOOD GESTURE" | |
bde9e88d | 402 | }; |
2d8eb851 KW |
403 | print "ok\n" if "\N{TOO MANY SPACES}" eq "\x{1F6AB}"; |
404 | print "ok\n" if "\N{TRAILING SPACE }" eq "\x{1F645}"; | |
bde9e88d KW |
405 | print "ok\n" if "\N{自転車・に乗る人}" eq "\x{1F6B4}"; |
406 | print "ok\n" if "\N{٤転車に乗る人}" eq "\x{1F6B4}"; | |
407 | EXPECT | |
2d8eb851 KW |
408 | OPTIONS regex fatal |
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 ' | |
bde9e88d KW |
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+ | |
df758df2 | 413 | ######## |
245c9183 | 414 | # NAME Using NBSP in :alias names is deprecated |
df758df2 KW |
415 | use utf8; |
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}"; | |
df758df2 | 419 | EXPECT |
61463a3e KW |
420 | OPTIONS regex fatal |
421 | Invalid character in charnames alias definition; marked by <-- HERE in 'NBSP <-- HERE SEPARATED SPACE' at - line 3 |