Test perl #4289
authorFather Chrysostomos <sprout@cpan.org>
Sun, 25 Nov 2012 22:28:25 +0000 (14:28 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 27 Nov 2012 15:05:03 +0000 (07:05 -0800)
This was fixed by the disabling of PL_sawampersand a few commits ago.

The output used to be like this:

$ perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$&|, "\n"'
e
$ perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$`|, "\n"'
h
$ perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$'\''|, "\n"'
l

Now it’s like this:

$ ./perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$&|, "\n"'
b
$ ./perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$`|, "\n"'
a
$ ./perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$'\''|, "\n"'
c

t/re/pat_rt_report.t

index 262e8d3..d19d1df 100644 (file)
@@ -22,7 +22,7 @@ BEGIN {
 }
 
 
-plan tests => 2527;  # Update this when adding/deleting tests.
+plan tests => 2530;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -1143,6 +1143,19 @@ EOP
         ok("blah blah" =~ /$pattern/, $message);
         ok("blah blah" =~ /(?:$pattern)h/, $message);
     }
+
+    {
+        # [perl #4289] First mention $& after a match
+        fresh_perl_is(
+            '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$&|, "\n"',
+            "b\n", {}, '$& first mentioned after match');
+        fresh_perl_is(
+            '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$`|, "\n"',
+            "a\n", {}, '$` first mentioned after match');
+        fresh_perl_is(
+            '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$\'|,"\n"',
+            "c\n", {}, '$\' first mentioned after match');
+    }
 } # End of sub run_tests
 
 1;