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