Regenerate test files
[gitmo/Mouse.git] / t-failing / 030_roles / 022_role_composition_req_methods.t
CommitLineData
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!!!
4use t::lib::MooseCompat;
67199842 5
6use strict;
7use warnings;
8
fde8e43f 9use Test::More;
10$TODO = q{Mouse is not yet completed};
67199842 11use Test::Exception;
12
fde8e43f 13use Mouse::Meta::Role::Application;
67199842 14use Mouse::Meta::Role::Composite;
15
16{
17 package Role::Foo;
6cfa1e5e 18 use Mouse::Role;
67199842 19 requires 'foo';
6cfa1e5e 20
67199842 21 package Role::Bar;
22 use Mouse::Role;
23 requires 'bar';
6cfa1e5e 24
67199842 25 package Role::ProvidesFoo;
6cfa1e5e 26 use Mouse::Role;
67199842 27 sub foo { 'Role::ProvidesFoo::foo' }
6cfa1e5e 28
67199842 29 package Role::ProvidesBar;
6cfa1e5e 30 use Mouse::Role;
31 sub bar { 'Role::ProvidesBar::bar' }
67199842 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,
6cfa1e5e 40 ]
67199842 41 );
42 isa_ok($c, 'Mouse::Meta::Role::Composite');
43
6cfa1e5e 44 is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name');
45
67199842 46 lives_ok {
fde8e43f 47 Mouse::Meta::Role::Application->new->apply($c);
6cfa1e5e 48 } '... this succeeds as expected';
49
67199842 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
6cfa1e5e 67 is($c->name, 'Role::Foo|Role::ProvidesFoo', '... got the composite role name');
68
69 lives_ok {
fde8e43f 70 Mouse::Meta::Role::Application->new->apply($c);
6cfa1e5e 71 } '... this succeeds as expected';
72
67199842 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,
6cfa1e5e 86 Role::Bar->meta,
67199842 87 ]
88 );
89 isa_ok($c, 'Mouse::Meta::Role::Composite');
90
6cfa1e5e 91 is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::Bar', '... got the composite role name');
92
67199842 93 lives_ok {
fde8e43f 94 Mouse::Meta::Role::Application->new->apply($c);
6cfa1e5e 95 } '... this succeeds as expected';
96
67199842 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,
6cfa1e5e 110 Role::ProvidesBar->meta,
111 Role::Bar->meta,
67199842 112 ]
113 );
114 isa_ok($c, 'Mouse::Meta::Role::Composite');
115
6cfa1e5e 116 is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::ProvidesBar|Role::Bar', '... got the composite role name');
117
67199842 118 lives_ok {
fde8e43f 119 Mouse::Meta::Role::Application->new->apply($c);
6cfa1e5e 120 } '... this succeeds as expected';
121
67199842 122 is_deeply(
123 [ sort $c->get_required_method_list ],
124 [ ],
125 '... got the right list of required methods'
126 );
127}
128
fde8e43f 129done_testing;