Merge 'Moose-moosex_compile_support' into 'trunk'
[gitmo/Moose.git] / t / 030_roles / 012_method_exclusion_during_composition.t
CommitLineData
c4538447 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More no_plan => 1;
7use Test::Exception;
8
9BEGIN {
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
27ok(My::Class->meta->has_method($_), "we have a $_ method") for qw(foo baz);
28ok(!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
40ok(My::OtherRole->meta->has_method($_), "we have a $_ method") for qw(foo bar baz);
41
42ok(!My::OtherRole->meta->requires_method('foo'), '... and the &foo method is not required');
43ok(My::OtherRole->meta->requires_method('bar'), '... and the &bar method is required');
44
45
46
47
48