Commit | Line | Data |
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!!! |
4 | use t::lib::MooseCompat; |
67199842 |
5 | |
6 | use strict; |
7 | use warnings; |
8 | |
c47cf415 |
9 | use Test::More; |
10 | $TODO = q{Mouse is not yet completed}; |
67199842 |
11 | use Test::Exception; |
12 | |
c47cf415 |
13 | use Mouse::Meta::Role::Application; |
67199842 |
14 | use Mouse::Meta::Role::Composite; |
15 | |
16 | { |
17 | package Role::Foo; |
18 | use Mouse::Role; |
19 | |
20 | before foo => sub { 'Role::Foo::foo' }; |
6cfa1e5e |
21 | around foo => sub { 'Role::Foo::foo' }; |
22 | after foo => sub { 'Role::Foo::foo' }; |
67199842 |
23 | around baz => sub { [ 'Role::Foo', @{shift->(@_)} ] }; |
24 | |
25 | package Role::Bar; |
26 | use Mouse::Role; |
27 | |
28 | before bar => sub { 'Role::Bar::bar' }; |
6cfa1e5e |
29 | around bar => sub { 'Role::Bar::bar' }; |
30 | after bar => sub { 'Role::Bar::bar' }; |
67199842 |
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 | |
6cfa1e5e |
67 | is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); |
67199842 |
68 | |
69 | lives_ok { |
c47cf415 |
70 | Mouse::Meta::Role::Application->new->apply($c); |
6cfa1e5e |
71 | } '... this succeeds as expected'; |
67199842 |
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' |
6cfa1e5e |
83 | ); |
67199842 |
84 | |
85 | is_deeply( |
86 | [ sort $c->get_method_modifier_list('around') ], |
87 | [ 'bar', 'baz', 'foo' ], |
88 | '... got the right list of methods' |
6cfa1e5e |
89 | ); |
67199842 |
90 | } |
c47cf415 |
91 | |
92 | done_testing; |