Commit | Line | Data |
3e19778d |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More no_plan => 1; |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
10 | use_ok('Moose'); |
11 | } |
12 | |
13 | { |
14 | package My::Role; |
15 | use Moose::Role; |
16 | |
17 | sub foo { 'Foo::foo' } |
18 | sub bar { 'Foo::bar' } |
19 | sub baz { 'Foo::baz' } |
20 | |
21 | requires 'role_bar'; |
22 | |
23 | package My::Class; |
24 | use Moose; |
25 | |
26 | ::lives_ok { |
27 | with 'My::Role' => { alias => { bar => 'role_bar' } }; |
28 | } '... this succeeds'; |
29 | } |
30 | |
31 | ok(My::Class->meta->has_method($_), "we have a $_ method") for qw(foo baz role_bar); |
32 | ok(!My::Class->meta->has_method('bar'), '... but we dont get bar'); |
33 | |
34 | { |
35 | package My::OtherRole; |
36 | use Moose::Role; |
37 | |
38 | ::lives_ok { |
39 | with 'My::Role' => { alias => { bar => 'role_bar' } }; |
40 | } '... this succeeds'; |
41 | |
42 | sub bar { 'My::OtherRole::bar' } |
43 | } |
44 | |
45 | ok(My::OtherRole->meta->has_method($_), "we have a $_ method") for qw(foo bar baz role_bar); |
46 | ok(!My::OtherRole->meta->requires_method('bar'), '... and the &bar method is not required'); |
47 | ok(!My::OtherRole->meta->requires_method('role_bar'), '... and the &role_bar method is not required'); |
48 | |
49 | |
50 | |
51 | |
52 | |