s/make_immutable/metaclass->make_immutable/
[gitmo/Moose.git] / t / 030_roles / 014_more_alias_and_exclude.t
CommitLineData
28412c0b 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 10;
7use Test::Exception;
8
9BEGIN {
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
59my $c = My::Class->new;
60isa_ok($c, 'My::Class');
61
62is($c->foo, 'Foo::foo', '... got the right method');
63is($c->bar, 'Bar::bar', '... got the right method');
64is($c->baz, 'Baz::baz', '... got the right method');
65is($c->gorch, 'Gorch::gorch', '... got the right method');
66
67is($c->foo_gorch, 'Foo::gorch', '... got the right method');
68is($c->baz_foo, 'Baz::foo', '... got the right method');
69is($c->baz_bar, 'Baz::bar', '... got the right method');
70
71
72
73
74