14 has 'bar' => (is => 'ro', required => 1);
15 has 'baz' => (is => 'rw', default => 100, required => 1);
16 has 'boo' => (is => 'rw', lazy => 1, default => 50, required => 1);
20 my $foo = Foo->new(bar => 10, baz => 20, boo => 100);
23 is($foo->bar, 10, '... got the right bar');
24 is($foo->baz, 20, '... got the right baz');
25 is($foo->boo, 100, '... got the right boo');
29 my $foo = Foo->new(bar => 10, boo => 5);
32 is($foo->bar, 10, '... got the right bar');
33 is($foo->baz, 100, '... got the right baz');
34 is($foo->boo, 5, '... got the right boo');
38 my $foo = Foo->new(bar => 10);
41 is($foo->bar, 10, '... got the right bar');
42 is($foo->baz, 100, '... got the right baz');
43 is($foo->boo, 50, '... got the right boo');
46 #Yeah.. this doesn't work like this anymore, see below. (groditi)
48 # Foo->new(bar => 10, baz => undef);
49 #} qr/^Attribute \(baz\) is required and cannot be undef/, '... must supply all the required attribute';
52 # Foo->new(bar => 10, boo => undef);
53 #} qr/^Attribute \(boo\) is required and cannot be undef/, '... must supply all the required attribute';
56 Foo->new(bar => 10, baz => undef);
57 }, undef, '... undef is a valid attribute value' );
60 Foo->new(bar => 10, boo => undef);
61 }, undef, '... undef is a valid attribute value' );
66 }, qr/^Attribute \(bar\) is required/, '... must supply all the required attribute' );