X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F031_method_modifiers.t;h=00f564a4af5ce7af5e9168299ae56589b7461625;hb=b88aa2e8d394623bfccf6eb8052dba12acf1e69a;hp=200b0453f443e6b1c2a416ca0ae949de5ed8bb29;hpb=3d2695646c17fca63e20186eeda494323b6aca02;p=gitmo%2FClass-MOP.git diff --git a/t/031_method_modifiers.t b/t/031_method_modifiers.t index 200b045..00f564a 100644 --- a/t/031_method_modifiers.t +++ b/t/031_method_modifiers.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 24; +use Test::More tests => 28; use Test::Exception; use Class::MOP; @@ -143,3 +143,68 @@ use Class::MOP::Method; ); } +# test introspection +{ + sub before1 { + } + + sub before2 { + } + + sub before3 { + } + + sub after1 { + } + + sub after2 { + } + + sub after3 { + } + + sub around1 { + } + + sub around2 { + } + + sub around3 { + } + + sub orig { + } + + my $method = Class::MOP::Method->wrap( + body => \&orig, + package_name => 'main', + name => '__ANON__', + ); + + my $wrapped = Class::MOP::Method::Wrapped->wrap($method); + + $wrapped->add_before_modifier($_) + for \&before1, \&before2, \&before3; + + $wrapped->add_after_modifier($_) + for \&after1, \&after2, \&after3; + + $wrapped->add_around_modifier($_) + for \&around1, \&around2, \&around3; + + is( $wrapped->get_original_method, $method, + 'check get_original_method' ); + + is_deeply( [ $wrapped->before_modifiers ], + [ \&before3, \&before2, \&before1 ], + 'check before_modifiers' ); + + is_deeply( [ $wrapped->after_modifiers ], + [ \&after1, \&after2, \&after3 ], + 'check after_modifiers' ); + + is_deeply( [ $wrapped->around_modifiers ], + [ \&around3, \&around2, \&around1 ], + 'check around_modifiers' ); +} +