14 sub foo { 'Foo::foo' }
15 sub bar { 'Foo::bar' }
16 sub baz { 'Foo::baz' }
21 with 'My::Role' => { -excludes => 'bar' };
24 ok(My::Class->meta->has_method($_), "we have a $_ method") for qw(foo baz);
25 ok(!My::Class->meta->has_method('bar'), '... but we excluded bar');
28 package My::OtherRole;
31 with 'My::Role' => { -excludes => 'foo' };
33 sub foo { 'My::OtherRole::foo' }
34 sub bar { 'My::OtherRole::bar' }
37 ok(My::OtherRole->meta->has_method($_), "we have a $_ method") for qw(foo bar baz);
39 ok(!My::OtherRole->meta->requires_method('foo'), '... and the &foo method is not required');
40 ok(My::OtherRole->meta->requires_method('bar'), '... and the &bar method is required');
46 sub foo { 'Foo::Role::foo' }
51 sub foo { 'Bar::Role::foo' }
56 sub foo { 'Baz::Role::foo' }
58 package My::Foo::Class;
62 with 'Foo::Role' => { -excludes => 'foo' },
63 'Bar::Role' => { -excludes => 'foo' },
65 }, undef, '... composed our roles correctly' );
67 package My::Foo::Class::Broken;
72 'Bar::Role' => { -excludes => 'foo' },
74 }, qr/Due to a method name conflict in roles 'Baz::Role' and 'Foo::Role', the method 'foo' must be implemented or excluded by 'My::Foo::Class::Broken'/, '... composed our roles correctly' );
78 my $foo = My::Foo::Class->new;
79 isa_ok($foo, 'My::Foo::Class');
81 is($foo->foo, 'Baz::Role::foo', '... got the right method');
85 package My::Foo::Role;
89 with 'Foo::Role' => { -excludes => 'foo' },
90 'Bar::Role' => { -excludes => 'foo' },
92 }, undef, '... composed our roles correctly' );
95 ok(My::Foo::Role->meta->has_method('foo'), "we have a foo method");
96 ok(!My::Foo::Role->meta->requires_method('foo'), '... and the &foo method is not required');
99 package My::Foo::Role::Other;
104 'Bar::Role' => { -excludes => 'foo' },
106 }, undef, '... composed our roles correctly' );
109 ok(!My::Foo::Role::Other->meta->has_method('foo'), "we dont have a foo method");
110 ok(My::Foo::Role::Other->meta->requires_method('foo'), '... and the &foo method is required');