Commit | Line | Data |
67199842 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More tests => 17; |
7 | use Test::Mouse; |
8 | |
9 | { |
10 | package My::Role; |
11 | use Mouse::Role; |
6cfa1e5e |
12 | |
67199842 |
13 | sub foo { "FOO" } |
6cfa1e5e |
14 | sub bar { "BAR" } |
67199842 |
15 | } |
16 | |
17 | { |
18 | package My::Class; |
19 | use Mouse; |
6cfa1e5e |
20 | |
67199842 |
21 | with 'My::Role' => { |
6cfa1e5e |
22 | -alias => { foo => 'baz', bar => 'gorch' }, |
23 | -excludes => ['foo', 'bar'], |
67199842 |
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; |
6cfa1e5e |
43 | |
67199842 |
44 | with 'My::Role' => { |
6cfa1e5e |
45 | -alias => { foo => 'baz', bar => 'gorch' }, |
46 | -excludes => ['foo', 'bar'], |
67199842 |
47 | }; |
6cfa1e5e |
48 | |
67199842 |
49 | package My::Class::Again; |
50 | use Mouse; |
6cfa1e5e |
51 | |
67199842 |
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 | |