Commit | Line | Data |
c4538447 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More no_plan => 1; |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
10 | use_ok('Moose'); |
11 | } |
12 | |
13 | { |
14 | package My::Role; |
15 | use Moose::Role; |
16 | |
17 | sub foo { 'Foo::foo' } |
18 | sub bar { 'Foo::bar' } |
19 | sub baz { 'Foo::baz' } |
20 | |
21 | package My::Class; |
22 | use Moose; |
23 | |
24 | with 'My::Role' => { excludes => 'bar' }; |
25 | } |
26 | |
27 | ok(My::Class->meta->has_method($_), "we have a $_ method") for qw(foo baz); |
28 | ok(!My::Class->meta->has_method('bar'), '... but we excluded bar'); |
29 | |
30 | { |
31 | package My::OtherRole; |
32 | use Moose::Role; |
33 | |
34 | with 'My::Role' => { excludes => 'foo' }; |
35 | |
36 | sub foo { 'My::OtherRole::foo' } |
37 | sub bar { 'My::OtherRole::bar' } |
38 | } |
39 | |
40 | ok(My::OtherRole->meta->has_method($_), "we have a $_ method") for qw(foo bar baz); |
41 | |
42 | ok(!My::OtherRole->meta->requires_method('foo'), '... and the &foo method is not required'); |
43 | ok(My::OtherRole->meta->requires_method('bar'), '... and the &bar method is required'); |
44 | |
45 | |
46 | |
47 | |
48 | |