6 use Test::More tests => 14;
17 has 'bar' => (is => 'ro', required => 1);
18 has 'baz' => (is => 'rw', default => 100, required => 1);
21 # this attribute is actually kind of silly
22 # since lazy requires default, then the
23 # required attribute becomes void in this
24 # case. But hey, best to test it :)
25 has 'boo' => (is => 'rw', lazy => 1, default => 50, required => 1);
29 my $foo = Foo->new(bar => 10, baz => 20, boo => 100);
32 is($foo->bar, 10, '... got the right bar');
33 is($foo->baz, 20, '... got the right baz');
34 is($foo->boo, 100, '... got the right boo');
38 my $foo = Foo->new(bar => 10, boo => 5);
41 is($foo->bar, 10, '... got the right bar');
42 is($foo->baz, 100, '... got the right baz');
43 is($foo->boo, 5, '... got the right boo');
47 my $foo = Foo->new(bar => 10);
50 is($foo->bar, 10, '... got the right bar');
51 is($foo->baz, 100, '... got the right baz');
52 is($foo->boo, 50, '... got the right boo');
57 } qr/^Attribute \(bar\) is required/, '... must supply all the required attribute';