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;
14 Check for repeated inheritance causing
15 a method conflict (which is not really
24 sub foo { 'Role::Base::foo' }
26 package Role::Derived1;
31 package Role::Derived2;
36 package My::Test::Class1;
40 with 'Role::Derived1', 'Role::Derived2';
41 } '... roles composed okay (no conflicts)';
44 ok(Role::Base->meta->has_method('foo'), '... have the method foo as expected');
45 ok(Role::Derived1->meta->has_method('foo'), '... have the method foo as expected');
46 ok(Role::Derived2->meta->has_method('foo'), '... have the method foo as expected');
47 ok(My::Test::Class1->meta->has_method('foo'), '... have the method foo as expected');
49 is(My::Test::Class1->foo, 'Role::Base::foo', '... got the right value from method');
53 Check for repeated inheritance causing
54 a method conflict with method modifiers
55 (which is not really a conflict)
63 override 'foo' => sub { super() . ' -> Role::Base::foo' };
65 package Role::Derived3;
70 package Role::Derived4;
75 package My::Test::Class2::Base;
78 sub foo { 'My::Test::Class2::Base' }
80 package My::Test::Class2;
83 extends 'My::Test::Class2::Base';
86 with 'Role::Derived3', 'Role::Derived4';
87 } '... roles composed okay (no conflicts)';
90 ok(Role::Base2->meta->has_override_method_modifier('foo'), '... have the method foo as expected');
91 ok(Role::Derived3->meta->has_override_method_modifier('foo'), '... have the method foo as expected');
92 ok(Role::Derived4->meta->has_override_method_modifier('foo'), '... have the method foo as expected');
93 ok(My::Test::Class2->meta->has_method('foo'), '... have the method foo as expected');
94 isa_ok(My::Test::Class2->meta->get_method('foo'), 'Mouse::Meta::Method');
95 ok(My::Test::Class2::Base->meta->has_method('foo'), '... have the method foo as expected');
96 isa_ok(My::Test::Class2::Base->meta->get_method('foo'), 'Mouse::Meta::Method');
98 is(My::Test::Class2::Base->foo, 'My::Test::Class2::Base', '... got the right value from method');
99 is(My::Test::Class2->foo, 'My::Test::Class2::Base -> Role::Base::foo', '... got the right value from method');
103 Check for repeated inheritance of the
104 same code. There are no conflicts with
105 before/around/after method modifiers.
107 This tests around, but should work the
108 same for before/afters as well
116 around 'foo' => sub { 'Role::Base::foo(' . (shift)->() . ')' };
118 package Role::Derived5;
123 package Role::Derived6;
128 package My::Test::Class3::Base;
131 sub foo { 'My::Test::Class3::Base' }
133 package My::Test::Class3;
136 extends 'My::Test::Class3::Base';
139 with 'Role::Derived5', 'Role::Derived6';
140 } '... roles composed okay (no conflicts)';
143 ok(Role::Base3->meta->has_around_method_modifiers('foo'), '... have the method foo as expected');
144 ok(Role::Derived5->meta->has_around_method_modifiers('foo'), '... have the method foo as expected');
145 ok(Role::Derived6->meta->has_around_method_modifiers('foo'), '... have the method foo as expected');
146 ok(My::Test::Class3->meta->has_method('foo'), '... have the method foo as expected');
147 isa_ok(My::Test::Class3->meta->get_method('foo'), 'Mouse::Meta::Method');
148 ok(My::Test::Class3::Base->meta->has_method('foo'), '... have the method foo as expected');
149 isa_ok(My::Test::Class3::Base->meta->get_method('foo'), 'Mouse::Meta::Method');
151 is(My::Test::Class3::Base->foo, 'My::Test::Class3::Base', '... got the right value from method');
152 is(My::Test::Class3->foo, 'Role::Base::foo(My::Test::Class3::Base)', '... got the right value from method');
156 Check for repeated inheritance causing
157 a attr conflict (which is not really
166 has 'foo' => (is => 'ro', default => 'Role::Base::foo');
168 package Role::Derived7;
173 package Role::Derived8;
178 package My::Test::Class4;
182 with 'Role::Derived7', 'Role::Derived8';
183 } '... roles composed okay (no conflicts)';
186 ok(Role::Base4->meta->has_attribute('foo'), '... have the attribute foo as expected');
187 ok(Role::Derived7->meta->has_attribute('foo'), '... have the attribute foo as expected');
188 ok(Role::Derived8->meta->has_attribute('foo'), '... have the attribute foo as expected');
189 ok(My::Test::Class4->meta->has_attribute('foo'), '... have the attribute foo as expected');
191 is(My::Test::Class4->new->foo, 'Role::Base::foo', '... got the right value from method');