This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
eb09d914300c22087c265ebf3bfc357e1c47ddef
[perl5.git] / t / lib / charnames / alias
1 Tests for use charnames with compilation errors and aliases.
2 __END__
3 # unsupported pragma
4 use warnings;
5 use charnames ":scoobydoo";
6 "Here: \N{e_ACUTE}!\n";
7 EXPECT
8 OPTIONS regex
9 unsupported special ':scoobydoo' in charnames at
10 ########
11 # NAME autoload doesn't get vianame
12 print "Here: \N{DIGIT ONE}\n";
13 charnames::vianame("DIGIT TWO");
14 EXPECT
15 Undefined subroutine &charnames::vianame called at - line 2.
16 Here: 1
17 ########
18 # NAME autoload doesn't get viacode
19 print "Here: \N{DIGIT THREE}\n";
20 charnames::viacode(0x34);
21 EXPECT
22 OPTIONS regex
23 Undefined subroutine &charnames::viacode called at - line 2.
24 Here: 3
25 ########
26 # NAME autoload doesn't get string_vianame
27 print "Here: \N{DIGIT FOUR}\n";
28 charnames::string_vianame("DIGIT FIVE");
29 EXPECT
30 OPTIONS regex
31 Undefined subroutine &charnames::string_vianame called at - line 2.
32 Here: 4
33 ########
34 # wrong type of alias (missing colon)
35 no warnings;
36 use charnames "alias";
37 "Here: \N{e_ACUTE}!\n";
38 EXPECT
39 OPTIONS regex
40 Unknown charname 'e_ACUTE' at
41 ########
42 # alias without an argument
43 use warnings;
44 use charnames ":alias";
45 "Here: \N{e_ACUTE}!\n";
46 EXPECT
47 OPTIONS regex
48 :alias needs an argument in charnames at
49 ########
50 # reversed sequence
51 use warnings;
52 use charnames ":alias" => ":full";
53 "Here: \N{e_ACUTE}!\n";
54 EXPECT
55 OPTIONS regex
56 :alias cannot use existing pragma :full \(reversed order\?\) at
57 ########
58 # alias with hashref but no :full
59 use warnings;
60 use charnames ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
61 "Here: \N{e_ACUTE}!\n";
62 EXPECT
63 OPTIONS regex
64 Unknown charname 'LATIN SMALL LETTER E WITH ACUTE' at
65 ########
66 # alias with hashref but with :short
67 use warnings;
68 no warnings 'void';
69 use charnames ":short", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
70 "Here: \N{e_ACUTE}!\n";
71 EXPECT
72 OPTIONS regex
73 Unknown charname 'LATIN SMALL LETTER E WITH ACUTE' at
74 ########
75 # alias with hashref to :full OK
76 use warnings;
77 no warnings 'void';
78 use charnames ":full", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
79 "Here: \N{e_ACUTE}!\n";
80 EXPECT
81 OPTIONS regex
82 $
83 ########
84 # alias with hashref to :loose OK
85 use warnings;
86 no warnings 'void';
87 use charnames ":loose", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
88 "Here: \N{e_ACUTE}!\n";
89 EXPECT
90 OPTIONS regex
91 $
92 ########
93 # alias with :loose requires :full type name
94 use warnings;
95 no warnings 'void';
96 use charnames ":loose", ":alias" => { e_ACUTE => "latin SMALL LETTER E WITH ACUTE" };
97 "Here: \N{e_ACUTE}!\n";
98 EXPECT
99 OPTIONS regex
100 Unknown charname 'latin SMALL LETTER E WITH ACUTE' at
101 ########
102 # alias with hashref to :short but using :full
103 use warnings;
104 no warnings 'void';
105 use charnames ":full", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" };
106 "Here: \N{e_ACUTE}!\n";
107 EXPECT
108 OPTIONS regex
109 Unknown charname 'LATIN:e WITH ACUTE' at
110 ########
111 # alias with hashref to :short OK
112 use warnings;
113 no warnings 'void';
114 use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" };
115 "Here: \N{e_ACUTE}!\n";
116 EXPECT
117 OPTIONS regex
118 $
119 ########
120 # alias with bad hashref
121 use warnings;
122 no warnings 'void';
123 use charnames ":short", ":alias" => "e_ACUTE";
124 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
125 EXPECT
126 OPTIONS regex
127 unicore/e_ACUTE_alias.pl cannot be used as alias file for charnames at
128 ########
129 # alias with arrayref
130 use warnings;
131 no warnings 'void';
132 use charnames ":short", ":alias" => [ e_ACUTE => "LATIN:e WITH ACUTE" ];
133 "Here: \N{e_ACUTE}!\n";
134 EXPECT
135 OPTIONS regex
136 Only HASH reference supported as argument to :alias at
137 ########
138 # alias with bad hashref
139 no warnings;
140 use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE", "a_ACUTE" };
141 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
142 EXPECT
143 OPTIONS regex
144 Unknown charname 'a_ACUTE' at
145 ########
146 # alias with hashref two aliases
147 use warnings;
148 no warnings 'void';
149 use charnames ":short", ":alias" => {
150     e_ACUTE => "LATIN:e WITH ACUTE",
151     a_ACUTE => "",
152     };
153 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
154 EXPECT
155 OPTIONS regex
156 Unknown charname '' at
157 ########
158 # alias with hashref two aliases
159 use warnings;
160 no warnings 'void';
161 use charnames ":short", ":alias" => {
162     e_ACUTE => "LATIN:e WITH ACUTE",
163     a_ACUTE => "LATIN:a WITH ACUTE",
164     };
165 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
166 EXPECT
167 OPTIONS regex
168 $
169 ########
170 # alias with hashref using mixed aliases
171 use warnings;
172 use charnames ":short", ":alias" => {
173     e_ACUTE => "LATIN:e WITH ACUTE",
174     a_ACUTE => "LATIN SMALL LETTER A WITH ACUT",
175     };
176 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
177 EXPECT
178 OPTIONS regex
179 Unknown charname 'LATIN SMALL LETTER A WITH ACUT' at
180 ########
181 # alias with hashref using mixed aliases
182 use warnings;
183 use charnames ":short", ":alias" => {
184     e_ACUTE => "LATIN:e WITH ACUTE",
185     a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
186     };
187 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
188 EXPECT
189 OPTIONS regex
190 Unknown charname 'LATIN SMALL LETTER A WITH ACUTE' at
191 ########
192 # alias with hashref using mixed aliases
193 use warnings;
194 no warnings 'void';
195 use charnames ":full", ":alias" => {
196     e_ACUTE => "LATIN:e WITH ACUTE",
197     a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
198     };
199 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
200 EXPECT
201 OPTIONS regex
202 Unknown charname 'LATIN:e WITH ACUTE' at
203 ########
204 # alias with nonexisting file
205 use warnings;
206 no warnings 'void';
207 use charnames ":full", ":alias" => "xyzzy";
208 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
209 EXPECT
210 OPTIONS regex
211 unicore/xyzzy_alias.pl cannot be used as alias file for charnames at
212 ########
213 # alias with bad file name
214 use warnings;
215 no warnings 'void';
216 use charnames ":full", ":alias" => "xy 7-";
217 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
218 EXPECT
219 OPTIONS regex
220 Charnames alias files can only have identifier characters at
221 ########
222 # alias with non_absolute (existing) file name (which it should /not/ use)
223 use warnings;
224 no warnings 'void';
225 use charnames ":full", ":alias" => "perl";
226 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
227 EXPECT
228 OPTIONS regex
229 unicore/perl_alias.pl cannot be used as alias file for charnames at
230 ########
231 # alias with bad file
232 --FILE-- ../../lib/unicore/xyzzy_alias.pl
233 #!perl
234 0;
235 --FILE--
236 use warnings;
237 no warnings 'void';
238 use charnames ":full", ":alias" => "xyzzy";
239 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
240 EXPECT
241 OPTIONS regex
242 unicore/xyzzy_alias.pl did not return a \(valid\) list of alias pairs at
243 ########
244 # alias with file with empty list
245 --FILE-- ../../lib/unicore/xyzzy_alias.pl
246 #!perl
247 ();
248 --FILE--
249 use warnings;
250 no warnings 'void';
251 use charnames ":full", ":alias" => "xyzzy";
252 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
253 EXPECT
254 OPTIONS regex
255 Unknown charname 'e_ACUTE' at
256 ########
257 # alias with file OK but file has :short aliases
258 --FILE-- ../../lib/unicore/xyzzy_alias.pl
259 #!perl
260 (   e_ACUTE => "LATIN:e WITH ACUTE",
261     a_ACUTE => "LATIN:a WITH ACUTE",
262     );
263 --FILE--
264 use warnings;
265 no warnings 'void';
266 use charnames ":full", ":alias" => "xyzzy";
267 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
268 EXPECT
269 OPTIONS regex
270 Unknown charname 'LATIN:e WITH ACUTE' at
271 ########
272 # alias with :short and file OK
273 --FILE-- ../../lib/unicore/xyzzy_alias.pl
274 #!perl
275 (   e_ACUTE => "LATIN:e WITH ACUTE",
276     a_ACUTE => "LATIN:a WITH ACUTE",
277     );
278 --FILE--
279 use warnings;
280 no warnings 'void';
281 use charnames ":short", ":alias" => "xyzzy";
282 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
283 EXPECT
284 OPTIONS regex
285 $
286 ########
287 # alias with :short and file OK has :long aliases
288 --FILE-- ../../lib/unicore/xyzzy_alias.pl
289 #!perl
290 (   e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
291     a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
292     );
293 --FILE--
294 use warnings;
295 no warnings 'void';
296 use charnames ":short", ":alias" => "xyzzy";
297 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
298 EXPECT
299 OPTIONS regex
300 Unknown charname 'LATIN SMALL LETTER E WITH ACUTE' at
301 ########
302 # alias with file implicit :full but file has :short aliases
303 --FILE-- ../../lib/unicore/xyzzy_alias.pl
304 #!perl
305 (   e_ACUTE => "LATIN:e WITH ACUTE",
306     a_ACUTE => "LATIN:a WITH ACUTE",
307     );
308 --FILE--
309 use warnings;
310 no warnings 'void';
311 use charnames ":alias" => ":xyzzy";
312 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
313 EXPECT
314 OPTIONS regex
315 Unknown charname 'LATIN:e WITH ACUTE' at
316 ########
317 # alias with file implicit :full and file has :long aliases
318 --FILE-- ../../lib/unicore/xyzzy_alias.pl
319 #!perl
320 (   e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
321     a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
322     );
323 --FILE--
324 use warnings;
325 no warnings 'void';
326 use charnames ":alias" => ":xyzzy";
327 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
328 EXPECT
329 OPTIONS regex
330 $
331 ########
332 # charnames with no import still works for runtime functions
333 use warnings;
334 no warnings 'void';
335 use charnames ();
336 charnames::vianame('SPACE');
337 charnames::viacode(0x41);
338 EXPECT
339 OPTIONS regex
340 $