This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH: [perl #126310] single quote UTF-8 malformation detection
[perl5.git] / t / lib / warnings / utf8
index 05e7300..3431b86 100644 (file)
@@ -15,6 +15,7 @@
 
 __END__
 # utf8.c [utf8_to_uvchr_buf] -W
+# NAME Malformed under 'use utf8' in double-quoted string
 BEGIN {
     if (ord('A') == 193) {
         print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
@@ -22,16 +23,25 @@ BEGIN {
     }
 }
 use utf8 ;
+no warnings;    # Malformed is a fatal error, so gets output anyway.
 my $a = "snøstorm" ;
-{
-    no warnings 'utf8' ;
-    my $a = "snøstorm";
-    use warnings 'utf8' ;
-    my $a = "snøstorm";
+EXPECT
+Malformed UTF-8 character: \xf8\x73\x74\x6f\x72 (unexpected non-continuation byte 0x73, immediately after start byte 0xf8; need 5 bytes, got 1) at - line 10.
+Malformed UTF-8 character (fatal) at - line 10.
+########
+# NAME Malformed under 'use utf8' in single-quoted string
+BEGIN {
+    if (ord('A') == 193) {
+        print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
+        exit 0;
+    }
 }
+use utf8 ;
+no warnings;    # Malformed is a fatal error, so gets output anyway.
+my $a = 'snøstorm' ;
 EXPECT
-Malformed UTF-8 character (unexpected non-continuation byte 0x73, immediately after start byte 0xf8) at - line 9.
-Malformed UTF-8 character (unexpected non-continuation byte 0x73, immediately after start byte 0xf8) at - line 14.
+Malformed UTF-8 character: \xf8\x73\x74\x6f\x72 (unexpected non-continuation byte 0x73, immediately after start byte 0xf8; need 5 bytes, got 1) at - line 9.
+Malformed UTF-8 character (fatal) at - line 9.
 ########
 use warnings 'utf8';
 my $d7ff  = uc(chr(0xD7FF));
@@ -354,92 +364,149 @@ my $file = tempfile();
 open(my $fh, "+>:utf8", $file);
 print $fh "\x{D7FF}", "\n";
 print $fh "\x{D800}", "\n";
+print $fh "\x{D900}", "\n";
+print $fh "\x{DA00}", "\n";
+print $fh "\x{DB00}", "\n";
+print $fh "\x{DC00}", "\n";
+print $fh "\x{DD00}", "\n";
+print $fh "\x{DE00}", "\n";
+print $fh "\x{DF00}", "\n";
 print $fh "\x{DFFF}", "\n";
 print $fh "\x{E000}", "\n";
 print $fh "\x{FDCF}", "\n";
 print $fh "\x{FDD0}", "\n";
+print $fh "\x{FDD1}", "\n";
 print $fh "\x{FDEF}", "\n";
 print $fh "\x{FDF0}", "\n";
+print $fh "\x{FDFE}", "\n";
+print $fh "\x{FDFF}", "\n";
+print $fh "\x{FE00}", "\n";
 print $fh "\x{FEFF}", "\n";
 print $fh "\x{FFFD}", "\n";
 print $fh "\x{FFFE}", "\n";
 print $fh "\x{FFFF}", "\n";
 print $fh "\x{10000}", "\n";
+print $fh "\x{1FFFD}", "\n";
 print $fh "\x{1FFFE}", "\n";
 print $fh "\x{1FFFF}", "\n";
+print $fh "\x{20000}", "\n";
+print $fh "\x{2FFFD}", "\n";
 print $fh "\x{2FFFE}", "\n";
 print $fh "\x{2FFFF}", "\n";
+print $fh "\x{30000}", "\n";
+print $fh "\x{3FFFD}", "\n";
 print $fh "\x{3FFFE}", "\n";
 print $fh "\x{3FFFF}", "\n";
+print $fh "\x{40000}", "\n";
+print $fh "\x{4FFFD}", "\n";
 print $fh "\x{4FFFE}", "\n";
 print $fh "\x{4FFFF}", "\n";
+print $fh "\x{50000}", "\n";
+print $fh "\x{5FFFD}", "\n";
 print $fh "\x{5FFFE}", "\n";
 print $fh "\x{5FFFF}", "\n";
+print $fh "\x{60000}", "\n";
+print $fh "\x{6FFFD}", "\n";
 print $fh "\x{6FFFE}", "\n";
 print $fh "\x{6FFFF}", "\n";
+print $fh "\x{70000}", "\n";
+print $fh "\x{7FFFD}", "\n";
 print $fh "\x{7FFFE}", "\n";
 print $fh "\x{7FFFF}", "\n";
+print $fh "\x{80000}", "\n";
+print $fh "\x{8FFFD}", "\n";
 print $fh "\x{8FFFE}", "\n";
 print $fh "\x{8FFFF}", "\n";
+print $fh "\x{90000}", "\n";
+print $fh "\x{9FFFD}", "\n";
 print $fh "\x{9FFFE}", "\n";
 print $fh "\x{9FFFF}", "\n";
+print $fh "\x{A0000}", "\n";
+print $fh "\x{AFFFD}", "\n";
 print $fh "\x{AFFFE}", "\n";
 print $fh "\x{AFFFF}", "\n";
+print $fh "\x{B0000}", "\n";
+print $fh "\x{BFFFD}", "\n";
 print $fh "\x{BFFFE}", "\n";
 print $fh "\x{BFFFF}", "\n";
+print $fh "\x{C0000}", "\n";
+print $fh "\x{CFFFD}", "\n";
 print $fh "\x{CFFFE}", "\n";
 print $fh "\x{CFFFF}", "\n";
+print $fh "\x{D0000}", "\n";
+print $fh "\x{DFFFD}", "\n";
 print $fh "\x{DFFFE}", "\n";
 print $fh "\x{DFFFF}", "\n";
+print $fh "\x{E0000}", "\n";
+print $fh "\x{EFFFD}", "\n";
 print $fh "\x{EFFFE}", "\n";
 print $fh "\x{EFFFF}", "\n";
+print $fh "\x{F0000}", "\n";
+print $fh "\x{FFFFD}", "\n";
 print $fh "\x{FFFFE}", "\n";
 print $fh "\x{FFFFF}", "\n";
 print $fh "\x{100000}", "\n";
+print $fh "\x{10FFFD}", "\n";
 print $fh "\x{10FFFE}", "\n";
 print $fh "\x{10FFFF}", "\n";
 print $fh "\x{110000}", "\n";
+print $fh "\x{11FFFD}", "\n";
+print $fh "\x{11FFFE}", "\n";
+print $fh "\x{11FFFF}", "\n";
+print $fh "\x{120000}", "\n";
 close $fh;
 EXPECT
 Unicode surrogate U+D800 is illegal in UTF-8 at - line 6.
-Unicode surrogate U+DFFF is illegal in UTF-8 at - line 7.
-Unicode non-character U+FDD0 is not recommended for open interchange in print at - line 10.
-Unicode non-character U+FDEF is not recommended for open interchange in print at - line 11.
-Unicode non-character U+FFFE is not recommended for open interchange in print at - line 15.
-Unicode non-character U+FFFF is not recommended for open interchange in print at - line 16.
-Unicode non-character U+1FFFE is not recommended for open interchange in print at - line 18.
-Unicode non-character U+1FFFF is not recommended for open interchange in print at - line 19.
-Unicode non-character U+2FFFE is not recommended for open interchange in print at - line 20.
-Unicode non-character U+2FFFF is not recommended for open interchange in print at - line 21.
-Unicode non-character U+3FFFE is not recommended for open interchange in print at - line 22.
-Unicode non-character U+3FFFF is not recommended for open interchange in print at - line 23.
-Unicode non-character U+4FFFE is not recommended for open interchange in print at - line 24.
-Unicode non-character U+4FFFF is not recommended for open interchange in print at - line 25.
-Unicode non-character U+5FFFE is not recommended for open interchange in print at - line 26.
-Unicode non-character U+5FFFF is not recommended for open interchange in print at - line 27.
-Unicode non-character U+6FFFE is not recommended for open interchange in print at - line 28.
-Unicode non-character U+6FFFF is not recommended for open interchange in print at - line 29.
-Unicode non-character U+7FFFE is not recommended for open interchange in print at - line 30.
-Unicode non-character U+7FFFF is not recommended for open interchange in print at - line 31.
-Unicode non-character U+8FFFE is not recommended for open interchange in print at - line 32.
-Unicode non-character U+8FFFF is not recommended for open interchange in print at - line 33.
-Unicode non-character U+9FFFE is not recommended for open interchange in print at - line 34.
-Unicode non-character U+9FFFF is not recommended for open interchange in print at - line 35.
-Unicode non-character U+AFFFE is not recommended for open interchange in print at - line 36.
-Unicode non-character U+AFFFF is not recommended for open interchange in print at - line 37.
-Unicode non-character U+BFFFE is not recommended for open interchange in print at - line 38.
-Unicode non-character U+BFFFF is not recommended for open interchange in print at - line 39.
-Unicode non-character U+CFFFE is not recommended for open interchange in print at - line 40.
-Unicode non-character U+CFFFF is not recommended for open interchange in print at - line 41.
-Unicode non-character U+DFFFE is not recommended for open interchange in print at - line 42.
-Unicode non-character U+DFFFF is not recommended for open interchange in print at - line 43.
-Unicode non-character U+EFFFE is not recommended for open interchange in print at - line 44.
-Unicode non-character U+EFFFF is not recommended for open interchange in print at - line 45.
-Unicode non-character U+FFFFE is not recommended for open interchange in print at - line 46.
-Unicode non-character U+FFFFF is not recommended for open interchange in print at - line 47.
-Unicode non-character U+10FFFE is not recommended for open interchange in print at - line 49.
-Unicode non-character U+10FFFF is not recommended for open interchange in print at - line 50.
-Code point 0x110000 is not Unicode, may not be portable in print at - line 51.
+Unicode surrogate U+D900 is illegal in UTF-8 at - line 7.
+Unicode surrogate U+DA00 is illegal in UTF-8 at - line 8.
+Unicode surrogate U+DB00 is illegal in UTF-8 at - line 9.
+Unicode surrogate U+DC00 is illegal in UTF-8 at - line 10.
+Unicode surrogate U+DD00 is illegal in UTF-8 at - line 11.
+Unicode surrogate U+DE00 is illegal in UTF-8 at - line 12.
+Unicode surrogate U+DF00 is illegal in UTF-8 at - line 13.
+Unicode surrogate U+DFFF is illegal in UTF-8 at - line 14.
+Unicode non-character U+FDD0 is not recommended for open interchange in print at - line 17.
+Unicode non-character U+FDD1 is not recommended for open interchange in print at - line 18.
+Unicode non-character U+FDEF is not recommended for open interchange in print at - line 19.
+Unicode non-character U+FFFE is not recommended for open interchange in print at - line 26.
+Unicode non-character U+FFFF is not recommended for open interchange in print at - line 27.
+Unicode non-character U+1FFFE is not recommended for open interchange in print at - line 30.
+Unicode non-character U+1FFFF is not recommended for open interchange in print at - line 31.
+Unicode non-character U+2FFFE is not recommended for open interchange in print at - line 34.
+Unicode non-character U+2FFFF is not recommended for open interchange in print at - line 35.
+Unicode non-character U+3FFFE is not recommended for open interchange in print at - line 38.
+Unicode non-character U+3FFFF is not recommended for open interchange in print at - line 39.
+Unicode non-character U+4FFFE is not recommended for open interchange in print at - line 42.
+Unicode non-character U+4FFFF is not recommended for open interchange in print at - line 43.
+Unicode non-character U+5FFFE is not recommended for open interchange in print at - line 46.
+Unicode non-character U+5FFFF is not recommended for open interchange in print at - line 47.
+Unicode non-character U+6FFFE is not recommended for open interchange in print at - line 50.
+Unicode non-character U+6FFFF is not recommended for open interchange in print at - line 51.
+Unicode non-character U+7FFFE is not recommended for open interchange in print at - line 54.
+Unicode non-character U+7FFFF is not recommended for open interchange in print at - line 55.
+Unicode non-character U+8FFFE is not recommended for open interchange in print at - line 58.
+Unicode non-character U+8FFFF is not recommended for open interchange in print at - line 59.
+Unicode non-character U+9FFFE is not recommended for open interchange in print at - line 62.
+Unicode non-character U+9FFFF is not recommended for open interchange in print at - line 63.
+Unicode non-character U+AFFFE is not recommended for open interchange in print at - line 66.
+Unicode non-character U+AFFFF is not recommended for open interchange in print at - line 67.
+Unicode non-character U+BFFFE is not recommended for open interchange in print at - line 70.
+Unicode non-character U+BFFFF is not recommended for open interchange in print at - line 71.
+Unicode non-character U+CFFFE is not recommended for open interchange in print at - line 74.
+Unicode non-character U+CFFFF is not recommended for open interchange in print at - line 75.
+Unicode non-character U+DFFFE is not recommended for open interchange in print at - line 78.
+Unicode non-character U+DFFFF is not recommended for open interchange in print at - line 79.
+Unicode non-character U+EFFFE is not recommended for open interchange in print at - line 82.
+Unicode non-character U+EFFFF is not recommended for open interchange in print at - line 83.
+Unicode non-character U+FFFFE is not recommended for open interchange in print at - line 86.
+Unicode non-character U+FFFFF is not recommended for open interchange in print at - line 87.
+Unicode non-character U+10FFFE is not recommended for open interchange in print at - line 90.
+Unicode non-character U+10FFFF is not recommended for open interchange in print at - line 91.
+Code point 0x110000 is not Unicode, may not be portable in print at - line 92.
+Code point 0x11FFFD is not Unicode, may not be portable in print at - line 93.
+Code point 0x11FFFE is not Unicode, may not be portable in print at - line 94.
+Code point 0x11FFFF is not Unicode, may not be portable in print at - line 95.
+Code point 0x120000 is not Unicode, may not be portable in print at - line 96.
 ########
 require "../test.pl";
 use warnings 'utf8';
@@ -689,14 +756,29 @@ print $fh $to_warn_char, "\n";
 close $fh;
 EXPECT
 OPTION regex
-It is deprecated to use code point 0x80+; the permissible max is 0x7F+ at - line \d+.
-It is deprecated to use code point 0x80+; the permissible max is 0x7F+ in pattern match \(m//\) at - line \d+.
-It is deprecated to use code point 0x80+; the permissible max is 0x7F+ in regexp compilation at - line \d+.
-It is deprecated to use code point 0x80+; the permissible max is 0x7F+ in regexp compilation at - line \d+.
-It is deprecated to use code point 0x80+; the permissible max is 0x7F+ at - line \d+.
-It is deprecated to use code point 0x80+; the permissible max is 0x7F+ in regexp compilation at - line \d+.
+Use of code point 0x80+ is deprecated; the permissible max is 0x7F+ at - line \d+.
+Use of code point 0x80+ is deprecated; the permissible max is 0x7F+ in pattern match \(m//\) at - line \d+.
+Use of code point 0x80+ is deprecated; the permissible max is 0x7F+ in regexp compilation at - line \d+.
+Use of code point 0x80+ is deprecated; the permissible max is 0x7F+ in regexp compilation at - line \d+.
+Use of code point 0x80+ is deprecated; the permissible max is 0x7F+ at - line \d+.
+Use of code point 0x80+ is deprecated; the permissible max is 0x7F+ in regexp compilation at - line \d+.
 Operation "uc" returns its argument for non-Unicode code point 0x7F+ at - line \d+.
-It is deprecated to use code point 0x80+; the permissible max is 0x7F+ at - line \d+.
+Use of code point 0x80+ is deprecated; the permissible max is 0x7F+ at - line \d+.
 Operation "uc" returns its argument for non-Unicode code point 0x80+ at - line \d+.
 Code point 0x7F+ is not Unicode, may not be portable in print at - line \d+.
-It is deprecated to use code point 0x80+; the permissible max is 0x7F+ in print at - line \d+.
+Use of code point 0x80+ is deprecated; the permissible max is 0x7F+ in print at - line \d+.
+########
+# NAME  [perl #127262]
+BEGIN{
+    if (ord('A') == 193) {
+        print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
+        exit 0;
+    }
+    use Config;
+    unless ($Double{double_style_ieee}) {
+        print "SKIPPED\n# non-IEEE fp range.";
+        exit 0;
+    }
+{};$^H=eval'2**400'}Â
+EXPECT
+Malformed UTF-8 character: \xc2\x0a (unexpected non-continuation byte 0x0a, immediately after start byte 0xc2; need 2 bytes, got 1) at - line 11.