added default {} keyword
[gitmo/Moose.git] / t / 048_more_role_edge_cases.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 10;
7 use Test::Exception;
8
9 BEGIN {
10     use_ok('Moose');           
11 }
12
13 {
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     
20     {
21         package RootA;
22         use Moose::Role;
23
24         sub foo { "RootA::foo" }
25
26         package SubAA;
27         use Moose::Role;
28
29         with "RootA";
30
31         sub bar { "SubAA::bar" }
32
33         package SubAB;
34         use Moose;
35
36         ::lives_ok { 
37             with "SubAA", "RootA"; 
38         } '... role was composed as expected';
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" );
47     is( $i->bar, "SubAA::bar", "... got thr right bar rv" );
48
49     can_ok( $i, "foo" );
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");
55 }
56