6 use Test::More tests => 15;
15 has 'bar' => (is => 'ro', required => 1);
16 has 'baz' => (is => 'rw', default => 100, required => 1);
17 has 'boo' => (is => 'rw', lazy => 1, default => 50, required => 1);
21 my $foo = Foo->new(bar => 10, baz => 20, boo => 100);
24 is($foo->bar, 10, '... got the right bar');
25 is($foo->baz, 20, '... got the right baz');
26 is($foo->boo, 100, '... got the right boo');
30 my $foo = Foo->new(bar => 10, boo => 5);
33 is($foo->bar, 10, '... got the right bar');
34 is($foo->baz, 100, '... got the right baz');
35 is($foo->boo, 5, '... got the right boo');
39 my $foo = Foo->new(bar => 10);
42 is($foo->bar, 10, '... got the right bar');
43 is($foo->baz, 100, '... got the right baz');
44 is($foo->boo, 50, '... got the right boo');
47 #Yeah.. this doesn't work like this anymore, see below. (groditi)
49 # Foo->new(bar => 10, baz => undef);
50 #} qr/^Attribute \(baz\) is required and cannot be undef/, '... must supply all the required attribute';
53 # Foo->new(bar => 10, boo => undef);
54 #} qr/^Attribute \(boo\) is required and cannot be undef/, '... must supply all the required attribute';
57 Foo->new(bar => 10, baz => undef);
58 } '... undef is a valid attribute value';
61 Foo->new(bar => 10, boo => undef);
62 } '... undef is a valid attribute value';
67 } qr/^Attribute \(bar\) is required/, '... must supply all the required attribute';