develooper Front page | perl.perl5.porters | Postings from January 2012

pat.t warning (Re: [perl.git] branch blead,updated. v5.15.7-90-g69a8a23)

Thread Next
From:
Craig A. Berry
Date:
January 28, 2012 06:42
Subject:
pat.t warning (Re: [perl.git] branch blead,updated. v5.15.7-90-g69a8a23)
Message ID:
craigberry-40DB47.08421728012012@cpc2-bmly6-0-0-cust974.2-3.cable.virginmedia.com
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.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About