Changelogging
[gitmo/Mouse.git] / t-failing / 030_roles / 024_role_composition_methods.t
1 #!/usr/bin/perl
2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
5
6 use strict;
7 use warnings;
8
9 use Test::More;
10 $TODO = q{Mouse is not yet completed};
11 use Test::Exception;
12
13 use Mouse::Meta::Role::Application;
14 use Mouse::Meta::Role::Composite;
15
16 {
17     package Role::Foo;
18     use Mouse::Role;
19
20     sub foo { 'Role::Foo::foo' }
21
22     package Role::Bar;
23     use Mouse::Role;
24
25     sub bar { 'Role::Bar::bar' }
26
27     package Role::FooConflict;
28     use Mouse::Role;
29
30     sub foo { 'Role::FooConflict::foo' }
31
32     package Role::BarConflict;
33     use Mouse::Role;
34
35     sub bar { 'Role::BarConflict::bar' }
36
37     package Role::AnotherFooConflict;
38     use Mouse::Role;
39     with 'Role::FooConflict';
40
41     sub baz { 'Role::AnotherFooConflict::baz' }
42 }
43
44 # test simple attributes
45 {
46     my $c = Mouse::Meta::Role::Composite->new(
47         roles => [
48             Role::Foo->meta,
49             Role::Bar->meta,
50         ]
51     );
52     isa_ok($c, 'Mouse::Meta::Role::Composite');
53
54     is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name');
55
56     lives_ok {
57         Mouse::Meta::Role::Application->new->apply($c);
58     } '... this succeeds as expected';
59
60     is_deeply(
61         [ sort $c->get_method_list ],
62         [ 'bar', 'foo' ],
63         '... got the right list of methods'
64     );
65 }
66
67 # test simple conflict
68 {
69     my $c = Mouse::Meta::Role::Composite->new(
70         roles => [
71             Role::Foo->meta,
72             Role::FooConflict->meta,
73         ]
74     );
75     isa_ok($c, 'Mouse::Meta::Role::Composite');
76
77     is($c->name, 'Role::Foo|Role::FooConflict', '... got the composite role name');
78
79     lives_ok {
80         Mouse::Meta::Role::Application->new->apply($c);
81     } '... this succeeds as expected';
82
83     is_deeply(
84         [ sort $c->get_method_list ],
85         [],
86         '... got the right list of methods'
87     );
88
89     is_deeply(
90         [ sort $c->get_required_method_list ],
91         [ 'foo' ],
92         '... got the right list of required methods'
93     );
94 }
95
96 # test complex conflict
97 {
98     my $c = Mouse::Meta::Role::Composite->new(
99         roles => [
100             Role::Foo->meta,
101             Role::Bar->meta,
102             Role::FooConflict->meta,
103             Role::BarConflict->meta,
104         ]
105     );
106     isa_ok($c, 'Mouse::Meta::Role::Composite');
107
108     is($c->name, 'Role::Foo|Role::Bar|Role::FooConflict|Role::BarConflict', '... got the composite role name');
109
110     lives_ok {
111         Mouse::Meta::Role::Application->new->apply($c);
112     } '... this succeeds as expected';
113
114     is_deeply(
115         [ sort $c->get_method_list ],
116         [],
117         '... got the right list of methods'
118     );
119
120     is_deeply(
121         [ sort $c->get_required_method_list ],
122         [ 'bar', 'foo' ],
123         '... got the right list of required methods'
124     );
125 }
126
127 # test simple conflict
128 {
129     my $c = Mouse::Meta::Role::Composite->new(
130         roles => [
131             Role::Foo->meta,
132             Role::AnotherFooConflict->meta,
133         ]
134     );
135     isa_ok($c, 'Mouse::Meta::Role::Composite');
136
137     is($c->name, 'Role::Foo|Role::AnotherFooConflict', '... got the composite role name');
138
139     lives_ok {
140         Mouse::Meta::Role::Application->new->apply($c);
141     } '... this succeeds as expected';
142
143     is_deeply(
144         [ sort $c->get_method_list ],
145         [ 'baz' ],
146         '... got the right list of methods'
147     );
148
149     is_deeply(
150         [ sort $c->get_required_method_list ],
151         [ 'foo' ],
152         '... got the right list of required methods'
153     );
154 }
155
156 done_testing;