Duplicated role_type() and class_type() no longer throw the error
[gitmo/Mouse.git] / Moose-t-failing / 030_roles / 024_role_composition_methods.t
CommitLineData
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!!!
4use t::lib::MooseCompat;
67199842 5
6use strict;
7use warnings;
8
c47cf415 9use Test::More;
10$TODO = q{Mouse is not yet completed};
67199842 11use Test::Exception;
12
c47cf415 13use Mouse::Meta::Role::Application;
67199842 14use 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 {
c47cf415 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 {
c47cf415 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 {
c47cf415 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 {
c47cf415 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
c47cf415 156done_testing;