Re: [perl #39530] printf: bad formatting of hexadecimal conversion of binary string...
[p5sagit/p5-mst-13.2.git] / t / op / pat.t
index 004499f..0b5c1a5 100755 (executable)
@@ -6,7 +6,7 @@
 
 $| = 1;
 
-print "1..1199\n";
+print "1..1208\n";
 
 BEGIN {
     chdir 't' if -d 't';
@@ -3181,7 +3181,10 @@ ok("bbbbac" =~ /$pattern/ && $1 eq 'a', "[perl #3547]");
 }
 
 {
-    split /(?{ split "" })/, "abc";
+    # XXX DAPM 13-Apr-06. Recursive split is still broken. It's only luck it
+    # hasn't been crashing. Disable this test until it is fixed properly.
+    # XXX also check what it returns rather than just doing ok(1,...)
+    # split /(?{ split "" })/, "abc";
     ok(1,'cache_re & "(?{": it dumps core in 5.6.1 & 5.8.0');
 }
 
@@ -3432,7 +3435,7 @@ ok(("foba  ba$s" =~ qr/(foo|BaSS|bar)/i)
     
     my $aeek = bless {}, 'wooosh';
     eval {$aeek->gloople() =~ /(.)/g;};
-    ok($@ eq "", "# TODO 26410 caused a regression") or print "# $@\n";
+    ok($@ eq "", "//g match against return value of sub") or print "# $@\n";
 }
 
 {
@@ -3445,8 +3448,6 @@ ok(("foba  ba$s" =~ qr/(foo|BaSS|bar)/i)
 }
 
 {
-    # Prior to change 26410 this did not work:
-
     package lv;
     $var = "abc";
     sub variable : lvalue { $var }
@@ -3455,18 +3456,68 @@ ok(("foba  ba$s" =~ qr/(foo|BaSS|bar)/i)
     my $o = bless [], "lv";
     my $f = "";
     eval { for (1..2) { $f .= $1 if $o->variable =~ /(.)/g } };
-    ok($f eq "ab", "# pos retained between calls") or print "# $@\n";
+    ok($f eq "ab", "pos retained between calls # TODO") or print "# $@\n";
 }
 
 {
-    # Prior to change 26410 this did not work:
-
     $var = "abc";
     sub variable : lvalue { $var }
 
     my $f = "";
     eval { for (1..2) { $f .= $1 if variable() =~ /(.)/g } };
-    ok($f eq "ab", "# pos retained between calls") or print "# $@\n";
+    ok($f eq "ab", "pos retained between calls # TODO") or print "# $@\n";
+}
+
+# [perl #37836] Simple Regex causes SEGV when run on specific data
+if ($ordA == 193) {
+    print "ok $test # Skip: in EBCDIC\n"; $test++;
+} else {
+    no warnings 'utf8';
+    $_ = pack('U0C2', 0xa2, 0xf8); # ill-formed UTF-8
+    my $ret = 0;
+    eval { $ret = s/[\0]+//g };
+    ok($ret == 0, "ill-formed UTF-8 doesn't match NUL in class");
 }
 
-# last test 1199
+{ # [perl #38293] chr(65535) should be allowed in regexes
+    no warnings 'utf8'; # to allow non-characters
+    my($c, $r, $s);
+
+    $c = chr 0xffff;
+    $c =~ s/$c//g;
+    ok($c eq "", "U+FFFF, parsed as atom");
+
+    $c = chr 0xffff;
+    $r = "\\$c";
+    $c =~ s/$r//g;
+    ok($c eq "", "U+FFFF backslashed, parsed as atom");
+
+    $c = chr 0xffff;
+    $c =~ s/[$c]//g;
+    ok($c eq "", "U+FFFF, parsed in class");
+
+    $c = chr 0xffff;
+    $r = "[\\$c]";
+    $c =~ s/$r//g;
+    ok($c eq "", "U+FFFF backslashed, parsed in class");
+
+    $s = "A\x{ffff}B";
+    $s =~ s/\x{ffff}//i;
+    ok($s eq "AB", "U+FFFF, EXACTF");
+
+    $s = "\x{ffff}A";
+    $s =~ s/\bA//;
+    ok($s eq "\x{ffff}", "U+FFFF, BOUND");
+
+    $s = "\x{ffff}!";
+    $s =~ s/\B!//;
+    ok($s eq "\x{ffff}", "U+FFFF, NBOUND");
+} # non-characters end
+
+
+# Keep the following test last -- it may crash perl
+
+ok(("a" x (2**15 - 10)) =~ /^()(a|bb)*$/, "Recursive stack cracker: #24274")
+    or print "# Unexpected outcome: should pass or crash perl\n";
+
+# last test 1200