From: Stevan Little Date: Thu, 20 Apr 2006 19:28:25 +0000 (+0000) Subject: fixes X-Git-Tag: 0_26~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8048fe76388270488ccaf9515bbc54a1f28d44fb;p=gitmo%2FClass-MOP.git fixes --- diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 866e6e8..09220ff 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -406,13 +406,13 @@ L report on this module's test suite. ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ - Class/MOP.pm 100.0 100.0 100.0 100.0 n/a 10.5 100.0 - Class/MOP/Attribute.pm 100.0 100.0 91.7 73.8 100.0 30.3 92.1 - Class/MOP/Class.pm 99.6 93.5 82.3 98.2 100.0 52.5 95.5 - Class/MOP/Method.pm 100.0 53.6 52.9 80.0 100.0 5.4 83.3 - metaclass.pm 100.0 100.0 80.0 100.0 n/a 1.4 97.4 + Class/MOP.pm 100.0 100.0 100.0 100.0 n/a 9.6 100.0 + Class/MOP/Attribute.pm 100.0 100.0 91.7 73.8 100.0 28.4 92.1 + Class/MOP/Class.pm 100.0 93.5 82.3 98.2 100.0 56.6 95.7 + Class/MOP/Method.pm 100.0 64.3 52.9 80.0 100.0 3.5 85.3 + metaclass.pm 100.0 100.0 80.0 100.0 n/a 1.9 97.4 ---------------------------- ------ ------ ------ ------ ------ ------ ------ - Total 99.8 89.3 79.7 86.2 100.0 100.0 93.3 + Total 100.0 90.8 79.7 86.2 100.0 100.0 93.6 ---------------------------- ------ ------ ------ ------ ------ ------ ------ =head1 ACKNOWLEDGEMENTS diff --git a/t/004_advanced_methods.t b/t/004_advanced_methods.t index 7ae9019..4a091d3 100644 --- a/t/004_advanced_methods.t +++ b/t/004_advanced_methods.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 14; use Test::Exception; BEGIN { @@ -53,6 +53,25 @@ A more real-world example would be a nice addition :) sub foobarbaz { 'Foo::Bar::Baz::foobarbaz' } } +ok(!defined(Class::MOP::Class->initialize('Foo')->find_next_method_by_name('BUILD')), + '... Foo::BUILD has not next method'); + +is(Class::MOP::Class->initialize('Bar')->find_next_method_by_name('BUILD'), + Class::MOP::Class->initialize('Foo')->get_method('BUILD'), + '... Bar::BUILD does have a next method'); + +is(Class::MOP::Class->initialize('Baz')->find_next_method_by_name('BUILD'), + Class::MOP::Class->initialize('Bar')->get_method('BUILD'), + '... Baz->BUILD does have a next method'); + +is(Class::MOP::Class->initialize('Foo::Bar')->find_next_method_by_name('BUILD'), + Class::MOP::Class->initialize('Foo')->get_method('BUILD'), + '... Foo::Bar->BUILD does have a next method'); + +is(Class::MOP::Class->initialize('Foo::Bar::Baz')->find_next_method_by_name('BUILD'), + Class::MOP::Class->initialize('Foo')->get_method('BUILD'), + '... Foo::Bar::Baz->BUILD does have a next method'); + is_deeply( [ sort { $a->{name} cmp $b->{name} } Class::MOP::Class->initialize('Foo')->compute_all_applicable_methods() ], [ diff --git a/t/030_method.t b/t/030_method.t index 89bc93e..f803363 100644 --- a/t/030_method.t +++ b/t/030_method.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 19; +use Test::More tests => 25; use Test::Exception; BEGIN { @@ -18,6 +18,14 @@ 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');