putting the method modifiers in roles back in, we have to maintain backwards compat...
[gitmo/Moose.git] / t / 041_role.t
index b4937e9..2758332 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 25;
+use Test::More tests => 35;
 use Test::Exception;
 
 BEGIN {  
@@ -31,15 +31,20 @@ words, should 'has_method' return true for them?
     
     sub foo { 'FooRole::foo' }
     sub boo { 'FooRole::boo' }    
-   
+    
+    before 'boo' => sub { "FooRole::boo:before" };
+    
+    after  'boo' => sub { "FooRole::boo:after1"  }; 
+    after  'boo' => sub { "FooRole::boo:after2"  };        
+    
+    around 'boo' => sub { "FooRole::boo:around" };  
+    
+    override 'bling' => sub { "FooRole::bling:override" };   
+    override 'fling' => sub { "FooRole::fling:override" };  
+    
     ::dies_ok { extends() } '... extends() is not supported';
-    ::dies_ok { augment() } '... augment() is not supported';
-    ::dies_ok { inner() } '... inner() is not supported';
-    ::dies_ok { overrides() } '... overrides() is not supported';
-    ::dies_ok { super() } '... super() is not supported';
-    ::dies_ok { after() } '... after() is not supported';
-    ::dies_ok { before() } '... before() is not supported';
-    ::dies_ok { around() } '... around() is not supported';
+    ::dies_ok { augment() } '... augment() is not supported';    
+    ::dies_ok { inner()   } '... inner() is not supported';        
 }
 
 my $foo_role = FooRole->meta;
@@ -87,3 +92,55 @@ is_deeply(
     { is => 'ro' },
     '... got the correct description of the baz attribute');
 
+# method modifiers
+
+ok($foo_role->has_before_method_modifiers('boo'), '... now we have a boo:before modifier');
+is(($foo_role->get_before_method_modifiers('boo'))[0]->(), 
+    "FooRole::boo:before", 
+    '... got the right method back');
+
+is_deeply(
+    [ $foo_role->get_method_modifier_list('before') ],
+    [ 'boo' ],
+    '... got the right list of before method modifiers');
+
+ok($foo_role->has_after_method_modifiers('boo'), '... now we have a boo:after modifier');
+is(($foo_role->get_after_method_modifiers('boo'))[0]->(), 
+    "FooRole::boo:after1", 
+    '... got the right method back');
+is(($foo_role->get_after_method_modifiers('boo'))[1]->(), 
+    "FooRole::boo:after2", 
+    '... got the right method back');    
+
+is_deeply(
+    [ $foo_role->get_method_modifier_list('after') ],
+    [ 'boo' ],
+    '... got the right list of after method modifiers');
+    
+ok($foo_role->has_around_method_modifiers('boo'), '... now we have a boo:around modifier');
+is(($foo_role->get_around_method_modifiers('boo'))[0]->(), 
+    "FooRole::boo:around", 
+    '... got the right method back');
+
+is_deeply(
+    [ $foo_role->get_method_modifier_list('around') ],
+    [ 'boo' ],
+    '... got the right list of around method modifiers');
+
+## overrides
+
+ok($foo_role->has_override_method_modifier('bling'), '... now we have a bling:override modifier');
+is($foo_role->get_override_method_modifier('bling')->(), 
+    "FooRole::bling:override", 
+    '... got the right method back');
+
+ok($foo_role->has_override_method_modifier('fling'), '... now we have a fling:override modifier');
+is($foo_role->get_override_method_modifier('fling')->(), 
+    "FooRole::fling:override", 
+    '... got the right method back');
+
+is_deeply(
+    [ sort $foo_role->get_method_modifier_list('override') ],
+    [ 'bling', 'fling' ],
+    '... got the right list of override method modifiers');
+