X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F030_method.t;h=f803363289a0cc1fb4d1217dfe822bdb7a775a46;hb=78d9bb3863ec6ddf5537fc9913fba3b170a8b88d;hp=de488519bfe9fe70737a517316b8de60c4245bf2;hpb=aa448b163f4882fc3e4b92a1c1f22e3c9ad9f933;p=gitmo%2FClass-MOP.git diff --git a/t/030_method.t b/t/030_method.t index de48851..f803363 100644 --- a/t/030_method.t +++ b/t/030_method.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 25; use Test::Exception; BEGIN { @@ -11,19 +11,33 @@ BEGIN { use_ok('Class::MOP::Method'); } +my $method = Class::MOP::Method->wrap(sub { 1 }); +is($method->meta, Class::MOP::Method->meta, '... instance and class both lead to the same meta'); + +is($method->package_name, 'main', '... our package is main::'); +is($method->name, '__ANON__', '... our sub name is __ANON__'); +is($method->fully_qualified_name, 'main::__ANON__', '... our subs full name is main::__ANON__'); + +dies_ok { Class::MOP::Method->wrap } '... cant call this method without some code'; +dies_ok { Class::MOP::Method->wrap([]) } '... cant call this method without some code'; +dies_ok { Class::MOP::Method->wrap(bless {} => 'Fail') } '... cant call this method without some code'; + +dies_ok { Class::MOP::Method->name } '... cant call this method with a class'; +dies_ok { Class::MOP::Method->package_name } '... cant call this method with a class'; +dies_ok { Class::MOP::Method->fully_qualified_name } '... cant call this method with a class'; + my $meta = Class::MOP::Method->meta; isa_ok($meta, 'Class::MOP::Class'); - -{ - my $meta = Class::MOP::Method->meta(); - isa_ok($meta, 'Class::MOP::Class'); - - foreach my $method_name (qw( - wrap - )) { - ok($meta->has_method($method_name), '... Class::MOP::Method->has_method(' . $method_name . ')'); - } +foreach my $method_name (qw( + wrap + package_name + name + )) { + ok($meta->has_method($method_name), '... Class::MOP::Method->has_method(' . $method_name . ')'); + my $method = $meta->get_method($method_name); + is($method->package_name, 'Class::MOP::Method', '... our package is Class::MOP::Method'); + is($method->name, $method_name, '... our sub name is "' . $method_name . '"'); } dies_ok {