X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F040_meta_role.t;h=c13b336e1995ad4469a999a7de97cabc975f8f2a;hb=03aac1fa4eb64aca574e5ec3b8f55c4f0327399c;hp=df706f3b693ac9651c03e6a562d5e021ad2f2a25;hpb=68efb0148447f7c638d4278e2d002bc3bb13cfbb;p=gitmo%2FMoose.git diff --git a/t/040_meta_role.t b/t/040_meta_role.t index df706f3..c13b336 100644 --- a/t/040_meta_role.t +++ b/t/040_meta_role.t @@ -3,10 +3,11 @@ use strict; use warnings; -use Test::More tests => 23; +use Test::More tests => 29; use Test::Exception; BEGIN { + use_ok('Moose'); use_ok('Moose::Meta::Role'); } @@ -28,7 +29,7 @@ is($foo_role->version, '0.01', '... got the right version of FooRole'); # methods ... ok($foo_role->has_method('foo'), '... FooRole has the foo method'); -is($foo_role->get_method('foo'), \&FooRole::foo, '... FooRole got the foo method'); +is($foo_role->get_method('foo')->body, \&FooRole::foo, '... FooRole got the foo method'); isa_ok($foo_role->get_method('foo'), 'Moose::Meta::Role::Method'); @@ -90,3 +91,19 @@ is_deeply( ok(!$foo_role->has_attribute('bar'), '... FooRole does not have the bar attribute'); ok($foo_role->has_attribute('baz'), '... FooRole does still have the baz attribute'); +# method modifiers + +ok(!$foo_role->has_before_method_modifiers('boo'), '... no boo:before modifier'); + +my $method = sub { "FooRole::boo:before" }; +lives_ok { + $foo_role->add_before_method_modifier('boo' => $method); +} '... added a method modifier okay'; + +ok($foo_role->has_before_method_modifiers('boo'), '... now we have a boo:before modifier'); +is(($foo_role->get_before_method_modifiers('boo'))[0], $method, '... got the right method back'); + +is_deeply( + [ $foo_role->get_method_modifier_list('before') ], + [ 'boo' ], + '... got the right list of before method modifiers');