38a20168fb65e5e383850ccc5fa44c77af35e988
[gitmo/Mouse.git] / t / 030_roles / 033_role_exclusion_and_alias_bug.t
1 #!/usr/bin/perl
2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
5
6 use strict;
7 use warnings;
8
9 use Test::More;
10 use Test::Mouse;
11
12 {
13     package My::Role;
14     use Mouse::Role;
15
16     sub foo { "FOO" }
17     sub bar { "BAR" }
18 }
19
20 {
21     package My::Class;
22     use Mouse;
23
24     with 'My::Role' => {
25         -alias    => { foo => 'baz', bar => 'gorch' },
26         -excludes => ['foo', 'bar'],
27     };
28 }
29
30 {
31     my $x = My::Class->new;
32     isa_ok($x, 'My::Class');
33     does_ok($x, 'My::Role');
34
35     can_ok($x, $_) for qw[baz gorch];
36
37     ok(!$x->can($_), '... cant call method ' . $_) for qw[foo bar];
38
39     is($x->baz, 'FOO', '... got the right value');
40     is($x->gorch, 'BAR', '... got the right value');
41 }
42
43 {
44     package My::Role::Again;
45     use Mouse::Role;
46
47     with 'My::Role' => {
48         -alias    => { foo => 'baz', bar => 'gorch' },
49         -excludes => ['foo', 'bar'],
50     };
51
52     package My::Class::Again;
53     use Mouse;
54
55     with 'My::Role::Again';
56 }
57
58 {
59     my $x = My::Class::Again->new;
60     isa_ok($x, 'My::Class::Again');
61     does_ok($x, 'My::Role::Again');
62     does_ok($x, 'My::Role');
63
64     can_ok($x, $_) for qw[baz gorch];
65
66     ok(!$x->can($_), '... cant call method ' . $_) for qw[foo bar];
67
68     is($x->baz, 'FOO', '... got the right value');
69     is($x->gorch, 'BAR', '... got the right value');
70 }
71
72 done_testing;