2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
10 $TODO = q{Mouse is not yet completed};
16 A fair amount of these tests will likely be irrelevant
17 once we have more fine grained control over the class
18 building process. A lot of the edge cases tested here
19 are actually related to class construction order and
20 not any real functionality.
23 Role which requires a method implemented
24 in another role as an override (it does
25 not remove the requirement)
30 package Role::RequireFoo;
37 package Role::ProvideFoo;
43 with 'Role::RequireFoo';
44 } '... the required "foo" method will not exist yet (but we will live)';
46 override 'foo' => sub { 'Role::ProvideFoo::foo' };
50 [ Role::ProvideFoo->meta->get_required_method_list ],
52 '... foo method is still required for Role::ProvideFoo');
56 Role which requires a method implemented
57 in the consuming class as an override.
58 It will fail since method modifiers are
59 second class citizens.
64 package Class::ProvideFoo::Base;
67 sub foo { 'Class::ProvideFoo::Base::foo' }
69 package Class::ProvideFoo::Override1;
72 extends 'Class::ProvideFoo::Base';
75 with 'Role::RequireFoo';
76 } '... the required "foo" method will be found in the superclass';
78 override 'foo' => sub { 'Class::ProvideFoo::foo' };
80 package Class::ProvideFoo::Override2;
83 extends 'Class::ProvideFoo::Base';
85 override 'foo' => sub { 'Class::ProvideFoo::foo' };
88 with 'Role::RequireFoo';
89 } '... the required "foo" method exists, although it is overriden locally';
95 Now same thing, but with a before
101 package Class::ProvideFoo::Before1;
104 extends 'Class::ProvideFoo::Base';
107 with 'Role::RequireFoo';
108 } '... the required "foo" method will be found in the superclass';
110 before 'foo' => sub { 'Class::ProvideFoo::foo:before' };
112 package Class::ProvideFoo::Before2;
115 extends 'Class::ProvideFoo::Base';
117 before 'foo' => sub { 'Class::ProvideFoo::foo:before' };
120 with 'Role::RequireFoo';
121 } '... the required "foo" method exists, although it is a before modifier locally';
123 package Class::ProvideFoo::Before3;
126 extends 'Class::ProvideFoo::Base';
128 sub foo { 'Class::ProvideFoo::foo' }
129 before 'foo' => sub { 'Class::ProvideFoo::foo:before' };
132 with 'Role::RequireFoo';
133 } '... the required "foo" method exists locally, and it is modified locally';
135 package Class::ProvideFoo::Before4;
138 extends 'Class::ProvideFoo::Base';
140 sub foo { 'Class::ProvideFoo::foo' }
141 before 'foo' => sub { 'Class::ProvideFoo::foo:before' };
143 ::isa_ok(__PACKAGE__->meta->get_method('foo'), 'Mouse::Meta::Method');
144 ::is(__PACKAGE__->meta->get_method('foo')->get_original_method->package_name, __PACKAGE__,
145 '... but the original method is from our package');
148 with 'Role::RequireFoo';
149 } '... the required "foo" method exists in the symbol table (and we will live)';
155 Now same thing, but with a method from an attribute
162 package Class::ProvideFoo::Attr1;
165 extends 'Class::ProvideFoo::Base';
168 with 'Role::RequireFoo';
169 } '... the required "foo" method will be found in the superclass (but then overriden)';
171 has 'foo' => (is => 'ro');
173 package Class::ProvideFoo::Attr2;
176 extends 'Class::ProvideFoo::Base';
178 has 'foo' => (is => 'ro');
181 with 'Role::RequireFoo';
182 } '... the required "foo" method exists, and is an accessor';
186 # a method required in a role, but then
187 # implemented in the superclass (as an
188 # attribute accessor too)
191 package Foo::Class::Base;
210 default => sub { (shift)->bar + 1 }
214 package Foo::Class::Child;
216 extends 'Foo::Class::Base';
220 } '... our role combined successfully';
223 # a method required in a role and implemented in a superclass, with a method
224 # modifier in the subclass. this should live, but dies in 0.26 -- hdp,
228 package Bar::Class::Base;
239 package Bar::Class::Child;
241 extends 'Bar::Class::Base';
242 after bar => sub { "o noes" };
243 # technically we could run lives_ok here, too, but putting it into a
244 # grandchild class makes it more obvious why this matters.
247 package Bar::Class::Grandchild;
249 extends 'Bar::Class::Child';
252 } 'required method exists in superclass as non-modifier, so we live';
256 package Bar2::Class::Base;
267 package Bar2::Class::Child;
269 extends 'Bar2::Class::Base';
270 override bar => sub { "o noes" };
271 # technically we could run lives_ok here, too, but putting it into a
272 # grandchild class makes it more obvious why this matters.
275 package Bar2::Class::Grandchild;
277 extends 'Bar2::Class::Child';
280 } 'required method exists in superclass as non-modifier, so we live';