9 package Foo::Trait::Constructor;
12 around _generate_BUILDALL => sub {
15 return $self->$orig(@_) . '$::called++;';
22 Moose::Util::MetaRole::apply_metaroles(
25 constructor => ['Foo::Trait::Constructor'],
31 is($called, 0, "no calls before inlining");
32 Foo->meta->make_immutable;
35 is($called, 1, "inlined constructor has trait modifications");
37 ok(Foo->meta->constructor_class->meta->does_role('Foo::Trait::Constructor'),
38 "class has correct constructor traits");
49 is($called, 0, "no calls before inlining");
51 Foo::Sub->meta->make_immutable;
54 is($called, 1, "inherits constructor trait properly");
56 ok(Foo::Sub->meta->constructor_class->meta->can('does_role')
57 && Foo::Sub->meta->constructor_class->meta->does_role('Foo::Trait::Constructor'),
58 "subclass inherits constructor traits");
66 use Moose -traits => ['Foo2::Role'];
67 __PACKAGE__->meta->make_immutable;
76 my $meta = __PACKAGE__->meta;
77 $meta->superclasses('Foo2');
78 { our $TODO; local $TODO = "need to handle immutability better";
79 ::lives_ok { $meta->superclasses('Bar2') };
80 ::lives_ok { $meta->make_mutable if $meta->is_immutable };