In article <E1RqfMI-0006Nd-BX@camel.ams6.corp.booking.com>,
sprout@cpan.org ("Father Chrysostomos") wrote:
>
> commit cc88c9aaa7ecb8334614c515caf0da2d5538403b
> Author: Father Chrysostomos <sprout@cpan.org>
> Date: Thu Jan 26 16:31:53 2012 -0800
>
> pat.t: Test that . overloading gets passed qr ref
>
> This is something that my sample patch in ticked #108780 (for
> fixing /foo$qr/ under ‘no overloading’) would have broken had it
> been applied.
>
> M t/re/pat.t
> -----------------------------------------------------------------------
> diff --git a/t/re/pat.t b/t/re/pat.t
> index 7b03e41..6c4cd1a 100644
> --- a/t/re/pat.t
> +++ b/t/re/pat.t
> @@ -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
This causes the following warning:
% ./perl -I../lib re/pat.t
Variable "@refs" will not stay shared at re/pat.t line 1232.
1..466
ok 1 - "abc\ndef\n" =~ /^abc/
ok 2 - "abc\ndef\n" !~ /^def/
That's on OS X. On VMS I see the same warning but the test suite chokes
on it with "unexpected output at test 0" and the test fails.