adding in method aliasing during composition
[gitmo/Moose.git] / t / 030_roles / 013_method_aliasing_during_composition.t
CommitLineData
3e19778d 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More no_plan => 1;
7use Test::Exception;
8
9BEGIN {
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
31ok(My::Class->meta->has_method($_), "we have a $_ method") for qw(foo baz role_bar);
32ok(!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
45ok(My::OtherRole->meta->has_method($_), "we have a $_ method") for qw(foo bar baz role_bar);
46ok(!My::OtherRole->meta->requires_method('bar'), '... and the &bar method is not required');
47ok(!My::OtherRole->meta->requires_method('role_bar'), '... and the &role_bar method is not required');
48
49
50
51
52