remove trailing whitespace
[gitmo/Moose.git] / t / 030_roles / 014_more_alias_and_exclude.t
CommitLineData
28412c0b 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
7ff56534 6use Test::More tests => 9;
28412c0b 7use Test::Exception;
8
7ff56534 9
28412c0b 10
11{
12 package Foo;
13 use Moose::Role;
d03bd989 14
28412c0b 15 sub foo { 'Foo::foo' }
16 sub bar { 'Foo::bar' }
17 sub baz { 'Foo::baz' }
d03bd989 18 sub gorch { 'Foo::gorch' }
19
28412c0b 20 package Bar;
21 use Moose::Role;
22
23 sub foo { 'Bar::foo' }
24 sub bar { 'Bar::bar' }
25 sub baz { 'Bar::baz' }
d03bd989 26 sub gorch { 'Bar::gorch' }
28412c0b 27
28 package Baz;
29 use Moose::Role;
d03bd989 30
28412c0b 31 sub foo { 'Baz::foo' }
32 sub bar { 'Baz::bar' }
33 sub baz { 'Baz::baz' }
d03bd989 34 sub gorch { 'Baz::gorch' }
35
28412c0b 36 package Gorch;
37 use Moose::Role;
d03bd989 38
28412c0b 39 sub foo { 'Gorch::foo' }
40 sub bar { 'Gorch::bar' }
41 sub baz { 'Gorch::baz' }
d03bd989 42 sub gorch { 'Gorch::gorch' }
28412c0b 43}
44
45{
46 package My::Class;
47 use Moose;
d03bd989 48
28412c0b 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
57my $c = My::Class->new;
58isa_ok($c, 'My::Class');
59
60is($c->foo, 'Foo::foo', '... got the right method');
61is($c->bar, 'Bar::bar', '... got the right method');
62is($c->baz, 'Baz::baz', '... got the right method');
63is($c->gorch, 'Gorch::gorch', '... got the right method');
64
65is($c->foo_gorch, 'Foo::gorch', '... got the right method');
66is($c->baz_foo, 'Baz::foo', '... got the right method');
67is($c->baz_bar, 'Baz::bar', '... got the right method');
68
69
70
71
72