-{
+{
# test no conflicts here
package Role::A;
use Mouse::Role;
package Role::C;
use Mouse::Role;
-
+
::lives_ok {
with qw(Role::A Role::B); # no conflict here
} "define role C";
::lives_ok {
with qw(Role::C);
} "define class A";
-
+
sub zot { 'Class::A::zot' }
}
{
# check that when a role is added to another role
- # and they conflict and the method they conflicted
- # with is then required.
-
+ # and they conflict and the method they conflict
+ # with is then required.
+
package Role::A::Conflict;
use Mouse::Role;
-
+
with 'Role::A';
-
+
sub bar { 'Role::A::Conflict::bar' }
-
+
package Class::A::Conflict;
use Mouse;
-
+
::throws_ok {
with 'Role::A::Conflict';
- } qr/requires.*'bar'/, '... did not fufill the requirement of &bar method';
-
+ } qr/Due to a method name conflict in roles 'Role::A' and 'Role::A::Conflict', the method 'bar' must be implemented or excluded by 'Class::A::Conflict'/, '... did not fufill the requirement of &bar method';
+
package Class::A::Resolved;
use Mouse;
-
+
::lives_ok {
with 'Role::A::Conflict';
- } '... did fufill the requirement of &bar method';
-
+ } '... did fufill the requirement of &bar method';
+
sub bar { 'Class::A::Resolved::bar' }
}
{
# check that when two roles are composed, they conflict
# but the composing role can resolve that conflict
-
+
package Role::D;
use Mouse::Role;
sub foo { 'Role::D::foo' }
- sub bar { 'Role::D::bar' }
+ sub bar { 'Role::D::bar' }
package Role::E;
use Mouse::Role;
::lives_ok {
with qw(Role::D Role::E); # conflict between 'foo's here
} "define role Role::F";
-
+
sub foo { 'Role::F::foo' }
- sub zot { 'Role::F::zot' }
-
+ sub zot { 'Role::F::zot' }
+
package Class::B;
use Mouse;
-
+
::lives_ok {
with qw(Role::F);
} "define class Class::B";
-
+
sub zot { 'Class::B::zot' }
}
{
# check that a conflict can be resolved
- # by a role, but also new ones can be
+ # by a role, but also new ones can be
# created just as easily ...
-
+
package Role::D::And::E::Conflict;
use Mouse::Role;
::lives_ok {
with qw(Role::D Role::E); # conflict between 'foo's here
} "... define role Role::D::And::E::Conflict";
-
+
sub foo { 'Role::D::And::E::Conflict::foo' } # this overrides ...
-
- # but these conflict
- sub xxy { 'Role::D::And::E::Conflict::xxy' }
- sub bar { 'Role::D::And::E::Conflict::bar' }
+
+ # but these conflict
+ sub xxy { 'Role::D::And::E::Conflict::xxy' }
+ sub bar { 'Role::D::And::E::Conflict::bar' }
}
{
# conflict propagation
-
+
package Role::H;
use Mouse::Role;
sub foo { 'Role::H::foo' }
- sub bar { 'Role::H::bar' }
+ sub bar { 'Role::H::bar' }
package Role::J;
use Mouse::Role;
::lives_ok {
with qw(Role::J Role::H); # conflict between 'foo's here
} "define role Role::I";
-
+
sub zot { 'Role::I::zot' }
sub zzy { 'Role::I::zzy' }
package Class::C;
use Mouse;
-
+
::throws_ok {
with qw(Role::I);
- } qr/requires.*'foo'/, "defining class Class::C fails";
+ } qr/Due to a method name conflict in roles 'Role::H' and 'Role::J', the method 'foo' must be implemented or excluded by 'Class::C'/, "defining class Class::C fails";
sub zot { 'Class::C::zot' }
::lives_ok {
with qw(Role::I);
- } "resolved with method";
+ } "resolved with method";
sub foo { 'Class::E::foo' }
- sub zot { 'Class::E::zot' }
+ sub zot { 'Class::E::zot' }
}
can_ok( Class::E->new, qw(foo bar xxy zot) );