fix for prototype undecl issue when type constraint utils loaded before consumers...
[gitmo/Moose.git] / t / 042_apply_role.t
index d41ba60..f94385e 100644 (file)
@@ -3,15 +3,13 @@
 use strict;
 use warnings;
 
-use Test::More tests => 33;
+use Test::More tests => 39;
 use Test::Exception;
 
 BEGIN {  
     use_ok('Moose::Role');               
 }
 
-
-
 {
     package FooRole;
     use Moose::Role;
@@ -21,20 +19,35 @@ BEGIN {
     
     sub goo { 'FooRole::goo' }
     sub foo { 'FooRole::foo' }
+    
+    override 'boo' => sub { 'FooRole::boo -> ' . super() };   
+    
+    around 'blau' => sub {  
+        my $c = shift;
+        'FooRole::blau -> ' . $c->();
+    }; 
 
+}{
     package BarClass;
     use Moose;
     
     sub boo { 'BarClass::boo' }
     sub foo { 'BarClass::foo' }  # << the role overrides this ...  
+
+    __PACKAGE__->meta->make_immutable(debug => 0);
+}{
     
     package FooClass;
     use Moose;
     
     extends 'BarClass';
        with 'FooRole';
+    
+    sub blau { 'FooClass::blau' }
 
     sub goo { 'FooClass::goo' }  # << overrides the one from the role ... 
+    
+    __PACKAGE__->meta->make_immutable(debug => 0);
 }
 
 my $foo_class_meta = FooClass->meta;
@@ -55,7 +68,7 @@ dies_ok {
 ok($foo_class_meta->does_role('FooRole'), '... the FooClass->meta does_role FooRole');
 ok(!$foo_class_meta->does_role('OtherRole'), '... the FooClass->meta !does_role OtherRole');
 
-foreach my $method_name (qw(bar baz foo goo)) {
+foreach my $method_name (qw(bar baz foo boo blau goo)) {
     ok($foo_class_meta->has_method($method_name), '... FooClass has the method ' . $method_name);    
 }
 
@@ -77,7 +90,9 @@ ok(!$foo->does('OtherRole'), '... and instance of FooClass does not do OtherRole
 can_ok($foo, 'bar');
 can_ok($foo, 'baz');
 can_ok($foo, 'foo');
+can_ok($foo, 'boo');
 can_ok($foo, 'goo');
+can_ok($foo, 'blau');
 
 is($foo->foo, 'FooRole::foo', '... got the right value of foo');
 is($foo->goo, 'FooClass::goo', '... got the right value of goo');
@@ -102,4 +117,6 @@ lives_ok {
 
 is($foo->bar, $foo2, '... got the right value for bar now');
 
+is($foo->boo, 'FooRole::boo -> BarClass::boo', '... got the right value from ->boo');
+is($foo->blau, 'FooRole::blau -> FooClass::blau', '... got the right value from ->blau');