X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=t%2Flib%2FTest%2FMouse.pm;h=2d46cbdb5040c5442576fe229c369adb7e3be577;hp=8d219dda5aabef6609226dc4753406bc29fc21c1;hb=431657256f423bda264c0cb76c28de72fd879b20;hpb=1b9e472d8c7e704eced9b2ea83194f83f0265018 diff --git a/t/lib/Test/Mouse.pm b/t/lib/Test/Mouse.pm index 8d219dd..2d46cbd 100644 --- a/t/lib/Test/Mouse.pm +++ b/t/lib/Test/Mouse.pm @@ -55,7 +55,49 @@ sub has_attribute_ok ($$;$) { # Moose compatible methods/functions -package Mouse::Util::TypeConstraints; +package + Mouse::Meta::Module; + +sub version { no strict 'refs'; ${shift->name.'::VERSION'} } +sub authority { no strict 'refs'; ${shift->name.'::AUTHORITY'} } +sub identifier { + my $self = shift; + return join '-' => ( + $self->name, + ($self->version || ()), + ($self->authority || ()), + ); +} + +package + Mouse::Meta::Role; + +for my $modifier_type (qw/before after around/) { + my $modifier = "${modifier_type}_method_modifiers"; + my $has_method_modifiers = sub{ + my($self, $method_name) = @_; + my $m = $self->{$modifier}->{$method_name}; + return $m && @{$m} != 0; + }; + + no strict 'refs'; + *{ 'has_' . $modifier_type . '_method_modifiers' } = $has_method_modifiers; +} + + +sub has_override_method_modifier { + my ($self, $method_name) = @_; + return exists $self->{override_method_modifiers}->{$method_name}; +} + +sub get_method_modifier_list { + my($self, $modifier_type) = @_; + + return keys %{ $self->{$modifier_type . '_method_modifiers'} }; +} + +package + Mouse::Util::TypeConstraints; use Mouse::Util::TypeConstraints (); @@ -63,7 +105,7 @@ sub export_type_constraints_as_functions { # TEST ONLY my $into = caller; foreach my $type( list_all_type_constraints() ) { - my $tc = find_type_constraint($type)->{_compiled_type_constraint}; + my $tc = find_type_constraint($type)->_compiled_type_constraint; my $as = $into . '::' . $type; no strict 'refs'; @@ -72,7 +114,8 @@ sub export_type_constraints_as_functions { # TEST ONLY return; } -package Mouse::Meta::Attribute; +package + Mouse::Meta::Attribute; sub applied_traits{ $_[0]->{traits} } # TEST ONLY sub has_applied_traits{ exists $_[0]->{traits} } # TEST ONLY