From: Graham Knop Date: Sat, 13 Jul 2013 21:14:39 +0000 (-0400) Subject: more testing for create_class_with_roles X-Git-Tag: v1.003000~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4055038d2a1b634c49ffbda0c25b460dd2c6c561;p=gitmo%2FMoo.git more testing for create_class_with_roles --- 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; diff --git a/xt/moo-does-moose-role.t b/xt/moo-does-moose-role.t index 8811bfd..b995e44 100644 --- a/xt/moo-does-moose-role.t +++ b/xt/moo-does-moose-role.t @@ -279,5 +279,13 @@ is exception { with qw(Splat NeedTrap); }, undef, 'requires satisfied by Moose attribute composed at the same time'; +{ + package HasMonkey; + use Moo; + sub monkey {} +} +is exception { + Moo::Role->create_class_with_roles('HasMonkey', 'Splat', 'NeedTrap'); +}, undef, ' ... and when created by create_class_with_roles'; done_testing;