6 use Test::More tests => 20;
20 ::ok(!$@, '... created the reader method okay');
24 reader => 'get_lazy_foo',
29 ::ok(!$@, '... created the lazy reader method okay') or warn $@;
34 local $SIG{__WARN__} = sub { $warn = $_[0] };
39 ::ok($warn, '... got a warning for mispelled attribute argument');
46 can_ok($foo, 'get_foo');
47 is($foo->get_foo(), undef, '... got an undefined value');
50 } '... get_foo is a read-only';
52 ok(!exists($foo->{lazy_foo}), '... no value in get_lazy_foo slot');
54 can_ok($foo, 'get_lazy_foo');
55 is($foo->get_lazy_foo(), 10, '... got an deferred value');
57 $foo->get_lazy_foo(100);
58 } '... get_lazy_foo is a read-only';
65 my $attr = $foo->meta->find_attribute_by_name("lazy_foo");
67 isa_ok( $attr, "Mouse::Meta::Attribute" );
69 ok( $attr->is_lazy, "it's lazy" );
71 is( $attr->get_raw_value($foo), undef, "raw value" );
73 is( $attr->get_value($foo), 10, "lazy value" );
75 is( $attr->get_raw_value($foo), 10, "raw value" );
79 my $foo = Foo->new(foo => 10, lazy_foo => 100);
82 is($foo->get_foo(), 10, '... got the correct value');
83 is($foo->get_lazy_foo(), 100, '... got the correct value');