6 use Test::More tests => 15;
14 our $VERSION = '0.01';
15 sub foo { 'FooRole::foo' }
22 #two checks because the inlined methods are different when
23 #there is a TC present.
24 has 'foos' => (is => 'ro', lazy_build => 1);
25 has 'bars' => (isa => 'Str', is => 'ro', lazy_build => 1);
26 has 'bazes' => (isa => 'Str', is => 'ro', builder => '_build_bazes');
27 sub _build_foos { "many foos" }
28 sub _build_bars { "many bars" }
29 sub _build_bazes { "many bazes" }
33 my $foo_role = Moose::Meta::Role->initialize('FooRole');
36 lives_ok{ Foo->new } "lazy_build works";
37 is(Foo->new->foos, 'many foos' , "correct value for 'foos' before inlining constructor");
38 is(Foo->new->bars, 'many bars' , "correct value for 'bars' before inlining constructor");
39 is(Foo->new->bazes, 'many bazes' , "correct value for 'bazes' before inlining constructor");
40 lives_ok{ $meta->make_immutable } "Foo is imutable";
41 lives_ok{ $meta->identifier } "->identifier on metaclass lives";
42 dies_ok{ $meta->add_role($foo_role) } "Add Role is locked";
43 lives_ok{ Foo->new } "Inlined constructor works with lazy_build";
44 is(Foo->new->foos, 'many foos' , "correct value for 'foos' after inlining constructor");
45 is(Foo->new->bars, 'many bars' , "correct value for 'bars' after inlining constructor");
46 is(Foo->new->bazes, 'many bazes' , "correct value for 'bazes' after inlining constructor");
47 lives_ok{ $meta->make_mutable } "Foo is mutable";
48 lives_ok{ $meta->add_role($foo_role) } "Add Role is unlocked";
71 lives_ok { Bar->meta->make_immutable }
72 'Immutable meta with single BUILD';
74 lives_ok { Baz->meta->make_immutable }
75 'Immutable meta with multiple BUILDs';
79 Nothing here yet, but soon :)