fix coderef naming to avoid confusing autoclean
[gitmo/Moo.git] / xt / moo-roles-into-moose-class.t
CommitLineData
7127b94e 1use strict;
04c82717 2use warnings;
7127b94e 3use Test::More;
04c82717 4
7127b94e 5{
6 package Foo;
7 use Moo::Role;
167455a0 8 # if we autoclean here there's nothing left and then load_class tries
9 # to require Foo during Moose application and everything breaks.
7127b94e 10}
11{
12 package Bar;
13 use Moo::Role;
14 use namespace::autoclean;
04c82717 15
16 has attr => (
17 is => 'ro'
18 );
19
20 sub thing {}
7127b94e 21}
22{
04c82717 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');
167455a0 33::ok(!Bar->can('has'), 'Moo::Role sugar removed by autoclean');
34::ok(!Bar->can('with'), 'Role::Tiny sugar removed by autoclean');
04c82717 35::ok(!Baz->can('has'), 'Sugar not copied');
36
37{
7127b94e 38 package Bax;
39 use Moose;
40 with qw/
41 Foo
42 Bar
43 /;
44}
45
46ok 1;
47done_testing;
48