Tweak the filename regexp in parser.t so that ./TEST -utf16 op/parser.t passes.
[p5sagit/p5-mst-13.2.git] / t / comp / utf.t
index 00523f9..d59ba2d 100644 (file)
@@ -1,6 +1,6 @@
 #!./perl -w
 
-print "1..100\n";
+print "1..3980\n";
 my $test = 0;
 
 my %templates = (
@@ -62,6 +62,8 @@ for my $bom (0, 1) {
 
            for my $expect ("N", "\xFF", "\x{100}", "\x{010a}", "\x{0a23}",
                            "\x{10000}", "\x{64321}", "\x{10FFFD}",
+                           "\x{1000a}", # 0xD800 0xDC0A
+                           "\x{12800}", # 0xD80A 0xDC00
                           ) {
                # A space so that the UTF-16 heuristic triggers - " '" gives two
                # characters of ASCII.
@@ -69,6 +71,21 @@ for my $bom (0, 1) {
                my $name = 'chrs ' . join ', ', map {ord $_} split '', $expect;
                test($enc, $write, $expect, $bom, $nl, $name);
            }
+
+           # This is designed to try to trip over the end of the buffer,
+           # with similar results to U-1000A and U-12800 above.
+           for my $pad (2 .. 162) {
+               for my $chr ("\x{10000}", "\x{1000a}", "\x{12800}") {
+                   my $padding = ' ' x $pad;
+                   # Need 4 octets that were from 2 ASCII characters to trigger
+                   # the heuristic that detects UTF-16 without a BOM. For
+                   # UTF-16BE, one space and the newline will do, as the
+                   # newline's high octet comes first. But for UTF-16LE, a
+                   # newline is "\n\0", so it doesn't trigger it.
+                   test($enc, "  \n$padding'$chr'", $chr, $bom, $nl,
+                        sprintf "'\\x{%x}' with $pad spaces before it", ord $chr);
+               }
+           }
        }
     }
 }