Commit | Line | Data |
28412c0b |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More tests => 10; |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
10 | use_ok('Moose'); |
11 | } |
12 | |
13 | { |
14 | package Foo; |
15 | use Moose::Role; |
16 | |
17 | sub foo { 'Foo::foo' } |
18 | sub bar { 'Foo::bar' } |
19 | sub baz { 'Foo::baz' } |
20 | sub gorch { 'Foo::gorch' } |
21 | |
22 | package Bar; |
23 | use Moose::Role; |
24 | |
25 | sub foo { 'Bar::foo' } |
26 | sub bar { 'Bar::bar' } |
27 | sub baz { 'Bar::baz' } |
28 | sub gorch { 'Bar::gorch' } |
29 | |
30 | package Baz; |
31 | use Moose::Role; |
32 | |
33 | sub foo { 'Baz::foo' } |
34 | sub bar { 'Baz::bar' } |
35 | sub baz { 'Baz::baz' } |
36 | sub gorch { 'Baz::gorch' } |
37 | |
38 | package Gorch; |
39 | use Moose::Role; |
40 | |
41 | sub foo { 'Gorch::foo' } |
42 | sub bar { 'Gorch::bar' } |
43 | sub baz { 'Gorch::baz' } |
44 | sub gorch { 'Gorch::gorch' } |
45 | } |
46 | |
47 | { |
48 | package My::Class; |
49 | use Moose; |
50 | |
51 | ::lives_ok { |
52 | with 'Foo' => { excludes => [qw/bar baz gorch/], alias => { gorch => 'foo_gorch' } }, |
53 | 'Bar' => { excludes => [qw/foo baz gorch/] }, |
54 | 'Baz' => { excludes => [qw/foo bar gorch/], alias => { foo => 'baz_foo', bar => 'baz_bar' } }, |
55 | 'Gorch' => { excludes => [qw/foo bar baz/] }; |
56 | } '... everything works out all right'; |
57 | } |
58 | |
59 | my $c = My::Class->new; |
60 | isa_ok($c, 'My::Class'); |
61 | |
62 | is($c->foo, 'Foo::foo', '... got the right method'); |
63 | is($c->bar, 'Bar::bar', '... got the right method'); |
64 | is($c->baz, 'Baz::baz', '... got the right method'); |
65 | is($c->gorch, 'Gorch::gorch', '... got the right method'); |
66 | |
67 | is($c->foo_gorch, 'Foo::gorch', '... got the right method'); |
68 | is($c->baz_foo, 'Baz::foo', '... got the right method'); |
69 | is($c->baz_bar, 'Baz::bar', '... got the right method'); |
70 | |
71 | |
72 | |
73 | |
74 | |