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 => ( |
12 | required => 1, |
13 | ); |
14 | |
15 | has bar => ( |
16 | required => 1, |
17 | default => 50, |
18 | ); |
19 | |
20 | has baz => ( |
21 | required => 1, |
22 | default => sub { 10 }, |
23 | ); |
24 | |
25 | has quux => ( |
26 | is => "rw", |
27 | required => 1, |
28 | lazy => 1, |
29 | default => sub { "yay" }, |
30 | ); |
31 | }; |
32 | |
398327c3 |
33 | throws_ok { Class->new } qr/Attribute \(foo\) is required/, "required attribute is required"; |
c3398f5b |
34 | lives_ok { Class->new(foo => 5) } "foo is the only required but unfulfilled attribute"; |
35 | lives_ok { Class->new(foo => 1, bar => 1, baz => 1, quux => 1) } "all attributes specified"; |
36 | |