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