-#!./perl -w
+#!./perl
# Regression tests for attributes.pm and the C< : attrs> syntax.
+use warnings;
+
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
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"/;
@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';
# 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(lvalue locked method);