X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F030_roles%2F008_role_conflict_edge_cases.t;h=4a6cee7b710b1745950f90b69c0d40f7fa1300ac;hb=f0b2e5673e864903e74a429565d0c57b69a60b95;hp=3ff06cddf9fa12dc67f0eb7485a32c0b0a46afd1;hpb=6549b0d1ae8b084898ac2d8ad60d6a57cccf4124;p=gitmo%2FMoose.git diff --git a/t/030_roles/008_role_conflict_edge_cases.t b/t/030_roles/008_role_conflict_edge_cases.t index 3ff06cd..4a6cee7 100644 --- a/t/030_roles/008_role_conflict_edge_cases.t +++ b/t/030_roles/008_role_conflict_edge_cases.t @@ -3,13 +3,13 @@ use strict; use warnings; -use Test::More tests => 32; -use Test::Exception; +use Test::More; +use Test::Fatal; =pod -Check for repeated inheritance causing -a method conflict (which is not really +Check for repeated inheritance causing +a method conflict (which is not really a conflict) =cut @@ -17,25 +17,25 @@ a conflict) { package Role::Base; use Moose::Role; - + sub foo { 'Role::Base::foo' } - + package Role::Derived1; - use Moose::Role; - + use Moose::Role; + with 'Role::Base'; - + package Role::Derived2; - use Moose::Role; + use Moose::Role; with 'Role::Base'; - + package My::Test::Class1; - use Moose; - - ::lives_ok { - with 'Role::Derived1', 'Role::Derived2'; - } '... roles composed okay (no conflicts)'; + use Moose; + + ::is( ::exception { + with 'Role::Derived1', 'Role::Derived2'; + }, undef, '... roles composed okay (no conflicts)' ); } ok(Role::Base->meta->has_method('foo'), '... have the method foo as expected'); @@ -47,8 +47,8 @@ is(My::Test::Class1->foo, 'Role::Base::foo', '... got the right value from metho =pod -Check for repeated inheritance causing -a method conflict with method modifiers +Check for repeated inheritance causing +a method conflict with method modifiers (which is not really a conflict) =cut @@ -56,39 +56,39 @@ a method conflict with method modifiers { package Role::Base2; use Moose::Role; - + override 'foo' => sub { super() . ' -> Role::Base::foo' }; - + package Role::Derived3; - use Moose::Role; - + use Moose::Role; + with 'Role::Base2'; - + package Role::Derived4; - use Moose::Role; + use Moose::Role; with 'Role::Base2'; package My::Test::Class2::Base; use Moose; - + sub foo { 'My::Test::Class2::Base' } - + package My::Test::Class2; - use Moose; - - extends 'My::Test::Class2::Base'; - - ::lives_ok { - with 'Role::Derived3', 'Role::Derived4'; - } '... roles composed okay (no conflicts)'; + use Moose; + + extends 'My::Test::Class2::Base'; + + ::is( ::exception { + with 'Role::Derived3', 'Role::Derived4'; + }, undef, '... roles composed okay (no conflicts)' ); } ok(Role::Base2->meta->has_override_method_modifier('foo'), '... have the method foo as expected'); ok(Role::Derived3->meta->has_override_method_modifier('foo'), '... have the method foo as expected'); ok(Role::Derived4->meta->has_override_method_modifier('foo'), '... have the method foo as expected'); ok(My::Test::Class2->meta->has_method('foo'), '... have the method foo as expected'); -isa_ok(My::Test::Class2->meta->get_method('foo'), 'Moose::Meta::Method::Overriden'); +isa_ok(My::Test::Class2->meta->get_method('foo'), 'Moose::Meta::Method::Overridden'); ok(My::Test::Class2::Base->meta->has_method('foo'), '... have the method foo as expected'); isa_ok(My::Test::Class2::Base->meta->get_method('foo'), 'Class::MOP::Method'); @@ -97,11 +97,11 @@ is(My::Test::Class2->foo, 'My::Test::Class2::Base -> Role::Base::foo', '... got =pod -Check for repeated inheritance of the -same code. There are no conflicts with +Check for repeated inheritance of the +same code. There are no conflicts with before/around/after method modifiers. -This tests around, but should work the +This tests around, but should work the same for before/afters as well =cut @@ -109,32 +109,32 @@ same for before/afters as well { package Role::Base3; use Moose::Role; - + around 'foo' => sub { 'Role::Base::foo(' . (shift)->() . ')' }; - + package Role::Derived5; - use Moose::Role; - + use Moose::Role; + with 'Role::Base3'; - + package Role::Derived6; - use Moose::Role; + use Moose::Role; with 'Role::Base3'; package My::Test::Class3::Base; use Moose; - + sub foo { 'My::Test::Class3::Base' } - + package My::Test::Class3; - use Moose; - - extends 'My::Test::Class3::Base'; - - ::lives_ok { - with 'Role::Derived5', 'Role::Derived6'; - } '... roles composed okay (no conflicts)'; + use Moose; + + extends 'My::Test::Class3::Base'; + + ::is( ::exception { + with 'Role::Derived5', 'Role::Derived6'; + }, undef, '... roles composed okay (no conflicts)' ); } ok(Role::Base3->meta->has_around_method_modifiers('foo'), '... have the method foo as expected'); @@ -150,8 +150,8 @@ is(My::Test::Class3->foo, 'Role::Base::foo(My::Test::Class3::Base)', '... got th =pod -Check for repeated inheritance causing -a attr conflict (which is not really +Check for repeated inheritance causing +a attr conflict (which is not really a conflict) =cut @@ -159,25 +159,25 @@ a conflict) { package Role::Base4; use Moose::Role; - + has 'foo' => (is => 'ro', default => 'Role::Base::foo'); - + package Role::Derived7; - use Moose::Role; - + use Moose::Role; + with 'Role::Base4'; - + package Role::Derived8; - use Moose::Role; + use Moose::Role; with 'Role::Base4'; - + package My::Test::Class4; - use Moose; - - ::lives_ok { - with 'Role::Derived7', 'Role::Derived8'; - } '... roles composed okay (no conflicts)'; + use Moose; + + ::is( ::exception { + with 'Role::Derived7', 'Role::Derived8'; + }, undef, '... roles composed okay (no conflicts)' ); } ok(Role::Base4->meta->has_attribute('foo'), '... have the attribute foo as expected'); @@ -186,3 +186,5 @@ ok(Role::Derived8->meta->has_attribute('foo'), '... have the attribute foo as ex ok(My::Test::Class4->meta->has_attribute('foo'), '... have the attribute foo as expected'); is(My::Test::Class4->new->foo, 'Role::Base::foo', '... got the right value from method'); + +done_testing;