X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F020_attributes%2F023_attribute_names.t;fp=t%2F020_attributes%2F023_attribute_names.t;h=9656e47a5ea633fc8378da42049e607567c5ee90;hb=52ac1d4a4961feee7a54e3b018fe1e609f1fe8a1;hp=f63b94816461942cb8745ee589d7f6202bf8ed82;hpb=854809075427abb0da2bb9d99d8f829ce91c0831;p=gitmo%2FMoose.git diff --git a/t/020_attributes/023_attribute_names.t b/t/020_attributes/023_attribute_names.t index f63b948..9656e47 100644 --- a/t/020_attributes/023_attribute_names.t +++ b/t/020_attributes/023_attribute_names.t @@ -5,25 +5,54 @@ use warnings; use Test::More tests => 8; use Test::Exception; -# note: not sure about "" and 0 being illegal attribute names -# but I'm just copying what Class::MOP::Attribute does - my $exception_regex = qr/You must provide a name for the attribute/; { package My::Role; use Moose::Role; - ::throws_ok{ has; } $exception_regex, 'has; fails'; - ::throws_ok{ has undef; } $exception_regex, 'has undef; fails'; - ::throws_ok{ has ""; } $exception_regex, 'has ""; fails'; - ::throws_ok{ has 0; } $exception_regex, 'has 0; fails'; + + ::throws_ok { + has; + } $exception_regex, 'has; fails'; + + ::throws_ok { + has undef; + } $exception_regex, 'has undef; fails'; + + ::lives_ok { + has "" => ( + is => 'bare', + ); + } 'has ""; works now'; + + ::lives_ok { + has 0 => ( + is => 'bare', + ); + } 'has 0; works now'; } { package My::Class; use Moose; - ::throws_ok{ has; } $exception_regex, 'has; fails'; - ::throws_ok{ has undef; } $exception_regex, 'has undef; fails'; - ::throws_ok{ has ""; } $exception_regex, 'has ""; fails'; - ::throws_ok{ has 0; } $exception_regex, 'has 0; fails'; + + ::throws_ok { + has; + } $exception_regex, 'has; fails'; + + ::throws_ok { + has undef; + } $exception_regex, 'has undef; fails'; + + ::lives_ok { + has "" => ( + is => 'bare', + ); + } 'has ""; works now'; + + ::lives_ok { + has 0 => ( + is => 'bare', + ); + } 'has 0; works now'; }