Commit | Line | Data |
67199842 |
1 | #!/usr/bin/perl |
fde8e43f |
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 | |
fde8e43f |
9 | use Test::More; |
10 | $TODO = q{Mouse is not yet completed}; |
67199842 |
11 | use Test::Exception; |
12 | |
fde8e43f |
13 | use Mouse::Meta::Role::Application; |
67199842 |
14 | use Mouse::Meta::Role::Composite; |
15 | |
16 | { |
17 | package Role::Foo; |
18 | use Mouse::Role; |
6cfa1e5e |
19 | |
20 | sub foo { 'Role::Foo::foo' } |
21 | |
67199842 |
22 | package Role::Bar; |
23 | use Mouse::Role; |
24 | |
25 | sub bar { 'Role::Bar::bar' } |
6cfa1e5e |
26 | |
67199842 |
27 | package Role::FooConflict; |
6cfa1e5e |
28 | use Mouse::Role; |
29 | |
30 | sub foo { 'Role::FooConflict::foo' } |
31 | |
67199842 |
32 | package Role::BarConflict; |
33 | use Mouse::Role; |
6cfa1e5e |
34 | |
67199842 |
35 | sub bar { 'Role::BarConflict::bar' } |
6cfa1e5e |
36 | |
67199842 |
37 | package Role::AnotherFooConflict; |
6cfa1e5e |
38 | use Mouse::Role; |
67199842 |
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 | |
6cfa1e5e |
54 | is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); |
55 | |
67199842 |
56 | lives_ok { |
fde8e43f |
57 | Mouse::Meta::Role::Application->new->apply($c); |
6cfa1e5e |
58 | } '... this succeeds as expected'; |
59 | |
67199842 |
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 | |
6cfa1e5e |
77 | is($c->name, 'Role::Foo|Role::FooConflict', '... got the composite role name'); |
78 | |
67199842 |
79 | lives_ok { |
fde8e43f |
80 | Mouse::Meta::Role::Application->new->apply($c); |
6cfa1e5e |
81 | } '... this succeeds as expected'; |
82 | |
67199842 |
83 | is_deeply( |
84 | [ sort $c->get_method_list ], |
85 | [], |
86 | '... got the right list of methods' |
6cfa1e5e |
87 | ); |
88 | |
67199842 |
89 | is_deeply( |
90 | [ sort $c->get_required_method_list ], |
91 | [ 'foo' ], |
92 | '... got the right list of required methods' |
6cfa1e5e |
93 | ); |
67199842 |
94 | } |
95 | |
96 | # test complex conflict |
97 | { |
98 | my $c = Mouse::Meta::Role::Composite->new( |
99 | roles => [ |
100 | Role::Foo->meta, |
6cfa1e5e |
101 | Role::Bar->meta, |
67199842 |
102 | Role::FooConflict->meta, |
6cfa1e5e |
103 | Role::BarConflict->meta, |
67199842 |
104 | ] |
105 | ); |
106 | isa_ok($c, 'Mouse::Meta::Role::Composite'); |
107 | |
6cfa1e5e |
108 | is($c->name, 'Role::Foo|Role::Bar|Role::FooConflict|Role::BarConflict', '... got the composite role name'); |
67199842 |
109 | |
110 | lives_ok { |
fde8e43f |
111 | Mouse::Meta::Role::Application->new->apply($c); |
67199842 |
112 | } '... this succeeds as expected'; |
113 | |
114 | is_deeply( |
115 | [ sort $c->get_method_list ], |
116 | [], |
117 | '... got the right list of methods' |
6cfa1e5e |
118 | ); |
119 | |
67199842 |
120 | is_deeply( |
121 | [ sort $c->get_required_method_list ], |
122 | [ 'bar', 'foo' ], |
123 | '... got the right list of required methods' |
6cfa1e5e |
124 | ); |
67199842 |
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 | |
6cfa1e5e |
137 | is($c->name, 'Role::Foo|Role::AnotherFooConflict', '... got the composite role name'); |
138 | |
67199842 |
139 | lives_ok { |
fde8e43f |
140 | Mouse::Meta::Role::Application->new->apply($c); |
6cfa1e5e |
141 | } '... this succeeds as expected'; |
142 | |
67199842 |
143 | is_deeply( |
144 | [ sort $c->get_method_list ], |
145 | [ 'baz' ], |
146 | '... got the right list of methods' |
6cfa1e5e |
147 | ); |
148 | |
67199842 |
149 | is_deeply( |
150 | [ sort $c->get_required_method_list ], |
151 | [ 'foo' ], |
152 | '... got the right list of required methods' |
6cfa1e5e |
153 | ); |
67199842 |
154 | } |
155 | |
fde8e43f |
156 | done_testing; |