Add a tool to import tests
[gitmo/Mouse.git] / t-failing / 030_roles / 026_role_composition_method_mods.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
20     before foo => sub { 'Role::Foo::foo' };
21     around foo => sub { 'Role::Foo::foo' };
22     after  foo => sub { 'Role::Foo::foo' };
23     around baz => sub { [ 'Role::Foo', @{shift->(@_)} ] };
24
25     package Role::Bar;
26     use Mouse::Role;
27
28     before bar => sub { 'Role::Bar::bar' };
29     around bar => sub { 'Role::Bar::bar' };
30     after  bar => sub { 'Role::Bar::bar' };
31
32     package Role::Baz;
33     use Mouse::Role;
34
35     with 'Role::Foo';
36     around baz => sub { [ 'Role::Baz', @{shift->(@_)} ] };
37
38 }
39
40 {
41   package Class::FooBar;
42   use Mouse;
43
44   with 'Role::Baz';
45   sub foo { 'placeholder' }
46   sub baz { ['Class::FooBar'] }
47 }
48
49 #test modifier call order
50 {
51     is_deeply(
52         Class::FooBar->baz,
53         ['Role::Baz','Role::Foo','Class::FooBar']
54     );
55 }
56
57 # test simple overrides
58 {
59     my $c = Mouse::Meta::Role::Composite->new(
60         roles => [
61             Role::Foo->meta,
62             Role::Bar->meta,
63         ]
64     );
65     isa_ok($c, 'Mouse::Meta::Role::Composite');
66
67     is($c->name, 'Role::Foo|Role::Bar', '... 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_method_modifier_list('before') ],
75         [ 'bar', 'foo' ],
76         '... got the right list of methods'
77     );
78
79     is_deeply(
80         [ sort $c->get_method_modifier_list('after') ],
81         [ 'bar', 'foo' ],
82         '... got the right list of methods'
83     );
84
85     is_deeply(
86         [ sort $c->get_method_modifier_list('around') ],
87         [ 'bar', 'baz', 'foo' ],
88         '... got the right list of methods'
89     );
90 }
91
92 done_testing;