6 my $lazy_default = "lazy_default";
13 has rwp => (is => 'rwp');
14 has lazy => (is => 'lazy');
15 sub _build_lazy { $test }
16 has lazy_default => (is => 'lazy', default => sub { $lazy_default });
23 is $foo->rwp, undef, "rwp value starts out undefined";
24 like exception { $foo->rwp($test) }, qr/Usage: Foo::rwp\(self\)/, "rwp is read_only";
25 is exception { $foo->_set_rwp($test) }, undef, "rwp can be set by writer";
26 is $foo->rwp, $test, "rwp value was set by writer";
31 is $foo->{lazy}, undef, "lazy value storage is undefined";
32 is $foo->lazy, $test, "lazy value returns test value when called";
33 like exception { $foo->lazy($test) }, qr/Usage: Foo::lazy\(self\)/, "lazy is read_only";
35 my $foo_with_args = Foo->new(lazy => $test);
36 is $foo_with_args->{lazy}, undef, "lazy ignores constructor value";
41 is $foo->{lazy_default}, undef, "lazy_default value storage is undefined";
42 is $foo->lazy_default, $lazy_default, "lazy_default value returns test value when called";
43 like exception { $foo->lazy_default($test) }, qr/Usage: Foo::lazy\(self\)/, "lazy_default is read_only";
45 my $foo_with_args = Foo->new(lazy_default => $test);
46 is $foo_with_args->{lazy_default}, undef, "lazy_default ignores constructor value";