Subject: | Method conflicts and superclasses - differs from Moose/Mouse |
Role::Tiny (and thus Moo::Role) differs from Moose in how it treats superclass methods when resolving role method conflicts.
Mouse used to behave the same as Role::Tiny/Moo::Role, but since 2.0.0 has followed the Moose way (albeit with a loud and unpleasant warning!)
The difference in behaviour should either be fixed, or noted in documentation.
Subject: | moose-conflict-resolved-by-superclass.t |
use strict;
use warnings;
use Test::More;
{
package Role::Foo1;
use Moose::Role;
sub foo { 'foo1' }
package Role::Foo2;
use Moose::Role;
sub foo { 'foo2' }
package BarSuper;
use Moose;
sub foo { 'foo3' }
package BarSub;
use Moose;
extends qw(BarSuper);
with 'Role::Foo1', 'Role::Foo2';
}
is(BarSub->new->foo, "foo3");
done_testing;
Subject: | mouse-conflict-resolved-by-superclass.t |
use strict;
use warnings;
use Test::More;
{
package Role::Foo1;
use Mouse::Role;
sub foo { 'foo1' }
package Role::Foo2;
use Mouse::Role;
sub foo { 'foo2' }
package BarSuper;
use Mouse;
sub foo { 'foo3' }
package BarSub;
use Mouse 2;
extends qw(BarSuper);
with 'Role::Foo1', 'Role::Foo2';
}
is(BarSub->new->foo, "foo3");
done_testing;
Subject: | role-tiny-conflict-resolved-by-superclass.t |
use strict;
use warnings;
use Test::More;
{
package Role::Foo1;
use Role::Tiny;
sub foo { 'foo1' }
package Role::Foo2;
use Role::Tiny;
sub foo { 'foo2' }
package BarSuper;
sub new { bless [], shift };
sub foo { 'foo3' }
package BarSub;
use parent -norequire, qw(BarSuper);
use Role::Tiny::With;
with 'Role::Foo1', 'Role::Foo2';
}
is(BarSub->new->foo, "foo3");
done_testing;