X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcompose-roles.t;h=53ec5bb6921f701bbff6817f235dd44448d6c5d8;hb=0d931f8a92552b142000bd5a4886e0c3d7d1a553;hp=29a3342a4be43982acd1e5522ec4c4b00d1c71d1;hpb=1947330aa6283819f0e7606fae1dfe732afdae6a;p=gitmo%2FMoo.git diff --git a/t/compose-roles.t b/t/compose-roles.t index 29a3342..53ec5bb 100644 --- a/t/compose-roles.t +++ b/t/compose-roles.t @@ -28,4 +28,27 @@ foreach my $combo ( is(ref($object), $combined, 'Object reblessed into correct class'); } +{ + package RoleWithAttr; + use Moo::Role; + + has attr1 => (is => 'rw'); + + package RoleWithAttr2; + use Moo::Role; + + has attr2 => (is => 'rw'); + + package ClassWithAttr; + use Moo; + + has attr3 => (is => 'rw'); +} + +Moo::Role->apply_roles_to_package('ClassWithAttr', 'RoleWithAttr', 'RoleWithAttr2'); +my $o = ClassWithAttr->new(attr1 => 1, attr2 => 2, attr3 => 3); +is($o->attr1, 1, 'attribute from role works'); +is($o->attr2, 2, 'attribute from role 2 works'); +is($o->attr3, 3, 'attribute from base class works'); + done_testing;