4 use Test::More tests => 6;
6 my $builder_called = 0;
15 builder => '_build_name',
18 sub default_name { "Frank" }
22 return uc $self->default_name;
26 my $object = Class->new(name => "Bob");
27 is($builder_called, 0, "builder not called in the constructor when we pass a value");
28 is($object->name, "Bob", "builder doesn't matter when we just set the value in constructor");
29 $object->name("Bill");
30 is($object->name, "Bill", "builder doesn't matter when we just set the value in writer");
31 is($builder_called, 0, "builder not called in the setter");
34 my $object2 = Class->new;
35 is($object2->name, "FRANK", "builder called to provide the default value");
36 is($builder_called, 1, "builder called ONCE to provide the default value");
38 # XXX: test clearer, lazy