Commit | Line | Data |
c69190f1 |
1 | use strictures 1; |
2 | use Test::More; |
3 | use Sub::Quote; |
4 | |
5 | { |
6 | package One; use Moo; |
7 | has one => (is => 'ro', default => sub { 'one' }); |
8 | |
9 | package One::P1; use Moo::Role; |
10 | has two => (is => 'ro', default => sub { 'two' }); |
11 | |
12 | package One::P2; use Moo::Role; |
13 | has three => (is => 'ro', default => sub { 'three' }); |
14 | } |
15 | |
16 | my $combined = Moo::Role->create_class_with_roles('One', qw(One::P1 One::P2)); |
17 | isa_ok $combined, "One"; |
18 | ok $combined->does($_), "Does $_" for qw(One::P1 One::P2); |
19 | |
20 | my $c = $combined->new; |
21 | is $c->one, "one", "attr default set from class"; |
22 | is $c->two, "two", "attr default set from role"; |
23 | is $c->three, "three", "attr default set from role"; |
24 | |
25 | done_testing; |