10 requires qw(req1 req2);
12 around foo => sub { my $orig = shift; join ' ', 'role foo', $orig->(@_) };
14 sub bar { 'role bar' }
16 sub baz { 'role baz' }
24 sub foo { 'class foo' }
25 sub baz { 'class baz' }
39 exception { Role::Tiny->apply_role_to_package('MyRole', $to) }
42 is(try_apply_to('MyClass'), undef, 'role applies cleanly');
43 is(MyClass->foo, 'role foo class foo', 'method modifier');
44 is(MyClass->bar, 'role bar', 'method from role');
45 is(MyClass->baz, 'class baz', 'method from class');
46 ok(MyClass->does('MyRole'), 'class does role');
47 ok(!MyClass->does('Random'), 'class does not do non-role');
49 like(try_apply_to('NoMethods'), qr/req1, req2/, 'error for both methods');
50 like(try_apply_to('OneMethod'), qr/req2/, 'error for one method');