This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
charnames: :alias alone implies :full
[perl5.git] / t / lib / charnames / alias
... / ...
CommitLineData
1Tests for use charnames with compilation errors and aliases.
2__END__
3# NAME illegal :pragma
4use warnings;
5use charnames ":scoobydoo";
6"Here: \N{e_ACUTE}!\n";
7EXPECT
8OPTIONS regex
9unsupported special ':scoobydoo' in charnames at
10########
11# NAME autoload doesn't get vianame
12print "Here: \N{DIGIT ONE}\n";
13charnames::vianame("DIGIT TWO");
14EXPECT
15OPTIONS regex
16Undefined subroutine &charnames::vianame called at - line \d+.
17Here: 1
18########
19# NAME autoload doesn't get viacode
20print "Here: \N{DIGIT THREE}\n";
21charnames::viacode(0x34);
22EXPECT
23OPTIONS regex
24Undefined subroutine &charnames::viacode called at - line \d+.
25Here: 3
26########
27# NAME autoload doesn't get string_vianame
28print "Here: \N{DIGIT FOUR}\n";
29charnames::string_vianame("DIGIT FIVE");
30EXPECT
31OPTIONS regex
32Undefined subroutine &charnames::string_vianame called at - line \d+.
33Here: 4
34########
35# NAME wrong type of alias (missing colon)
36no warnings;
37use charnames "alias";
38"Here: \N{e_ACUTE}!\n";
39EXPECT
40OPTIONS regex fatal
41Unknown charname 'e_ACUTE' at - line \d+, within string
42########
43# NAME alias without an argument
44use warnings;
45use charnames ":alias";
46"Here: \N{e_ACUTE}!\n";
47EXPECT
48OPTIONS regex
49:alias needs an argument in charnames at
50########
51# NAME reversed sequence
52use warnings;
53use charnames ":alias" => ":full";
54"Here: \N{e_ACUTE}!\n";
55EXPECT
56OPTIONS regex
57:alias cannot use existing pragma :full \(reversed order\?\) at
58########
59# NAME alias with hashref but with :short
60use warnings;
61no warnings 'void';
62use charnames ":short", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
63"Here: \N{e_ACUTE}!\n";
64EXPECT
65OPTIONS regex fatal
66Unknown charname 'e_ACUTE' at - line \d+, within string
67########
68# NAME alias with hashref to :full OK
69use warnings;
70no warnings 'void';
71use charnames ":full", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
72"Here: \N{e_ACUTE}!\n";
73EXPECT
74OPTIONS regex
75$
76########
77# NAME alias with hashref to :loose OK
78use warnings;
79no warnings 'void';
80use charnames ":loose", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
81"Here: \N{e_ACUTE}!\n";
82EXPECT
83OPTIONS regex
84$
85########
86# NAME alias with :loose requires :full type name
87use warnings;
88no warnings 'void';
89use charnames ":loose", ":alias" => { e_ACUTE => "latin SMALL LETTER E WITH ACUTE" };
90"Here: \N{e_ACUTE}!\n";
91EXPECT
92OPTIONS regex fatal
93Unknown charname 'e_ACUTE' at - line \d+, within string
94########
95# NAME alias with hashref to :short but using :full
96use warnings;
97no warnings 'void';
98use charnames ":full", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" };
99"Here: \N{e_ACUTE}!\n";
100EXPECT
101OPTIONS regex fatal
102Unknown charname 'e_ACUTE' at - line \d+, within string
103########
104# NAME alias with hashref to :short OK
105use warnings;
106no warnings 'void';
107use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" };
108"Here: \N{e_ACUTE}!\n";
109EXPECT
110OPTIONS regex
111$
112########
113# NAME alias with bad hashref
114use warnings;
115no warnings 'void';
116use charnames ":short", ":alias" => "e_ACUTE";
117"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
118EXPECT
119OPTIONS regex
120unicore/e_ACUTE_alias.pl cannot be used as alias file for charnames at
121########
122# NAME alias with arrayref
123use warnings;
124no warnings 'void';
125use charnames ":short", ":alias" => [ e_ACUTE => "LATIN:e WITH ACUTE" ];
126"Here: \N{e_ACUTE}!\n";
127EXPECT
128OPTIONS regex
129Only HASH reference supported as argument to :alias at
130########
131# NAME alias with bad hashref
132no warnings;
133use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE", "a_ACUTE" };
134"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
135EXPECT
136OPTIONS regex
137Unknown charname 'a_ACUTE' at
138########
139# NAME alias with hashref two aliases
140use warnings;
141no warnings 'void';
142use charnames ":short", ":alias" => {
143 e_ACUTE => "LATIN:e WITH ACUTE",
144 a_ACUTE => "",
145 };
146"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
147EXPECT
148OPTIONS regex fatal
149Unknown charname 'a_ACUTE' at - line \d+, within string
150########
151# NAME alias with hashref two aliases
152use warnings;
153no warnings 'void';
154use 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";
159EXPECT
160OPTIONS regex
161$
162########
163# NAME alias with hashref using mixed aliases
164use warnings;
165use 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";
170EXPECT
171OPTIONS regex fatal
172Unknown charname 'a_ACUTE' at - line \d+, within string
173########
174# NAME alias with hashref using mixed aliases
175use warnings;
176use 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";
181EXPECT
182OPTIONS regex fatal
183Unknown charname 'a_ACUTE' at - line \d+, within string
184########
185# NAME alias with hashref using mixed aliases
186use warnings;
187no warnings 'void';
188use 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";
193EXPECT
194OPTIONS regex fatal
195Unknown charname 'e_ACUTE' at - line \d+, within string
196########
197# NAME alias with nonexisting file
198use warnings;
199no warnings 'void';
200use charnames ":full", ":alias" => "non_existing_xyzzy";
201"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
202EXPECT
203OPTIONS regex
204unicore/non_existing_xyzzy_alias.pl cannot be used as alias file for charnames at
205########
206# NAME alias with bad file name
207use warnings;
208no warnings 'void';
209use charnames ":full", ":alias" => "xy 7-";
210"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
211EXPECT
212OPTIONS regex
213Charnames alias file names can only have identifier characters at
214########
215# NAME alias with non_absolute (existing) file name (which it should /not/ use)
216use warnings;
217no warnings 'void';
218use charnames ":full", ":alias" => "perl";
219"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
220EXPECT
221OPTIONS regex
222unicore/perl_alias.pl cannot be used as alias file for charnames at
223########
224# NAME alias with bad file
225--FILE-- ../../lib/unicore/xyzzy_alias.pl
226#!perl
2270;
228--FILE--
229use warnings;
230no warnings 'void';
231use charnames ":full", ":alias" => "xyzzy";
232"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
233EXPECT
234OPTIONS regex
235unicore/xyzzy_alias.pl did not return a \(valid\) list of alias pairs at
236########
237# NAME alias with file with empty list
238--FILE-- ../../lib/unicore/xyzzy_alias.pl
239#!perl
240();
241--FILE--
242use warnings;
243no warnings 'void';
244use charnames ":full", ":alias" => "xyzzy";
245"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
246EXPECT
247OPTIONS regex fatal
248Unknown charname 'e_ACUTE' at - line \d+, within string
249########
250# NAME alias with file OK but file has :short aliases
251--FILE-- ../../lib/unicore/xyzzy_alias.pl
252#!perl
253( e_ACUTE => "LATIN:e WITH ACUTE",
254 a_ACUTE => "LATIN:a WITH ACUTE",
255 );
256--FILE--
257use warnings;
258no warnings 'void';
259use charnames ":full", ":alias" => "xyzzy";
260"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
261EXPECT
262OPTIONS regex fatal
263Unknown charname 'e_ACUTE' at - line \d+, within string
264########
265# NAME alias with :short and file OK
266--FILE-- ../../lib/unicore/xyzzy_alias.pl
267#!perl
268( e_ACUTE => "LATIN:e WITH ACUTE",
269 a_ACUTE => "LATIN:a WITH ACUTE",
270 );
271--FILE--
272use warnings;
273no warnings 'void';
274use charnames ":short", ":alias" => "xyzzy";
275"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
276EXPECT
277OPTIONS regex
278$
279########
280# NAME alias with :short and file OK has :long aliases
281--FILE-- ../../lib/unicore/xyzzy_alias.pl
282#!perl
283( e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
284 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
285 );
286--FILE--
287use warnings;
288no warnings 'void';
289use charnames ":short", ":alias" => "xyzzy";
290"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
291EXPECT
292OPTIONS regex fatal
293Unknown charname 'e_ACUTE' at - line \d+, within string
294########
295# NAME alias with file implicit :full but file has :short aliases
296--FILE-- ../../lib/unicore/xyzzy_alias.pl
297#!perl
298( e_ACUTE => "LATIN:e WITH ACUTE",
299 a_ACUTE => "LATIN:a WITH ACUTE",
300 );
301--FILE--
302use warnings;
303no warnings 'void';
304use charnames ":alias" => ":xyzzy";
305"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
306EXPECT
307OPTIONS regex fatal
308Unknown charname 'e_ACUTE' at - line \d+, within string
309########
310# NAME alias with file implicit :full and file has :long aliases
311--FILE-- ../../lib/unicore/xyzzy_alias.pl
312#!perl
313( e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
314 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
315 );
316--FILE--
317use warnings;
318no warnings 'void';
319use charnames ":alias" => ":xyzzy";
320"Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
321EXPECT
322OPTIONS regex
323$
324########
325# NAME charnames with no import still works for runtime functions
326use warnings;
327no warnings 'void';
328use charnames ();
329charnames::vianame('SPACE');
330charnames::viacode(0x41);
331EXPECT
332OPTIONS regex
333$
334########
335# NAME no extraneous warning [perl #11560]
336use warnings;
337use charnames ();
338print charnames::viacode(0x80), "\n";
339EXPECT
340OPTIONS regex
341PADDING CHARACTER
342########
343# NAME various wrong characters in :alias are errors
344# Below, one of the EXPECT regexes matches both the UTF-8 and non-UTF-8 form.
345# This is because under some circumstances the message gets output as UTF-8.
346use charnames ":full", ":alias" => {
347 "4e_ACUTE" => "LATIN SMALL LETTER E WITH ACUTE",
348 "e_A,CUTE" => "LATIN SMALL LETTER E WITH ACUTE",
349 "e_ACUT\x{d7}E" => "LATIN SMALL LETTER E WITH ACUTE",
350 };
351EXPECT
352OPTIONS regex
353Invalid character in charnames alias definition; marked by <-- HERE in '4<-- HERE e_ACUTE'
354Invalid character in charnames alias definition; marked by <-- HERE in 'e_A,<-- HERE CUTE'
355Invalid character in charnames alias definition; marked by <-- HERE in 'e_ACUT(?:\x{d7}|\x{C3}\x{97})<-- HERE E'
356########
357# RT#73022
358# NAME \N{...} interprets ... as octets rather than UTF-8
359use utf8;
360use open qw( :utf8 :std );
361use charnames ":full", ":alias" => { "自転車に乗る人" => "BICYCLIST" };
362print "ok\n" if "\N{自転車に乗る人}" eq "\x{1F6B4}";
363EXPECT
364ok
365########
366# NAME Misspelled \N{} UTF-8 names are errors
367use utf8;
368use open qw( :utf8 :std );
369use charnames ":full", ":alias" => { "自転車に乗る人" => "BICYCLIST" };
370print "ok\n" if "\N{転車に乗る人}" eq "\x{1F6B4}";
371EXPECT
372OPTIONS regex
373Unknown charname '転車に乗る人' at - line \d+, within string
374########
375# NAME various wrong UTF-8 characters in :alias are errors
376# First has a punctuation, KATAKANA MIDDLE DOT, in it; second begins with a
377# digit: ARABIC-INDIC DIGIT FOUR
378use utf8;
379use open qw( :utf8 :std );
380use charnames ":full", ":alias" => { "自転車・に乗る人" => "BICYCLIST",
381 "٤転車に乗る人" => "BICYCLIST",
382 };
383print "ok\n" if "\N{自転車・に乗る人}" eq "\x{1F6B4}";
384print "ok\n" if "\N{٤転車に乗る人}" eq "\x{1F6B4}";
385EXPECT
386OPTIONS regex
387Invalid character in charnames alias definition; marked by <-- HERE in '٤<-- HERE 転車に乗る人'
388Invalid character in charnames alias definition; marked by <-- HERE in '自転車・<-- HERE に乗る人' at - line \d+