bump version to 2.0801
[gitmo/Moose.git] / t / roles / role_composition_conflict_detection.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Fatal;
6
7 use Moose::Util qw( find_meta );
8
9 {
10     package RoleA;
11     use Moose::Role;
12
13     sub foo { 42 }
14 }
15
16 {
17     package RoleB;
18     use Moose::Role;
19
20     with 'RoleA';
21 }
22
23 {
24     package RoleC;
25     use Moose::Role;
26
27     sub foo { 84 }
28 }
29
30 {
31     my $composite
32         = Moose::Meta::Role->combine( map { [ find_meta($_) => {} ] }
33             qw( RoleA RoleB RoleC ) );
34     ok( $composite->requires_method('foo'), 'Composite of [ABC] requires a foo method' );
35     ok( ! $composite->has_method('foo'), 'Composite of [ABC] does not also have a foo method' );
36 }
37
38 {
39     my $composite
40         = Moose::Meta::Role->combine( map { [ find_meta($_) => {} ] }
41             qw( RoleA RoleC RoleB ) );
42     ok( $composite->requires_method('foo'), 'Composite of [ACB] requires a foo method' );
43     ok( ! $composite->has_method('foo'), 'Composite of [ACB] does not also have a foo method' );
44 }
45
46 done_testing;