Really check that sysread(I, $x, 1, -4) dies with "Offset outside string"
[p5sagit/p5-mst-13.2.git] / t / op / pat.t
old mode 100755 (executable)
new mode 100644 (file)
index 62ca4b2..00c5490
@@ -13,7 +13,7 @@ sub run_tests;
 
 $| = 1;
 
-my $EXPECTED_TESTS = 4061;  # Update this when adding/deleting tests.
+my $EXPECTED_TESTS = 4066;  # Update this when adding/deleting tests.
 
 BEGIN {
     chdir 't' if -d 't';
@@ -4159,7 +4159,7 @@ sub run_tests {
             [ 1, qr#^((??{"(?:|<(/?bla)>)"}))((??{$nested_tags}))\1$#, "bla blubb <bla><blubb></blubb></bla>", "a b <bla><blubb></blubb></bla>" ],
             [ 0, qr#^((??{"(?!)"}))?((??{$nested_tags}))(?!)$#, "bla blubb undef", "a b undef" ],
 
-        ) {
+        ) { #"#silence vim highlighting
             $c++;
             @ctl_n = ();
             @plus = ();
@@ -4346,6 +4346,39 @@ sub run_tests {
             iseq($str, "\$1 = undef, \$2 = undef, \$3 = undef, \$4 = undef, \$5 = undef, \$^R = undef");
        }
     }
+
+    # This only works under -DEBUGGING because it relies on an assert().
+    {
+        local $BugId = '60508';
+       local $Message = "Check capture offset re-entrancy of utf8 code.";
+
+        sub fswash { $_[0] =~ s/([>X])//g; }
+
+        my $k1 = "." x 4 . ">>";
+        fswash($k1);
+
+        my $k2 = "\x{f1}\x{2022}";
+        $k2 =~ s/([\360-\362])/>/g;
+        fswash($k2);
+
+        iseq($k2, "\x{2022}", "utf8::SWASHNEW doesn't cause capture leaks");
+    }
+
+
+    {
+       local $BugId = 65372;   # minimal CURLYM limited to 32767 matches
+       my @pat = (
+           qr{a(x|y)*b},       # CURLYM
+           qr{a(x|y)*?b},      # .. with minmod
+           qr{a([wx]|[yz])*b}, # .. and without tries
+           qr{a([wx]|[yz])*?b},
+       );
+       my $len = 32768;
+       my $s = join '', 'a', 'x' x $len, 'b';
+       for my $pat (@pat) {
+           ok($s =~ $pat, $pat);
+       }
+    }
     #
     # This should be the last test.
     #