This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix bug #109206: ANCH_MBOL with while /.*/g
[perl5.git] / t / re / pat.t
index 8ea531c..b4b7ac4 100644 (file)
@@ -21,7 +21,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 466;  # Update this when adding/deleting tests.
+plan tests => 469;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -1241,6 +1241,18 @@ EOP
        is "@refs", "Regexp", '/$o$qr/ passes qr ref to cat overload meth';
     }
 
+    {
+        my $count=0;
+        my $str="\n";
+        $count++ while $str=~/.*/g;
+        is $count, 2, 'test that ANCH_MBOL works properly. We should get 2 from $count++ while "\n"=~/.*/g';
+        my $class_count= 0;
+        $class_count++ while $str=~/[^\n]*/g;
+        is $class_count, $count, 'while "\n"=~/.*/g and while "\n"=~/[^\n]*/g should behave the same';
+        my $anch_count= 0;
+        $anch_count++ while $str=~/^.*/mg;
+        is $anch_count, 1, 'while "\n"=~/^.*/mg should match only once';
+    }
 } # End of sub run_tests
 
 1;