Commit | Line | Data |
---|---|---|
f9b5f5f8 | 1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
a28e50e4 | 5 | use Test::More; |
53a4d826 | 6 | use Test::Exception; |
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 | |
53a4d826 | 13 | ::throws_ok { |
52ac1d4a | 14 | has; |
53a4d826 | 15 | } $exception_regex, 'has; fails'; |
52ac1d4a | 16 | |
53a4d826 | 17 | ::throws_ok { |
52ac1d4a | 18 | has undef; |
53a4d826 | 19 | } $exception_regex, 'has undef; fails'; |
52ac1d4a | 20 | |
53a4d826 | 21 | ::lives_ok { |
52ac1d4a | 22 | has "" => ( |
23 | is => 'bare', | |
24 | ); | |
53a4d826 | 25 | } 'has ""; works now'; |
52ac1d4a | 26 | |
53a4d826 | 27 | ::lives_ok { |
52ac1d4a | 28 | has 0 => ( |
29 | is => 'bare', | |
30 | ); | |
53a4d826 | 31 | } 'has 0; works now'; |
f9b5f5f8 | 32 | } |
33 | ||
34 | { | |
35 | package My::Class; | |
36 | use Moose; | |
52ac1d4a | 37 | |
53a4d826 | 38 | ::throws_ok { |
52ac1d4a | 39 | has; |
53a4d826 | 40 | } $exception_regex, 'has; fails'; |
52ac1d4a | 41 | |
53a4d826 | 42 | ::throws_ok { |
52ac1d4a | 43 | has undef; |
53a4d826 | 44 | } $exception_regex, 'has undef; fails'; |
52ac1d4a | 45 | |
53a4d826 | 46 | ::lives_ok { |
52ac1d4a | 47 | has "" => ( |
48 | is => 'bare', | |
49 | ); | |
53a4d826 | 50 | } 'has ""; works now'; |
52ac1d4a | 51 | |
53a4d826 | 52 | ::lives_ok { |
52ac1d4a | 53 | has 0 => ( |
54 | is => 'bare', | |
55 | ); | |
53a4d826 | 56 | } 'has 0; works now'; |
f9b5f5f8 | 57 | } |
58 | ||
a28e50e4 | 59 | done_testing; |