Commit | Line | Data |
c3398f5b |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | use Test::More tests => 3; |
eab81545 |
5 | use Test::Exception; |
c3398f5b |
6 | |
7 | do { |
8 | package Class; |
9 | use Mouse; |
10 | |
11 | has foo => ( |
74be9f76 |
12 | is => 'bare', |
c3398f5b |
13 | required => 1, |
14 | ); |
15 | |
16 | has bar => ( |
74be9f76 |
17 | is => 'bare', |
c3398f5b |
18 | required => 1, |
19 | default => 50, |
20 | ); |
21 | |
22 | has baz => ( |
74be9f76 |
23 | is => 'bare', |
c3398f5b |
24 | required => 1, |
25 | default => sub { 10 }, |
26 | ); |
27 | |
28 | has quux => ( |
29 | is => "rw", |
30 | required => 1, |
31 | lazy => 1, |
32 | default => sub { "yay" }, |
33 | ); |
34 | }; |
35 | |
398327c3 |
36 | throws_ok { Class->new } qr/Attribute \(foo\) is required/, "required attribute is required"; |
c3398f5b |
37 | lives_ok { Class->new(foo => 5) } "foo is the only required but unfulfilled attribute"; |
38 | lives_ok { Class->new(foo => 1, bar => 1, baz => 1, quux => 1) } "all attributes specified"; |
39 | |