Add another MOOSE_TEST_MD option, MooseX
[gitmo/Moose.git] / t / roles / role_exclusion_and_alias_bug.t
CommitLineData
f5b6d42e 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
a28e50e4 6use Test::More;
f5b6d42e 7use Test::Moose;
8
9{
10 package My::Role;
11 use Moose::Role;
d03bd989 12
f5b6d42e 13 sub foo { "FOO" }
d03bd989 14 sub bar { "BAR" }
f5b6d42e 15}
16
17{
18 package My::Class;
19 use Moose;
d03bd989 20
f5b6d42e 21 with 'My::Role' => {
c8b8d92f 22 -alias => { foo => 'baz', bar => 'gorch' },
23 -excludes => ['foo', 'bar'],
f5b6d42e 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 Moose::Role;
d03bd989 43
f5b6d42e 44 with 'My::Role' => {
c8b8d92f 45 -alias => { foo => 'baz', bar => 'gorch' },
46 -excludes => ['foo', 'bar'],
f5b6d42e 47 };
d03bd989 48
f5b6d42e 49 package My::Class::Again;
50 use Moose;
d03bd989 51
f5b6d42e 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
a28e50e4 69done_testing;