use strict;
use warnings;
-use Test::More no_plan => 1;
+use Test::More tests => 8;
use Test::Exception;
-BEGIN {
- use_ok('Moose');
- use_ok('Moose::Meta::Role::Application::RoleSummation');
- use_ok('Moose::Meta::Role::Composite');
-}
+use Moose::Meta::Role::Application::RoleSummation;
+use Moose::Meta::Role::Composite;
{
package Role::Foo;
use Moose::Role;
-
+
override foo => sub { 'Role::Foo::foo' };
-
+
package Role::Bar;
use Moose::Role;
override bar => sub { 'Role::Bar::bar' };
-
+
package Role::FooConflict;
- use Moose::Role;
-
+ use Moose::Role;
+
override foo => sub { 'Role::FooConflict::foo' };
-
+
package Role::FooMethodConflict;
- use Moose::Role;
-
- sub foo { 'Role::FooConflict::foo' }
-
+ use Moose::Role;
+
+ sub foo { 'Role::FooConflict::foo' }
+
package Role::BarMethodConflict;
use Moose::Role;
-
+
sub bar { 'Role::BarConflict::bar' }
}
);
isa_ok($c, 'Moose::Meta::Role::Composite');
- is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name');
-
+ is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name');
+
lives_ok {
Moose::Meta::Role::Application::RoleSummation->new->apply($c);
- } '... this lives ok';
-
+ } '... this lives ok';
+
is_deeply(
[ sort $c->get_method_modifier_list('override') ],
[ 'bar', 'foo' ],
# test simple overrides w/ conflicts
dies_ok {
Moose::Meta::Role::Application::RoleSummation->new->apply(
- Moose::Meta::Role::Composite->new(
+ Moose::Meta::Role::Composite->new(
roles => [
Role::Foo->meta,
Role::FooMethodConflict->meta,
Moose::Meta::Role::Composite->new(
roles => [
Role::Foo->meta,
- Role::Bar->meta,
- Role::FooConflict->meta,
+ Role::Bar->meta,
+ Role::FooConflict->meta,
]
)
);
# test simple overrides w/ conflicts
dies_ok {
Moose::Meta::Role::Application::RoleSummation->new->apply(
- Moose::Meta::Role::Composite->new(
+ Moose::Meta::Role::Composite->new(
roles => [
Role::Foo->meta,
- Role::Bar->meta,
- Role::FooMethodConflict->meta,
+ Role::Bar->meta,
+ Role::FooMethodConflict->meta,
]
)
);