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