added default {} keyword
[gitmo/Moose.git] / t / 048_more_role_edge_cases.t
CommitLineData
92768c49 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
06b30515 6use Test::More tests => 10;
e39d707f 7use Test::Exception;
8
9BEGIN {
10 use_ok('Moose');
11}
92768c49 12
13{
e39d707f 14 # NOTE:
15 # this tests that repeated role
16 # composition will not cause
17 # a conflict between two methods
18 # which are actually the same anyway
19
92768c49 20 {
21 package RootA;
22 use Moose::Role;
23
e39d707f 24 sub foo { "RootA::foo" }
92768c49 25
26 package SubAA;
27 use Moose::Role;
28
29 with "RootA";
30
e39d707f 31 sub bar { "SubAA::bar" }
92768c49 32
33 package SubAB;
34 use Moose;
35
e39d707f 36 ::lives_ok {
37 with "SubAA", "RootA";
38 } '... role was composed as expected';
92768c49 39 }
40
41 ok( SubAB->does("SubAA"), "does SubAA");
42 ok( SubAB->does("RootA"), "does RootA");
43
44 isa_ok( my $i = SubAB->new, "SubAB" );
45
46 can_ok( $i, "bar" );
e39d707f 47 is( $i->bar, "SubAA::bar", "... got thr right bar rv" );
92768c49 48
49 can_ok( $i, "foo" );
e39d707f 50 my $foo_rv;
51 lives_ok {
52 $foo_rv = $i->foo;
53 } '... called foo successfully';
54 is($foo_rv, "RootA::foo", "... got the right foo rv");
92768c49 55}
56