Commit | Line | Data |
4060c871 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use Test::More tests => 8; |
6 | use Test::Exception; |
7 | |
8 | my $exception_regex = qr/You must provide a name for the attribute/; |
9 | { |
10 | package My::Role; |
11 | use Mouse::Role; |
12 | |
13 | ::throws_ok { |
14 | has; |
15 | } $exception_regex, 'has; fails'; |
16 | |
17 | ::throws_ok { |
18 | has undef; |
19 | } $exception_regex, 'has undef; fails'; |
20 | |
21 | ::lives_ok { |
22 | has "" => ( |
23 | is => 'bare', |
24 | ); |
25 | } 'has ""; works now'; |
26 | |
27 | ::lives_ok { |
28 | has 0 => ( |
29 | is => 'bare', |
30 | ); |
31 | } 'has 0; works now'; |
32 | } |
33 | |
34 | { |
35 | package My::Class; |
36 | use Mouse; |
37 | |
38 | ::throws_ok { |
39 | has; |
40 | } $exception_regex, 'has; fails'; |
41 | |
42 | ::throws_ok { |
43 | has undef; |
44 | } $exception_regex, 'has undef; fails'; |
45 | |
46 | ::lives_ok { |
47 | has "" => ( |
48 | is => 'bare', |
49 | ); |
50 | } 'has ""; works now'; |
51 | |
52 | ::lives_ok { |
53 | has 0 => ( |
54 | is => 'bare', |
55 | ); |
56 | } 'has 0; works now'; |
57 | } |
58 | |