Re: [perl #41071] require stringifies code references in tied @INC
[p5sagit/p5-mst-13.2.git] / t / op / attrs.t
index dc91438..7b20210 100644 (file)
@@ -1,14 +1,16 @@
-#!./perl -w
+#!./perl
 
 # Regression tests for attributes.pm and the C< : attrs> syntax.
 
+use warnings;
+
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
 }
 
-plan tests => 95;
+plan 'no_plan';
 
 $SIG{__WARN__} = sub { die @_ };
 
@@ -81,6 +83,10 @@ like $@, qr/^SCALAR package attribute may clash with future reserved word: ["']?
 eval 'my A $x : plugh plover;';
 like $@, qr/^SCALAR package attributes may clash with future reserved words: ["']?plugh["']? /;
 
+no warnings 'reserved';
+eval 'my A $x : plugh;';
+is $@, '';
+
 eval 'package Cat; my Cat @socks;';
 like $@, qr/^Can't declare class for non-scalar \@socks in "my"/;
 
@@ -106,6 +112,11 @@ is ref($thunk), "Z";
 @attrs = eval 'attributes::get $thunk';
 is "@attrs", "locked method Z";
 
+# Test attributes on predeclared subroutines:
+eval 'package A; sub PS : lvalue';
+@attrs = eval 'attributes::get \&A::PS';
+is "@attrs", "lvalue";
+
 # Test ability to modify existing sub's (or XSUB's) attributes.
 eval 'package A; sub X { $_[0] } sub X : lvalue';
 @attrs = eval 'attributes::get \&A::X';
@@ -142,12 +153,13 @@ eval_ok '
 
 # bug #15898
 eval 'our ${""} : foo = 1';
-like $@, qr/Can't declare scalar dereference in our/;
+like $@, qr/Can't declare scalar dereference in "our"/;
 eval 'my $$foo : bar = 1';
-like $@, qr/Can't declare scalar dereference in my/;
+like $@, qr/Can't declare scalar dereference in "my"/;
 
 
-my @code = qw(assertion lvalue locked method);
+my @code = qw(lvalue locked method);
+unshift @code, 'assertion' if $] >= 5.009;
 my @other = qw(shared unique);
 my %valid;
 $valid{CODE} = {map {$_ => 1} @code};