summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2002-08-08 20:57:59 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2002-08-08 20:57:59 +0000
commitc9124e9294bd94b9fd79577899b132159c6feb6f (patch)
tree095d9c01cea5436566176f8913e9815f5835536d
parent8e7ae056e33b3389a21755f55fa95e623bcad80f (diff)
downloadperl-c9124e9294bd94b9fd79577899b132159c6feb6f.tar.gz
More tests for the attribute syntax, from the
attributes manpage. p4raw-id: //depot/perl@17705
-rw-r--r--t/op/attrs.t20
1 files changed, 19 insertions, 1 deletions
diff --git a/t/op/attrs.t b/t/op/attrs.t
index 264de8a510..25abeb21b5 100644
--- a/t/op/attrs.t
+++ b/t/op/attrs.t
@@ -8,7 +8,7 @@ BEGIN {
require './test.pl';
}
-plan tests => 39;
+plan tests => 47;
$SIG{__WARN__} = sub { die @_ };
@@ -56,6 +56,24 @@ like $@, qr/^Invalid SCALAR attribute: ["']?plugh["']? at/;
eval '{my ($x,$y) : plugh(})}';
like $@, qr/^Invalid SCALAR attribute: ["']?plugh\(}\)["']? at/;
+# More syntax tests from the attributes manpage
+eval 'my $x : switch(10,foo(7,3)) : expensive;';
+like $@, qr/^Invalid SCALAR attributes: ["']?switch\(10,foo\(7,3\)\) : expensive["']? at/;
+eval q/my $x : Ugly('\(") :Bad;/;
+like $@, qr/^Invalid SCALAR attributes: ["']?Ugly\('\\\("\) : Bad["']? at/;
+eval 'my $x : _5x5;';
+like $@, qr/^Invalid SCALAR attribute: ["']?_5x5["']? at/;
+eval 'my $x : locked method;';
+like $@, qr/^Invalid SCALAR attributes: ["']?locked : method["']? at/;
+eval 'my $x : switch(10,foo();';
+like $@, qr/^Unterminated attribute parameter in attribute list at/;
+eval q/my $x : Ugly('(');/;
+like $@, qr/^Unterminated attribute parameter in attribute list at/;
+eval 'my $x : 5x5;';
+like $@, qr/error/;
+eval 'my $x : Y2::north;';
+like $@, qr/Invalid separator character ':' in attribute list at/;
+
sub A::MODIFY_SCALAR_ATTRIBUTES { return }
eval 'my A $x : plugh;';
like $@, qr/^SCALAR package attribute may clash with future reserved word: ["']?plugh["']? at/;