pat.t: Test that . overloading gets passed qr ref
authorFather Chrysostomos <sprout@cpan.org>
Fri, 27 Jan 2012 00:31:53 +0000 (16:31 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 27 Jan 2012 00:31:53 +0000 (16:31 -0800)
This is something that my sample patch in ticked #108780 (for
fixing /foo$qr/ under ‘no overloading’) would have broken had it
been applied.

t/re/pat.t

index 7b03e41..6c4cd1a 100644 (file)
@@ -21,7 +21,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 465;  # Update this when adding/deleting tests.
+plan tests => 466;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -1222,6 +1222,23 @@ EOP
        eval ' sub { my @a =~ // } ';
     }
 
+    { # Concat overloading and qr// thingies
+       my @refs;
+       my $qr = qr//;
+       package Cat {
+           use overload
+               '""' => sub { ${$_[0]} },
+               '.' => sub {
+                   push @refs, ref $_[1] if ref $_[1];
+                   bless $_[2] ? \"$_[1]${$_[0]}" : \"${$_[0]}$_[1]"
+               }
+       }
+       my $s = "foo";
+       my $o = bless \$s, Cat::;
+       /$o$qr/;
+       is "@refs", "Regexp", '/$o$qr/ passes qr ref to cat overload meth';
+    }
+
 } # End of sub run_tests
 
 1;