Commit | Line | Data |
89e9bce8 |
1 | use strictures 1; |
2 | use Test::More; |
3 | |
4 | use 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 | |
29 | my $bar = Bar->new; |
30 | |
31 | ok(!$ModifyFoo::before_ran, 'before has not run yet'); |
32 | ok(!$ModifyFoo::after_ran, 'after has not run yet'); |
33 | ok(!$ModifyFoo::around_ran, 'around has not run yet'); |
34 | $bar->foo; |
35 | ok($ModifyFoo::before_ran, 'before ran'); |
36 | ok($ModifyFoo::after_ran, 'after ran'); |
37 | ok($ModifyFoo::around_ran, 'around ran'); |
38 | |
39 | done_testing; |