Commit | Line | Data |
20725a2d |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | use Test::More tests => 2; |
5 | |
6 | my @calls; |
7 | |
8 | do { |
9 | package MyRole::LogMethod; |
10 | use MooseX::Role::Parameterized; |
11 | |
12 | parameter method => ( |
13 | is => 'rw', |
14 | isa => 'Str', |
15 | required => 1, |
16 | ); |
17 | |
18 | role { |
19 | my $p = shift; |
20 | |
21 | override $p->method => sub { |
22 | push @calls, "calling " . $p->method; |
23 | super; |
24 | push @calls, "called " . $p->method; |
25 | }; |
26 | }; |
27 | }; |
28 | |
29 | do { |
30 | package MyClass; |
31 | use Moose; |
32 | with 'MyRole::LogMethod' => { |
33 | method => 'new', |
34 | }; |
35 | }; |
36 | |
37 | is_deeply([splice @calls], [], "no calls yet"); |
38 | MyClass->new; |
39 | is_deeply([splice @calls], ["calling new", "called new"], "instrumented new"); |
40 | |