Commit | Line | Data |
f9b5f5f8 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use Test::More tests => 8; |
6 | use Test::Exception; |
7 | |
8 | # note: not sure about "" and 0 being illegal attribute names |
9 | # but I'm just copying what Class::MOP::Attribute does |
10 | |
11 | my $exception_regex = qr/You must provide a name for the attribute/; |
12 | { |
13 | package My::Role; |
14 | use Moose::Role; |
15 | ::throws_ok{ has; } $exception_regex, 'has; fails'; |
16 | ::throws_ok{ has undef; } $exception_regex, 'has undef; fails'; |
17 | ::throws_ok{ has ""; } $exception_regex, 'has ""; fails'; |
18 | ::throws_ok{ has 0; } $exception_regex, 'has 0; fails'; |
19 | } |
20 | |
21 | { |
22 | package My::Class; |
23 | use Moose; |
24 | ::throws_ok{ has; } $exception_regex, 'has; fails'; |
25 | ::throws_ok{ has undef; } $exception_regex, 'has undef; fails'; |
26 | ::throws_ok{ has ""; } $exception_regex, 'has ""; fails'; |
27 | ::throws_ok{ has 0; } $exception_regex, 'has 0; fails'; |
28 | } |
29 | |