From: Graham Knop Date: Wed, 19 Jun 2013 14:18:49 +0000 (-0400) Subject: test for creating class when parent doesn't have constructor built X-Git-Tag: v1.003000~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e95d3981f31c078147fa6e3f5b61ff16683703ac;hp=1108b2e2131e2f72dbd1a43afe5e8940b9e85931;p=gitmo%2FMoo.git test for creating class when parent doesn't have constructor built --- diff --git a/t/compose-roles.t b/t/compose-roles.t index 53ec5bb..ead1f11 100644 --- a/t/compose-roles.t +++ b/t/compose-roles.t @@ -32,17 +32,17 @@ foreach my $combo ( package RoleWithAttr; use Moo::Role; - has attr1 => (is => 'rw'); + has attr1 => (is => 'ro', default => -1); package RoleWithAttr2; use Moo::Role; - has attr2 => (is => 'rw'); + has attr2 => (is => 'ro', default => -2); package ClassWithAttr; use Moo; - has attr3 => (is => 'rw'); + has attr3 => (is => 'ro', default => -3); } Moo::Role->apply_roles_to_package('ClassWithAttr', 'RoleWithAttr', 'RoleWithAttr2'); @@ -51,4 +51,15 @@ 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'); +{ + package SubClassWithoutAttr; + use Moo; + extends 'ClassWithAttr'; +} + +my $o2 = Moo::Role->create_class_with_roles( + 'SubClassWithoutAttr', 'RoleWithAttr')->new; +is($o2->attr3, -3, 'constructor includes base class'); +is($o2->attr2, -2, 'constructor includes role'); + done_testing;