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