added default {} keyword
[gitmo/Moose.git] / t / 044_role_conflict_detection.t
index d209244..712c491 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 90;
+use Test::More tests => 67;
 use Test::Exception;
 
 BEGIN {
@@ -19,8 +19,6 @@ Mutually recursive roles.
 
 {
     package Role::Foo;
-    use strict;
-    use warnings;
     use Moose::Role;
 
     requires 'foo';
@@ -28,8 +26,6 @@ Mutually recursive roles.
     sub bar { 'Role::Foo::bar' }
     
     package Role::Bar;
-    use strict;
-    use warnings;
     use Moose::Role;
     
     requires 'bar';
@@ -39,8 +35,6 @@ Mutually recursive roles.
 
 {
     package My::Test1;
-    use strict;
-    use warnings;
     use Moose;
     
     ::lives_ok {
@@ -48,8 +42,6 @@ Mutually recursive roles.
     } '... our mutually recursive roles combine okay';
     
     package My::Test2;
-    use strict;
-    use warnings;
     use Moose;
     
     ::lives_ok {
@@ -97,15 +89,11 @@ Role method conflicts
 
 {
     package Role::Bling;
-    use strict;
-    use warnings;
     use Moose::Role;
     
     sub bling { 'Role::Bling::bling' }
     
     package Role::Bling::Bling;
-    use strict;
-    use warnings;
     use Moose::Role;
     
     sub bling { 'Role::Bling::Bling::bling' }    
@@ -113,8 +101,6 @@ Role method conflicts
 
 {
     package My::Test3;
-    use strict;
-    use warnings;
     use Moose;
     
     ::throws_ok {
@@ -122,8 +108,6 @@ Role method conflicts
     } qr/requires the method \'bling\' to be implemented/, '... role methods conflicted and method was required';
     
     package My::Test4;
-    use strict;
-    use warnings;
     use Moose;
     
     ::lives_ok {
@@ -132,8 +116,6 @@ Role method conflicts
     } '... role methods didnt conflict when manually combined';    
     
     package My::Test5;
-    use strict;
-    use warnings;
     use Moose;
     
     ::lives_ok {
@@ -142,8 +124,6 @@ Role method conflicts
     } '... role methods didnt conflict when manually combined (in opposite order)';    
     
     package My::Test6;
-    use strict;
-    use warnings;
     use Moose;
     
     ::lives_ok {
@@ -175,8 +155,6 @@ is(My::Test6->bling, 'My::Test6::bling', '... and we got the local method');
 
 {
     package Role::Bling::Bling::Bling;
-    use strict;
-    use warnings;
     use Moose::Role;
     
     with 'Role::Bling::Bling';
@@ -199,15 +177,11 @@ Role attribute conflicts
 
 {
     package Role::Boo;
-    use strict;
-    use warnings;
     use Moose::Role;
     
     has 'ghost' => (is => 'ro', default => 'Role::Boo::ghost');
     
     package Role::Boo::Hoo;
-    use strict;
-    use warnings;
     use Moose::Role;
     
     has 'ghost' => (is => 'ro', default => 'Role::Boo::Hoo::ghost');
@@ -215,8 +189,6 @@ Role attribute conflicts
 
 {
     package My::Test7;
-    use strict;
-    use warnings;
     use Moose;
     
     ::throws_ok {
@@ -225,8 +197,6 @@ Role attribute conflicts
       '... role attrs conflicted and method was required';
 
     package My::Test8;
-    use strict;
-    use warnings;
     use Moose;
 
     ::lives_ok {
@@ -235,8 +205,6 @@ Role attribute conflicts
     } '... role attrs didnt conflict when manually combined';
     
     package My::Test9;
-    use strict;
-    use warnings;
     use Moose;
 
     ::lives_ok {
@@ -245,8 +213,6 @@ Role attribute conflicts
     } '... role attrs didnt conflict when manually combined';    
 
     package My::Test10;
-    use strict;
-    use warnings;
     use Moose;
     
     has 'ghost' => (is => 'ro', default => 'My::Test10::ghost');    
@@ -286,114 +252,3 @@ Role override method conflicts
 
 =cut
 
-{
-    package Role::Plot;
-    use strict;
-    use warnings;
-    use Moose::Role;
-    
-    override 'twist' => sub {
-        super() . ' -> Role::Plot::twist';
-    };
-    
-    package Role::Truth;
-    use strict;
-    use warnings;
-    use Moose::Role;
-    
-    override 'twist' => sub {
-        super() . ' -> Role::Truth::twist';
-    };
-}
-
-{
-    package My::Test::Base;
-    use strict;
-    use warnings;
-    use Moose;
-    
-    sub twist { 'My::Test::Base::twist' }
-        
-    package My::Test11;
-    use strict;
-    use warnings;
-    use Moose;
-    
-    extends 'My::Test::Base';
-
-    ::lives_ok {
-        with 'Role::Truth';
-    } '... composed the role with override okay';
-       
-    package My::Test12;
-    use strict;
-    use warnings;
-    use Moose;
-
-    extends 'My::Test::Base';
-
-    ::lives_ok {    
-       with 'Role::Plot';
-    } '... composed the role with override okay';
-              
-    package My::Test13;
-    use strict;
-    use warnings;
-    use Moose;
-
-    ::dies_ok {
-        with 'Role::Plot';       
-    } '... cannot compose it because we have no superclass';
-    
-    package My::Test14;
-    use strict;
-    use warnings;
-    use Moose;
-
-    extends 'My::Test::Base';
-
-    ::throws_ok {
-        with 'Role::Plot', 'Role::Truth';       
-    } qr/Two \'override\' methods of the same name encountered/, 
-      '... cannot compose it because we have no superclass';       
-}
-
-ok(My::Test11->meta->has_method('twist'), '... the twist method has been added');
-ok(My::Test12->meta->has_method('twist'), '... the twist method has been added');
-ok(!My::Test13->meta->has_method('twist'), '... the twist method has not been added');
-ok(!My::Test14->meta->has_method('twist'), '... the twist method has not been added');
-
-ok(!My::Test11->does('Role::Plot'), '... our class does() the correct roles');
-ok(My::Test11->does('Role::Truth'), '... our class does() the correct roles');
-ok(!My::Test12->does('Role::Truth'), '... our class does() the correct roles');
-ok(My::Test12->does('Role::Plot'), '... our class does() the correct roles');
-ok(!My::Test13->does('Role::Plot'), '... our class does() the correct roles');
-ok(!My::Test14->does('Role::Truth'), '... our class does() the correct roles');
-ok(!My::Test14->does('Role::Plot'), '... our class does() the correct roles');
-
-is(My::Test11->twist(), 'My::Test::Base::twist -> Role::Truth::twist', '... got the right method return');
-is(My::Test12->twist(), 'My::Test::Base::twist -> Role::Plot::twist', '... got the right method return');
-ok(!My::Test13->can('twist'), '... no twist method here at all');
-is(My::Test14->twist(), 'My::Test::Base::twist', '... got the right method return (from superclass)');
-
-{
-    package Role::Reality;
-    use strict;
-    use warnings;
-    use Moose::Role;
-
-    ::throws_ok {    
-        with 'Role::Plot';
-    } qr/A local method of the same name as been found/, 
-    '... could not compose roles here, it dies';
-
-    sub twist {
-        'Role::Reality::twist';
-    }
-}    
-
-ok(Role::Reality->meta->has_method('twist'), '... the twist method has not been added');
-ok(!Role::Reality->meta->does_role('Role::Plot'), '... our role does() the correct roles');
-is(Role::Reality->meta->get_method('twist')->(), 
-    'Role::Reality::twist', 
-    '... the twist method returns the right value');