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