Commit | Line | Data |
---|---|---|
b1b81553 | 1 | use strict; |
2 | use warnings; | |
4aaa2ed6 | 3 | use Test::More tests => 5; |
b1b81553 | 4 | |
5 | { | |
6 | package Animal; | |
7 | use Mouse::Role; | |
4aaa2ed6 | 8 | requires 'bark'; |
b1b81553 | 9 | sub eat { 'delicious' } |
10 | has food => ( is => 'ro' ); | |
11 | } | |
12 | ||
13 | { | |
14 | package Dog; | |
15 | use Mouse::Role; | |
16 | with 'Animal'; | |
17 | } | |
18 | ||
19 | { | |
20 | package Chihuahua; | |
21 | use Mouse; | |
22 | with 'Dog'; | |
4aaa2ed6 | 23 | sub bark { 'bow-wow' } |
b1b81553 | 24 | } |
25 | ||
26 | ok !Animal->can('food'); | |
27 | ok !Dog->can('food'); | |
28 | ||
29 | my $c = Chihuahua->new(food => 'bone'); | |
30 | is $c->eat(), 'delicious'; | |
31 | is $c->food(), 'bone'; | |
4aaa2ed6 | 32 | is $c->bark(), 'bow-wow'; |
b1b81553 | 33 |