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