Mouse::Role supports 'with'
[gitmo/Mouse.git] / t / 035-apply-roles-to-roles.t
1 use strict;
2 use warnings;
3 use Test::More tests => 4;
4
5 {
6     package Animal;
7     use Mouse::Role;
8     sub eat { 'delicious' }
9     has food => ( is => 'ro' );
10 }
11
12 {
13     package Dog;
14     use Mouse::Role;
15     with 'Animal';
16 }
17
18 {
19     package Chihuahua;
20     use Mouse;
21     with 'Dog';
22 }
23
24 ok !Animal->can('food');
25 ok !Dog->can('food');
26
27 my $c = Chihuahua->new(food => 'bone');
28 is $c->eat(), 'delicious';
29 is $c->food(), 'bone';
30