From: Graham Knop Date: Mon, 27 May 2013 04:09:12 +0000 (-0400) Subject: test for mutual requires X-Git-Tag: v1.003000~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e0d6c8a89f254b4b30674b56117ff953b698628;p=gitmo%2FMoo.git test for mutual requires --- diff --git a/t/mutual-requires.t b/t/mutual-requires.t new file mode 100644 index 0000000..114b46c --- /dev/null +++ b/t/mutual-requires.t @@ -0,0 +1,45 @@ +use strict; +use warnings FATAL => 'all'; +use Test::More; +use Test::Fatal; + +is exception { + package RoleA; + use Moo::Role; + requires 'method_b'; + requires 'attr_b'; + sub method_a {} + has attr_a => (is => 'ro'); +}, undef, 'define role a'; + +is exception { + package RoleB; + use Moo::Role; + requires 'method_a'; + requires 'attr_a'; + sub method_b {} + has attr_b => (is => 'ro'); +}, undef, 'define role a'; + +is exception { + package RoleC; + use Moo::Role; + with 'RoleA', 'RoleB'; + 1; +}, undef, 'compose roles with mutual requires into role'; + +is exception { + package PackageWithPrecomposed; + use Moo; + with 'RoleC'; + 1; +}, undef, 'compose precomposed roles into package'; + +is exception { + package PackageWithCompose; + use Moo; + with 'RoleA', 'RoleB'; + 1; +}, undef, 'compose roles with mutual requires into package'; + +done_testing;