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 is( exception { Foo->new }, undef, "lazy_build works" );
37 is( Foo->new->foos, 'many foos',
38 "correct value for 'foos' before inlining constructor" );
39 is( Foo->new->bars, 'many bars',
40 "correct value for 'bars' before inlining constructor" );
41 is( Foo->new->bazes, 'many bazes',
42 "correct value for 'bazes' before inlining constructor" );
43 is( exception { $meta->make_immutable }, undef, "Foo is imutable" );
44 is( exception { $meta->identifier }, undef, "->identifier on metaclass lives" );
45 isnt( exception { $meta->add_role($foo_role) }, undef, "Add Role is locked" );
46 is( exception { Foo->new }, undef, "Inlined constructor works with lazy_build" );
47 is( Foo->new->foos, 'many foos',
48 "correct value for 'foos' after inlining constructor" );
49 is( Foo->new->bars, 'many bars',
50 "correct value for 'bars' after inlining constructor" );
51 is( Foo->new->bazes, 'many bazes',
52 "correct value for 'bazes' after inlining constructor" );
53 is( exception { $meta->make_mutable }, undef, "Foo is mutable" );
54 is( exception { $meta->add_role($foo_role) }, undef, "Add Role is unlocked" );
76 is( exception { Bar->meta->make_immutable }, undef, 'Immutable meta with single BUILD' );
78 is( exception { Baz->meta->make_immutable }, undef, 'Immutable meta with multiple BUILDs' );
82 Nothing here yet, but soon :)