From: Arthur Axel 'fREW' Schmidt Date: Tue, 3 Apr 2012 22:29:38 +0000 (-0500) Subject: add method modifiers test X-Git-Tag: v0.009_015~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=89e9bce8367ed666bf20ccae7a32b8ee77ecab2d;p=gitmo%2FMoo.git add method modifiers test --- diff --git a/xt/moose-method-modifiers.t b/xt/moose-method-modifiers.t new file mode 100644 index 0000000..af9492d --- /dev/null +++ b/xt/moose-method-modifiers.t @@ -0,0 +1,38 @@ +use strictures 1; +use Test::More; + +use Moo::HandleMoose; + +{ + package ModifyFoo; + use Moo::Role; + + our $before_ran = 0; + our $around_ran = 0; + our $after_ran = 0; + + before foo => sub { $before_ran = 1 }; + after foo => sub { $after_ran = 1 }; + around foo => sub { + my ($orig, $self, @rest) = @_; + $self->$orig(@rest); + $after_ran = 1; + }; + + package Bar; + use Moose; + + sub foo { } +} + +my $bar = Bar->new; + +ok(!$ModifyFoo::before_ran, 'before has not run yet'); +ok(!$ModifyFoo::after_ran, 'after has not run yet'); +ok(!$ModifyFoo::around_ran, 'around has not run yet'); +$bar->foo; +ok($ModifyFoo::before_ran, 'before ran'); +ok($ModifyFoo::after_ran, 'after ran'); +ok($ModifyFoo::around_ran, 'around ran'); + +done_testing;