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