return; from with/etc.
[gitmo/Moo.git] / xt / moose-method-modifiers.t
CommitLineData
89e9bce8 1use strictures 1;
2use Test::More;
3
4use Moo::HandleMoose;
5
6{
cb35d359 7 package ModifyFoo;
89e9bce8 8 use Moo::Role;
9
10 our $before_ran = 0;
11 our $around_ran = 0;
12 our $after_ran = 0;
13
14 before foo => sub { $before_ran = 1 };
15 after foo => sub { $after_ran = 1 };
16 around foo => sub {
17 my ($orig, $self, @rest) = @_;
18 $self->$orig(@rest);
146fb407 19 $around_ran = 1;
89e9bce8 20 };
21
22 package Bar;
23 use Moose;
cb35d359 24 with 'ModifyFoo';
89e9bce8 25
26 sub foo { }
27}
28
29my $bar = Bar->new;
30
31ok(!$ModifyFoo::before_ran, 'before has not run yet');
32ok(!$ModifyFoo::after_ran, 'after has not run yet');
33ok(!$ModifyFoo::around_ran, 'around has not run yet');
34$bar->foo;
35ok($ModifyFoo::before_ran, 'before ran');
36ok($ModifyFoo::after_ran, 'after ran');
37ok($ModifyFoo::around_ran, 'around ran');
38
39done_testing;