From: Stevan Little Date: Sun, 1 Jul 2007 21:22:01 +0000 (+0000) Subject: fixing some stuff X-Git-Tag: 0_24~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1db8ecc7a2e918d23aca2808ea79717a2a2a5a9a;p=gitmo%2FMoose.git fixing some stuff --- diff --git a/Changes b/Changes index be6bf34..b632be5 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ Revision history for Perl extension Moose +0.24 + * Moose::Meta::Role + - required methods are now fetched using find_method_by_name + so that required methods can come from superclasses + - adjusted tests for this + 0.23 Mon. June 18, 2007 * Moose::Meta::Method::Constructor - fix inlined constructor for hierarchy with multiple BUILD methods (mst) diff --git a/lib/Moose.pm b/lib/Moose.pm index 504e511..4921992 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -4,7 +4,7 @@ package Moose; use strict; use warnings; -our $VERSION = '0.23'; +our $VERSION = '0.24'; our $AUTHORITY = 'cpan:STEVAN'; use Scalar::Util 'blessed', 'reftype'; diff --git a/lib/Moose/Meta/Role.pm b/lib/Moose/Meta/Role.pm index c35f7cd..ada5450 100644 --- a/lib/Moose/Meta/Role.pm +++ b/lib/Moose/Meta/Role.pm @@ -9,7 +9,7 @@ use Carp 'confess'; use Scalar::Util 'blessed'; use B 'svref_2object'; -our $VERSION = '0.07'; +our $VERSION = '0.08'; our $AUTHORITY = 'cpan:STEVAN'; use Moose::Meta::Class; @@ -172,7 +172,7 @@ sub get_method_list { } (shift)->Moose::Meta::Class::get_method_list(@_) } -sub find_method_by_name { (shift)->has_method(@_) } +sub find_method_by_name { (shift)->get_method(@_) } # ... however the items in statis (attributes & method modifiers) # can be removed and added to through this API @@ -325,7 +325,7 @@ sub _check_required_methods { # we need to make sure that the method is # not a method modifier, because those do # not satisfy the requirements ... - my $method = $other->get_method($required_method_name); + my $method = $other->find_method_by_name($required_method_name); # check if it is an override or a generated accessor .. (!$method->isa('Moose::Meta::Method::Overriden') && !$method->isa('Class::MOP::Method::Accessor')) diff --git a/t/046_roles_and_required_method_edge_cases.t b/t/046_roles_and_required_method_edge_cases.t index 7191d54..f957530 100644 --- a/t/046_roles_and_required_method_edge_cases.t +++ b/t/046_roles_and_required_method_edge_cases.t @@ -6,6 +6,18 @@ use warnings; use Test::More tests => 18; use Test::Exception; +=pod + +NOTE: +A fair amount of these tests will likely be irrelevant +once we have more fine grained control over the class +building process. A lot of the edge cases tested here +are actually related to class construction order and +not any real functionality. +- SL + +=cut + BEGIN { use_ok('Moose'); use_ok('Moose::Role'); @@ -64,9 +76,9 @@ second class citizens. extends 'Class::ProvideFoo::Base'; - ::dies_ok { + ::lives_ok { with 'Role::RequireFoo'; - } '... the required "foo" method will not exist yet (and we will die)'; + } '... the required "foo" method will be found in the superclass'; override 'foo' => sub { 'Class::ProvideFoo::foo' }; @@ -96,9 +108,9 @@ method modifier. extends 'Class::ProvideFoo::Base'; - ::dies_ok { + ::lives_ok { with 'Role::RequireFoo'; - } '... the required "foo" method will not exist yet (and we will die)'; + } '... the required "foo" method will be found in the superclass'; before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; @@ -171,9 +183,9 @@ method modifier. extends 'Class::ProvideFoo::Base'; - ::dies_ok { + ::lives_ok { with 'Role::RequireFoo'; - } '... the required "foo" method will not exist yet (and we will die)'; + } '... the required "foo" method will be found in the superclass (but then overriden)'; has 'foo' => (is => 'ro');