X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcompose-roles.t;h=26c35a1649e638052858a6395da970e262ce1101;hb=0fac3e2399478aea66e4a13e2aaa0b10f22239ed;hp=162f7106de0738d64b977c7f9c6f7ff8571e38bd;hpb=75967522341e1ce85f0dcbcfe65d91a1222e0a7a;p=gitmo%2FMoo.git diff --git a/t/compose-roles.t b/t/compose-roles.t index 162f710..26c35a1 100644 --- a/t/compose-roles.t +++ b/t/compose-roles.t @@ -83,7 +83,7 @@ is($o2->attr2, -2, 'constructor includes role'); } is exception { - package EmptyClass; + package ClassWithExtension; use Moo; Moo::Role->apply_roles_to_object( Moo->_accessor_maker_for(__PACKAGE__), @@ -92,4 +92,27 @@ is exception { with qw(RoleWithAttr RoleWithReq); }, undef, 'apply_roles_to_object correctly calls accessor generator'; +{ + package EmptyClass; + use Moo; +} + +{ + package RoleWithReq2; + use Moo::Role; + requires 'attr2'; +} + +is exception { + Moo::Role->create_class_with_roles( + 'EmptyClass', 'RoleWithReq2', 'RoleWithAttr2'); +}, undef, 'create_class_with_roles accepts attributes for requirements'; + +like exception { + Moo::Role->create_class_with_roles( + 'EmptyClass', 'RoleWithReq2', 'RoleWithAttr'); +}, qr/Can't apply .* missing attr2/, + 'create_class_with_roles accepts attributes for requirements'; + + done_testing;