Fix test for overload in given() with smart match after last change
[p5sagit/p5-mst-13.2.git] / t / op / subst.t
index 59c3d21..06c04e8 100755 (executable)
@@ -1,4 +1,4 @@
-#!./perl -wT
+#!./perl -w
 
 BEGIN {
     chdir 't' if -d 't';
@@ -7,7 +7,7 @@ BEGIN {
 }
 
 require './test.pl';
-plan( tests => 126 );
+plan( tests => 139 );
 
 $x = 'foo';
 $_ = "x";
@@ -516,3 +516,78 @@ is("<$_> <$s>", "<> <4>", "[perl #7806]");
     $f =~ s/x/y/g;
     is($f, "yy", "[perl #17757]");
 }
+
+# [perl #20684] returned a zero count
+$_ = "1111";
+is(s/(??{1})/2/eg, 4, '#20684 s/// with (??{..}) inside');
+
+# [perl #20682] @- not visible in replacement
+$_ = "123";
+/(2)/; # seed @- with something else
+s/(1)(2)(3)/$#- (@-)/;
+is($_, "3 (0 0 1 2)", '#20682 @- not visible in replacement');
+
+# [perl #20682] $^N not visible in replacement
+$_ = "abc";
+/(a)/; s/(b)|(c)/-$^N/g;
+is($_,'a-b-c','#20682 $^N not visible in replacement');
+
+# [perl #22351] perl bug with 'e' substitution modifier
+my $name = "chris";
+{
+    no warnings 'uninitialized';
+    $name =~ s/hr//e;
+}
+is($name, "cis", q[#22351 bug with 'e' substitution modifier]);
+
+
+# [perl #34171] $1 didn't honour 'use bytes' in s//e
+{
+    my $s="\x{100}";
+    my $x;
+    {
+       use bytes;
+       $s=~ s/(..)/$x=$1/e
+    }
+    is(length($x), 2, '[perl #34171]');
+}
+
+
+{ # [perl #27940] perlbug: [\x00-\x1f] works, [\c@-\c_] does not
+    my $c;
+
+    ($c = "\x20\c@\x30\cA\x40\cZ\x50\c_\x60") =~ s/[\c@-\c_]//g;
+    is($c, "\x20\x30\x40\x50\x60", "s/[\\c\@-\\c_]//g");
+
+    ($c = "\x20\x00\x30\x01\x40\x1A\x50\x1F\x60") =~ s/[\x00-\x1f]//g;
+    is($c, "\x20\x30\x40\x50\x60", "s/[\\x00-\\x1f]//g");
+}
+{
+    $_ = "xy";
+    no warnings 'uninitialized';
+    /(((((((((x)))))))))(z)/;  # clear $10
+    s/(((((((((x)))))))))(y)/${10}/;
+    is($_,"y","RT#6006: \$_ eq '$_'");
+    $_ = "xr";
+    s/(((((((((x)))))))))(r)/fooba${10}/;
+    is($_,"foobar","RT#6006: \$_ eq '$_'");
+}
+{
+    my $want=("\n" x 11).("B\n" x 11)."B";
+    $_="B";
+    our $i;
+    for $i(1..11){
+       s/^.*$/$&/gm;
+       $_="\n$_\n$&";
+    }
+    is($want,$_,"RT#17542");
+}
+
+{
+    my @tests = ('ABC', "\xA3\xA4\xA5", "\x{410}\x{411}\x{412}");
+    foreach (@tests) {
+       my $id = ord $_;
+       s/./pos/ge;
+       is($_, "012", "RT#52104: $id");
+    }
+}