7 use Test::Moose qw(does_ok);
10 package Foo::Trait::Class;
15 package Foo::Trait::Attribute;
20 package Foo::Role::Base;
25 package Foo::Exporter;
28 Moose::Exporter->setup_import_methods(
30 class => ['Foo::Trait::Class'],
31 attribute => ['Foo::Trait::Attribute'],
33 role_metaroles => { role => ['Foo::Trait::Class'] },
34 base_class_roles => ['Foo::Role::Base'],
41 Foo::Exporter->import;
43 has foo => (is => 'ro');
45 ::does_ok(Foo->meta, 'Foo::Trait::Class');
46 ::does_ok(Foo->meta->get_attribute('foo'), 'Foo::Trait::Attribute');
47 ::does_ok('Foo', 'Foo::Role::Base');
51 package Foo::Exporter::WithMoose;
55 my ( $import, $unimport, $init_meta )
56 = Moose::Exporter->build_import_methods(
59 class => ['Foo::Trait::Class'],
60 attribute => ['Foo::Trait::Attribute'],
62 base_class_roles => ['Foo::Role::Base'],
63 install => [qw(import unimport)],
69 ::pass('custom init_meta was called');
70 Moose->init_meta(%options);
71 return $package->$init_meta(%options);
77 Foo::Exporter::WithMoose->import;
79 has(foo => (is => 'ro'));
81 ::isa_ok('Foo2', 'Moose::Object');
82 ::isa_ok(Foo2->meta, 'Moose::Meta::Class');
83 ::does_ok(Foo2->meta, 'Foo::Trait::Class');
84 ::does_ok(Foo2->meta->get_attribute('foo'), 'Foo::Trait::Attribute');
85 ::does_ok('Foo2', 'Foo::Role::Base');
91 Foo::Exporter->import;
93 ::does_ok(Foo::Role->meta, 'Foo::Trait::Class');
97 package Foo::Exporter::WithMooseRole;
101 my ( $import, $unimport, $init_meta )
102 = Moose::Exporter->build_import_methods(
103 also => 'Moose::Role',
105 role => ['Foo::Trait::Class'],
106 attribute => ['Foo::Trait::Attribute'],
108 install => [qw(import unimport)],
114 ::pass('custom init_meta was called');
115 Moose::Role->init_meta(%options);
116 return $package->$init_meta(%options);
122 Foo::Exporter::WithMooseRole->import;
124 ::isa_ok(Foo2::Role->meta, 'Moose::Meta::Role');
125 ::does_ok(Foo2::Role->meta, 'Foo::Trait::Class');