From: Shawn M Moore Date: Wed, 30 Jul 2008 15:30:09 +0000 (+0000) Subject: Failing tests for method modifiers in a role X-Git-Tag: 0.19~229 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4fd5e34732f16f0dd449799378e9ec22cd93999d;p=gitmo%2FMouse.git Failing tests for method modifiers in a role --- diff --git a/t/403-method-modifiers.t b/t/403-method-modifiers.t new file mode 100644 index 0000000..67b0d6f --- /dev/null +++ b/t/403-method-modifiers.t @@ -0,0 +1,59 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 4; +use Test::Exception; + +my @calls; +my ($before, $after, $around); + +do { + package Role; + use Mouse::Role; + + $before = sub { + push @calls, 'Role::foo:before'; + }; + before foo => $before; + + $after = sub { + push @calls, 'Role::foo:after'; + }; + after foo => $after; + + $around = sub { + my $orig = shift; + push @calls, 'Role::foo:around_before'; + $orig->(@_); + push @calls, 'Role::foo:around_after'; + }; + around foo => $around; + + no Mouse::Role; +}; + +is_deeply([Role->meta->get_before_method_modifiers('foo')], [$before]); +is_deeply([Role->meta->get_after_method_modifiers('foo')], [$after]); +is_deeply([Role->meta->get_around_method_modifiers('foo')], [$around]); + +do { + package Class; + use Mouse; + with 'Role'; + + sub foo { + push @calls, 'Class::foo'; + } + + no Mouse; +}; + +Class->foo; +is_deeply([splice @calls], [ + 'Role::foo:before', + 'Role::foo:around_before', + 'Class::foo', + 'Role::foo:around_after', + 'Role::foo:after', +]); +