package MyRole; use Moo::Role; sub foo { $_[1] ? 'true' : 'false'; } __PACKAGE__ #### package MyClass; use warnings; use strict; use Moo; with 'MyRole'; around foo => sub { my $orig = shift; my $self = shift; my $value = $self->$orig(@_); return 'true' eq $value ? 'probably' : $value }; __PACKAGE__ #### #!/usr/bin/perl { package ConsumerOf::MyRole; use Moo; with 'MyRole'; } use Test::Spec; use Test::Exception; describe MyRole => sub { my $o; before each => sub { $o = 'ConsumerOf::MyRole'->new; }; it 'knows the foo method' => sub { lives_ok { $o->foo }; }; it 'foos truth' => sub { is $o->foo(1), 'true'; }; it 'foos false' => sub { is $o->foo(0), 'false'; }; }; runtests(); #### #! /usr/bin/perl use Test::Spec; use MyClass; describe MyClass => sub { my $o; before each => sub { $o = 'MyClass'->new; }; it 'instantiates' => sub { isa_ok $o, 'MyClass'; }; it 'returns false' => sub { is $o->foo(0), 'false'; }; it "isn't sure" => sub { is $o->foo(1), 'probably'; }; }; runtests(); #### ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,