6 use Test::More tests => 15;
13 "outer( " .( eval { inner() } || "" ). ")";
22 augment method => sub {
27 ::ok( !$@, "can call augment in a role that has the parent method" );
29 package ClassWithRole;
33 package ClassWithoutRole;
38 augment method => sub {
43 ::ok( !$@, "class can augment a method that comes from a role" );
45 package UnrelatedRole;
49 augment method => sub {
50 "inner from unrelated role";
54 ::ok( !$@, "can call augment in a role that has does not have the parent method" );
56 package ClassWithTwoRoles;
59 with qw/Base UnrelatedRole/;
62 foreach my $class (qw/ClassWithoutRole ClassWithRole ClassWithTwoRoles/) {
63 can_ok( $class, "method" );
65 ok( $class->does("Base"), "$class does Base" );
67 like( $class->method, qr/^outer\( .* \)$/, "outer method invoked" );
70 is( ClassWithoutRole->method, "outer( inner from class )", "composition of class + base role" );
71 is( ClassWithRole->method, "outer( inner from role )", "composition of class + base role + related role" );
72 is( ClassWithTwoRoles->method, "outer( inner from unrelated role )", "composition of class + base role + mixin role" );