6 use Test::More tests => 16;
17 has 'bar' => (is => 'ro', required => 1);
18 has 'baz' => (is => 'rw', default => 100, required => 1);
19 has 'boo' => (is => 'rw', lazy => 1, default => 50, required => 1);
23 my $foo = Foo->new(bar => 10, baz => 20, boo => 100);
26 is($foo->bar, 10, '... got the right bar');
27 is($foo->baz, 20, '... got the right baz');
28 is($foo->boo, 100, '... got the right boo');
32 my $foo = Foo->new(bar => 10, boo => 5);
35 is($foo->bar, 10, '... got the right bar');
36 is($foo->baz, 100, '... got the right baz');
37 is($foo->boo, 5, '... got the right boo');
41 my $foo = Foo->new(bar => 10);
44 is($foo->bar, 10, '... got the right bar');
45 is($foo->baz, 100, '... got the right baz');
46 is($foo->boo, 50, '... got the right boo');
49 #Yeah.. this doesn't work like this anymore, see below. (groditi)
51 # Foo->new(bar => 10, baz => undef);
52 #} qr/^Attribute \(baz\) is required and cannot be undef/, '... must supply all the required attribute';
55 # Foo->new(bar => 10, boo => undef);
56 #} qr/^Attribute \(boo\) is required and cannot be undef/, '... must supply all the required attribute';
59 Foo->new(bar => 10, baz => undef);
60 } '... undef is a valid attribute value';
63 Foo->new(bar => 10, boo => undef);
64 } '... undef is a valid attribute value';
69 } qr/^Attribute \(bar\) is required/, '... must supply all the required attribute';