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");