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