Implemented Mouse::Role->does; modified Mouse::Meta::Class->initialise
[gitmo/Mouse.git] / t / 030_roles / failing / 033_role_exclusion_and_alias_bug.t
CommitLineData
67199842 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 17;
7use Test::Mouse;
8
9{
10 package My::Role;
11 use Mouse::Role;
12
13 sub foo { "FOO" }
14 sub bar { "BAR" }
15}
16
17{
18 package My::Class;
19 use Mouse;
20
21 with 'My::Role' => {
22 alias => { foo => 'baz', bar => 'gorch' },
23 excludes => ['foo', 'bar'],
24 };
25}
26
27{
28 my $x = My::Class->new;
29 isa_ok($x, 'My::Class');
30 does_ok($x, 'My::Role');
31
32 can_ok($x, $_) for qw[baz gorch];
33
34 ok(!$x->can($_), '... cant call method ' . $_) for qw[foo bar];
35
36 is($x->baz, 'FOO', '... got the right value');
37 is($x->gorch, 'BAR', '... got the right value');
38}
39
40{
41 package My::Role::Again;
42 use Mouse::Role;
43
44 with 'My::Role' => {
45 alias => { foo => 'baz', bar => 'gorch' },
46 excludes => ['foo', 'bar'],
47 };
48
49 package My::Class::Again;
50 use Mouse;
51
52 with 'My::Role::Again';
53}
54
55{
56 my $x = My::Class::Again->new;
57 isa_ok($x, 'My::Class::Again');
58 does_ok($x, 'My::Role::Again');
59 does_ok($x, 'My::Role');
60
61 can_ok($x, $_) for qw[baz gorch];
62
63 ok(!$x->can($_), '... cant call method ' . $_) for qw[foo bar];
64
65 is($x->baz, 'FOO', '... got the right value');
66 is($x->gorch, 'BAR', '... got the right value');
67}
68
69