fix coderef naming to avoid confusing autoclean
[gitmo/Moo.git] / xt / moo-roles-into-moose-class.t
1 use strict;
2 use warnings;
3 use Test::More;
4
5 {
6     package Foo;
7     use Moo::Role;
8     # if we autoclean here there's nothing left and then load_class tries
9     # to require Foo during Moose application and everything breaks.
10 }
11 {
12     package Bar;
13     use Moo::Role;
14     use namespace::autoclean;
15
16     has attr => (
17         is => 'ro'
18     );
19
20     sub thing {}
21 }
22 {
23     package Baz;
24     use Moose;
25     no Moose;
26
27     ::ok(!__PACKAGE__->can('has'), 'No has function after no Moose;');
28     Moose::with('Baz', 'Bar');
29 }
30
31 ::is(Baz->can('thing'), Bar->can('thing'), 'Role copies method correctly');
32 ::ok(Baz->can('attr'), 'Attr accessor correct');
33 ::ok(!Bar->can('has'), 'Moo::Role sugar removed by autoclean');
34 ::ok(!Bar->can('with'), 'Role::Tiny sugar removed by autoclean');
35 ::ok(!Baz->can('has'), 'Sugar not copied');
36
37 {
38     package Bax;
39     use Moose;
40     with qw/
41         Foo
42         Bar
43     /;
44 }
45
46 ok 1;
47 done_testing;
48