Changelogging
[gitmo/Mouse.git] / t-failing / 030_roles / 022_role_composition_req_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     requires 'foo';
20
21     package Role::Bar;
22     use Mouse::Role;
23     requires 'bar';
24
25     package Role::ProvidesFoo;
26     use Mouse::Role;
27     sub foo { 'Role::ProvidesFoo::foo' }
28
29     package Role::ProvidesBar;
30     use Mouse::Role;
31     sub bar { 'Role::ProvidesBar::bar' }
32 }
33
34 # test simple requirement
35 {
36     my $c = Mouse::Meta::Role::Composite->new(
37         roles => [
38             Role::Foo->meta,
39             Role::Bar->meta,
40         ]
41     );
42     isa_ok($c, 'Mouse::Meta::Role::Composite');
43
44     is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name');
45
46     lives_ok {
47         Mouse::Meta::Role::Application->new->apply($c);
48     } '... this succeeds as expected';
49
50     is_deeply(
51         [ sort $c->get_required_method_list ],
52         [ 'bar', 'foo' ],
53         '... got the right list of required methods'
54     );
55 }
56
57 # test requirement satisfied
58 {
59     my $c = Mouse::Meta::Role::Composite->new(
60         roles => [
61             Role::Foo->meta,
62             Role::ProvidesFoo->meta,
63         ]
64     );
65     isa_ok($c, 'Mouse::Meta::Role::Composite');
66
67     is($c->name, 'Role::Foo|Role::ProvidesFoo', '... got the composite role name');
68
69     lives_ok {
70         Mouse::Meta::Role::Application->new->apply($c);
71     } '... this succeeds as expected';
72
73     is_deeply(
74         [ sort $c->get_required_method_list ],
75         [],
76         '... got the right list of required methods'
77     );
78 }
79
80 # test requirement satisfied
81 {
82     my $c = Mouse::Meta::Role::Composite->new(
83         roles => [
84             Role::Foo->meta,
85             Role::ProvidesFoo->meta,
86             Role::Bar->meta,
87         ]
88     );
89     isa_ok($c, 'Mouse::Meta::Role::Composite');
90
91     is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::Bar', '... got the composite role name');
92
93     lives_ok {
94         Mouse::Meta::Role::Application->new->apply($c);
95     } '... this succeeds as expected';
96
97     is_deeply(
98         [ sort $c->get_required_method_list ],
99         [ 'bar' ],
100         '... got the right list of required methods'
101     );
102 }
103
104 # test requirement satisfied
105 {
106     my $c = Mouse::Meta::Role::Composite->new(
107         roles => [
108             Role::Foo->meta,
109             Role::ProvidesFoo->meta,
110             Role::ProvidesBar->meta,
111             Role::Bar->meta,
112         ]
113     );
114     isa_ok($c, 'Mouse::Meta::Role::Composite');
115
116     is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::ProvidesBar|Role::Bar', '... got the composite role name');
117
118     lives_ok {
119         Mouse::Meta::Role::Application->new->apply($c);
120     } '... this succeeds as expected';
121
122     is_deeply(
123         [ sort $c->get_required_method_list ],
124         [ ],
125         '... got the right list of required methods'
126     );
127 }
128
129 done_testing;