This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/op/caller.t: Comment magic number
[perl5.git] / t / lib / warnings / utf8
CommitLineData
f0df466a
JH
1
2 utf8.c AOK
3
4 [utf8_to_uv]
5 Malformed UTF-8 character
6 my $a = ord "\x80" ;
7
8 Malformed UTF-8 character
9 my $a = ord "\xf080" ;
10 <<<<<< this warning can't be easily triggered from perl anymore
11
12 [utf16_to_utf8]
13 Malformed UTF-16 surrogate
93f09d7b 14 <<<<<< Add a test when something actually calls utf16_to_utf8
f0df466a
JH
15
16__END__
17# utf8.c [utf8_to_uv] -W
18BEGIN {
19 if (ord('A') == 193) {
20 print "SKIPPED\n# ebcdic platforms do not generate Malformed UTF-8 warnings.";
21 exit 0;
22 }
23}
24use utf8 ;
25my $a = "snøstorm" ;
26{
27 no warnings 'utf8' ;
28 my $a = "snøstorm";
29 use warnings 'utf8' ;
30 my $a = "snøstorm";
31}
32EXPECT
41432148
JH
33Malformed UTF-8 character (unexpected non-continuation byte 0x73, immediately after start byte 0xf8) at - line 9.
34Malformed UTF-8 character (unexpected non-continuation byte 0x73, immediately after start byte 0xf8) at - line 14.
f0df466a 35########
507b9800 36use warnings 'utf8';
9ae3ac1a
KW
37my $d7ff = uc(chr(0xD7FF));
38my $d800 = uc(chr(0xD800));
39my $dfff = uc(chr(0xDFFF));
40my $e000 = uc(chr(0xE000));
41my $feff = uc(chr(0xFEFF));
42my $fffd = uc(chr(0xFFFD));
43my $fffe = uc(chr(0xFFFE));
44my $ffff = uc(chr(0xFFFF));
45my $hex4 = uc(chr(0x10000));
46my $hex5 = uc(chr(0x100000));
47my $maxm1 = uc(chr(0x10FFFE));
48my $max = uc(chr(0x10FFFF));
49my $nonUnicode = uc(chr(0x110000));
507b9800 50no warnings 'utf8';
9ae3ac1a
KW
51my $d7ff = uc(chr(0xD7FF));
52my $d800 = uc(chr(0xD800));
53my $dfff = uc(chr(0xDFFF));
54my $e000 = uc(chr(0xE000));
55my $feff = uc(chr(0xFEFF));
56my $fffd = uc(chr(0xFFFD));
57my $fffe = uc(chr(0xFFFE));
58my $ffff = uc(chr(0xFFFF));
59my $hex4 = uc(chr(0x10000));
60my $hex5 = uc(chr(0x100000));
61my $maxm1 = uc(chr(0x10FFFE));
62my $max = uc(chr(0x10FFFF));
63my $nonUnicode = uc(chr(0x110000));
507b9800 64EXPECT
9ae3ac1a
KW
65Operation "uc" returns its argument for UTF-16 surrogate U+D800 at - line 3.
66Operation "uc" returns its argument for UTF-16 surrogate U+DFFF at - line 4.
67Operation "uc" returns its argument for non-Unicode code point 0x110000 at - line 14.
507b9800 68########
62961d2e 69use warnings 'utf8';
9ae3ac1a
KW
70my $d7ff = lc pack("U", 0xD7FF);
71my $d800 = lc pack("U", 0xD800);
72my $dfff = lc pack("U", 0xDFFF);
73my $e000 = lc pack("U", 0xE000);
74my $feff = lc pack("U", 0xFEFF);
75my $fffd = lc pack("U", 0xFFFD);
76my $fffe = lc pack("U", 0xFFFE);
77my $ffff = lc pack("U", 0xFFFF);
78my $hex4 = lc pack("U", 0x10000);
79my $hex5 = lc pack("U", 0x100000);
80my $maxm1 = lc pack("U", 0x10FFFE);
81my $max = lc pack("U", 0x10FFFF);
82my $nonUnicode = lc(pack("U", 0x110000));
62961d2e 83no warnings 'utf8';
9ae3ac1a
KW
84my $d7ff = lc pack("U", 0xD7FF);
85my $d800 = lc pack("U", 0xD800);
86my $dfff = lc pack("U", 0xDFFF);
87my $e000 = lc pack("U", 0xE000);
88my $feff = lc pack("U", 0xFEFF);
89my $fffd = lc pack("U", 0xFFFD);
90my $fffe = lc pack("U", 0xFFFE);
91my $ffff = lc pack("U", 0xFFFF);
92my $hex4 = lc pack("U", 0x10000);
93my $hex5 = lc pack("U", 0x100000);
94my $maxm1 = lc pack("U", 0x10FFFE);
95my $max = lc pack("U", 0x10FFFF);
96my $nonUnicode = lc(pack("U", 0x110000));
62961d2e 97EXPECT
9ae3ac1a
KW
98Operation "lc" returns its argument for UTF-16 surrogate U+D800 at - line 3.
99Operation "lc" returns its argument for UTF-16 surrogate U+DFFF at - line 4.
100Operation "lc" returns its argument for non-Unicode code point 0x110000 at - line 14.
62961d2e
JH
101########
102use warnings 'utf8';
9ae3ac1a
KW
103my $d7ff = ucfirst "\x{D7FF}";
104my $d800 = ucfirst "\x{D800}";
105my $dfff = ucfirst "\x{DFFF}";
106my $e000 = ucfirst "\x{E000}";
107my $feff = ucfirst "\x{FEFF}";
108my $fffd = ucfirst "\x{FFFD}";
109my $fffe = ucfirst "\x{FFFE}";
110my $ffff = ucfirst "\x{FFFF}";
111my $hex4 = ucfirst "\x{10000}";
112my $hex5 = ucfirst "\x{100000}";
113my $maxm1 = ucfirst "\x{10FFFE}";
114my $max = ucfirst "\x{10FFFF}";
115my $nonUnicode = ucfirst "\x{110000}";
62961d2e 116no warnings 'utf8';
9ae3ac1a
KW
117my $d7ff = ucfirst "\x{D7FF}";
118my $d800 = ucfirst "\x{D800}";
119my $dfff = ucfirst "\x{DFFF}";
120my $e000 = ucfirst "\x{E000}";
121my $feff = ucfirst "\x{FEFF}";
122my $fffd = ucfirst "\x{FFFD}";
123my $fffe = ucfirst "\x{FFFE}";
124my $ffff = ucfirst "\x{FFFF}";
125my $hex4 = ucfirst "\x{10000}";
126my $hex5 = ucfirst "\x{100000}";
127my $maxm1 = ucfirst "\x{10FFFE}";
128my $max = ucfirst "\x{10FFFF}";
129my $nonUnicode = ucfirst "\x{110000}";
130EXPECT
131Operation "ucfirst" returns its argument for UTF-16 surrogate U+D800 at - line 3.
132Operation "ucfirst" returns its argument for UTF-16 surrogate U+DFFF at - line 4.
133Operation "ucfirst" returns its argument for non-Unicode code point 0x110000 at - line 14.
134########
135use warnings 'utf8';
136chr(0xD7FF) =~ /\p{Any}/;
137chr(0xD800) =~ /\p{Any}/;
138chr(0xDFFF) =~ /\p{Any}/;
139chr(0xE000) =~ /\p{Any}/;
140chr(0xFEFF) =~ /\p{Any}/;
141chr(0xFFFD) =~ /\p{Any}/;
142chr(0xFFFE) =~ /\p{Any}/;
143chr(0xFFFF) =~ /\p{Any}/;
144chr(0x10000) =~ /\p{Any}/;
145chr(0x100000) =~ /\p{Any}/;
146chr(0x10FFFE) =~ /\p{Any}/;
147chr(0x10FFFF) =~ /\p{Any}/;
148chr(0x110000) =~ /\p{Any}/;
149no warnings 'utf8';
150chr(0xD7FF) =~ /\p{Any}/;
151chr(0xD800) =~ /\p{Any}/;
152chr(0xDFFF) =~ /\p{Any}/;
153chr(0xE000) =~ /\p{Any}/;
154chr(0xFEFF) =~ /\p{Any}/;
155chr(0xFFFD) =~ /\p{Any}/;
156chr(0xFFFE) =~ /\p{Any}/;
157chr(0xFFFF) =~ /\p{Any}/;
158chr(0x10000) =~ /\p{Any}/;
159chr(0x100000) =~ /\p{Any}/;
160chr(0x10FFFE) =~ /\p{Any}/;
161chr(0x10FFFF) =~ /\p{Any}/;
162chr(0x110000) =~ /\p{Any}/;
163EXPECT
164Code point 0x110000 is not Unicode, no properties match it; all inverse properties do at - line 14.
165########
166require "../test.pl";
167use warnings 'utf8';
168my $file = tempfile();
169open(my $fh, "+>:utf8", $file);
170print $fh "\x{D7FF}", "\n";
171print $fh "\x{D800}", "\n";
172print $fh "\x{DFFF}", "\n";
173print $fh "\x{E000}", "\n";
174print $fh "\x{FDCF}", "\n";
175print $fh "\x{FDD0}", "\n";
176print $fh "\x{FDEF}", "\n";
177print $fh "\x{FDF0}", "\n";
178print $fh "\x{FEFF}", "\n";
179print $fh "\x{FFFD}", "\n";
180print $fh "\x{FFFE}", "\n";
181print $fh "\x{FFFF}", "\n";
182print $fh "\x{10000}", "\n";
183print $fh "\x{1FFFE}", "\n";
184print $fh "\x{1FFFF}", "\n";
185print $fh "\x{2FFFE}", "\n";
186print $fh "\x{2FFFF}", "\n";
187print $fh "\x{3FFFE}", "\n";
188print $fh "\x{3FFFF}", "\n";
189print $fh "\x{4FFFE}", "\n";
190print $fh "\x{4FFFF}", "\n";
191print $fh "\x{5FFFE}", "\n";
192print $fh "\x{5FFFF}", "\n";
193print $fh "\x{6FFFE}", "\n";
194print $fh "\x{6FFFF}", "\n";
195print $fh "\x{7FFFE}", "\n";
196print $fh "\x{7FFFF}", "\n";
197print $fh "\x{8FFFE}", "\n";
198print $fh "\x{8FFFF}", "\n";
199print $fh "\x{9FFFE}", "\n";
200print $fh "\x{9FFFF}", "\n";
201print $fh "\x{AFFFE}", "\n";
202print $fh "\x{AFFFF}", "\n";
203print $fh "\x{BFFFE}", "\n";
204print $fh "\x{BFFFF}", "\n";
205print $fh "\x{CFFFE}", "\n";
206print $fh "\x{CFFFF}", "\n";
207print $fh "\x{DFFFE}", "\n";
208print $fh "\x{DFFFF}", "\n";
209print $fh "\x{EFFFE}", "\n";
210print $fh "\x{EFFFF}", "\n";
211print $fh "\x{FFFFE}", "\n";
212print $fh "\x{FFFFF}", "\n";
213print $fh "\x{100000}", "\n";
214print $fh "\x{10FFFE}", "\n";
215print $fh "\x{10FFFF}", "\n";
216print $fh "\x{110000}", "\n";
217close $fh;
218EXPECT
219Unicode surrogate U+D800 is illegal in UTF-8 at - line 6.
220Unicode surrogate U+DFFF is illegal in UTF-8 at - line 7.
221Unicode non-character U+FDD0 is illegal for open interchange at - line 10.
222Unicode non-character U+FDEF is illegal for open interchange at - line 11.
223Unicode non-character U+FFFE is illegal for open interchange at - line 15.
224Unicode non-character U+FFFF is illegal for open interchange at - line 16.
225Unicode non-character U+1FFFE is illegal for open interchange at - line 18.
226Unicode non-character U+1FFFF is illegal for open interchange at - line 19.
227Unicode non-character U+2FFFE is illegal for open interchange at - line 20.
228Unicode non-character U+2FFFF is illegal for open interchange at - line 21.
229Unicode non-character U+3FFFE is illegal for open interchange at - line 22.
230Unicode non-character U+3FFFF is illegal for open interchange at - line 23.
231Unicode non-character U+4FFFE is illegal for open interchange at - line 24.
232Unicode non-character U+4FFFF is illegal for open interchange at - line 25.
233Unicode non-character U+5FFFE is illegal for open interchange at - line 26.
234Unicode non-character U+5FFFF is illegal for open interchange at - line 27.
235Unicode non-character U+6FFFE is illegal for open interchange at - line 28.
236Unicode non-character U+6FFFF is illegal for open interchange at - line 29.
237Unicode non-character U+7FFFE is illegal for open interchange at - line 30.
238Unicode non-character U+7FFFF is illegal for open interchange at - line 31.
239Unicode non-character U+8FFFE is illegal for open interchange at - line 32.
240Unicode non-character U+8FFFF is illegal for open interchange at - line 33.
241Unicode non-character U+9FFFE is illegal for open interchange at - line 34.
242Unicode non-character U+9FFFF is illegal for open interchange at - line 35.
243Unicode non-character U+AFFFE is illegal for open interchange at - line 36.
244Unicode non-character U+AFFFF is illegal for open interchange at - line 37.
245Unicode non-character U+BFFFE is illegal for open interchange at - line 38.
246Unicode non-character U+BFFFF is illegal for open interchange at - line 39.
247Unicode non-character U+CFFFE is illegal for open interchange at - line 40.
248Unicode non-character U+CFFFF is illegal for open interchange at - line 41.
249Unicode non-character U+DFFFE is illegal for open interchange at - line 42.
250Unicode non-character U+DFFFF is illegal for open interchange at - line 43.
251Unicode non-character U+EFFFE is illegal for open interchange at - line 44.
252Unicode non-character U+EFFFF is illegal for open interchange at - line 45.
253Unicode non-character U+FFFFE is illegal for open interchange at - line 46.
254Unicode non-character U+FFFFF is illegal for open interchange at - line 47.
255Unicode non-character U+10FFFE is illegal for open interchange at - line 49.
256Unicode non-character U+10FFFF is illegal for open interchange at - line 50.
257Code point 0x110000 is not Unicode, may not be portable at - line 51.
258########
259require "../test.pl";
260no warnings 'utf8';
261my $file = tempfile();
262open(my $fh, "+>:utf8", $file);
263print $fh "\x{D7FF}", "\n";
264print $fh "\x{D800}", "\n";
265print $fh "\x{DFFF}", "\n";
266print $fh "\x{E000}", "\n";
267print $fh "\x{FDCF}", "\n";
268print $fh "\x{FDD0}", "\n";
269print $fh "\x{FDEF}", "\n";
270print $fh "\x{FDF0}", "\n";
271print $fh "\x{FEFF}", "\n";
272print $fh "\x{FFFD}", "\n";
273print $fh "\x{FFFE}", "\n";
274print $fh "\x{FFFF}", "\n";
275print $fh "\x{10000}", "\n";
276print $fh "\x{1FFFE}", "\n";
277print $fh "\x{1FFFF}", "\n";
278print $fh "\x{2FFFE}", "\n";
279print $fh "\x{2FFFF}", "\n";
280print $fh "\x{3FFFE}", "\n";
281print $fh "\x{3FFFF}", "\n";
282print $fh "\x{4FFFE}", "\n";
283print $fh "\x{4FFFF}", "\n";
284print $fh "\x{5FFFE}", "\n";
285print $fh "\x{5FFFF}", "\n";
286print $fh "\x{6FFFE}", "\n";
287print $fh "\x{6FFFF}", "\n";
288print $fh "\x{7FFFE}", "\n";
289print $fh "\x{7FFFF}", "\n";
290print $fh "\x{8FFFE}", "\n";
291print $fh "\x{8FFFF}", "\n";
292print $fh "\x{9FFFE}", "\n";
293print $fh "\x{9FFFF}", "\n";
294print $fh "\x{AFFFE}", "\n";
295print $fh "\x{AFFFF}", "\n";
296print $fh "\x{BFFFE}", "\n";
297print $fh "\x{BFFFF}", "\n";
298print $fh "\x{CFFFE}", "\n";
299print $fh "\x{CFFFF}", "\n";
300print $fh "\x{DFFFE}", "\n";
301print $fh "\x{DFFFF}", "\n";
302print $fh "\x{EFFFE}", "\n";
303print $fh "\x{EFFFF}", "\n";
304print $fh "\x{FFFFE}", "\n";
305print $fh "\x{FFFFF}", "\n";
306print $fh "\x{100000}", "\n";
307print $fh "\x{10FFFE}", "\n";
308print $fh "\x{10FFFF}", "\n";
309print $fh "\x{110000}", "\n";
310close $fh;
62961d2e 311EXPECT