8 has one => (is => 'ro', default => sub { 'one' });
10 package One::P1; use Moo::Role;
11 has two => (is => 'ro', default => sub { 'two' });
13 package One::P2; use Moo::Role;
14 has three => (is => 'ro', default => sub { 'three' });
17 my $combined = Moo::Role->create_class_with_roles('One', qw(One::P1 One::P2));
18 isa_ok $combined, "One";
19 ok $combined->does($_), "Does $_" for qw(One::P1 One::P2);
21 my $c = $combined->new;
22 is $c->one, "one", "attr default set from class";
23 is $c->two, "two", "attr default set from role";
24 is $c->three, "three", "attr default set from role";
27 package Deux; use Moo; with 'One::P1';
29 ::exception { has two => (is => 'ro', default => sub { 'II' }); },
30 qr{^You cannot overwrite a locally defined method \(two\) with a reader},
31 'overwriting accesssors with roles fails'
36 package Two; use Moo; with 'One::P1';
37 has '+two' => (is => 'ro', default => sub { 'II' });
40 is(Two->new->two, 'II', "overwriting accessors using +attr works");