From: Tomas Doran Date: Tue, 19 Jun 2012 20:43:22 +0000 (+0100) Subject: Add additional testing for role combination X-Git-Tag: v0.091010~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=502d28800e35fef6335c54ea58f5e1264c16ecdf;p=gitmo%2FMoo.git Add additional testing for role combination --- diff --git a/xt/moo-does-moose-role.t b/xt/moo-does-moose-role.t index c8be09d..c1be1fd 100644 --- a/xt/moo-does-moose-role.t +++ b/xt/moo-does-moose-role.t @@ -5,6 +5,8 @@ BEGIN { package Ker; use Moo::Role; + + sub has_ker {} } BEGIN { @@ -21,6 +23,18 @@ BEGIN { around monkey => sub { 'OW' }; has trap => (is => 'ro', default => sub { -1 }); + + sub has_splat {} +} + +BEGIN { + package KerSplat; + use Moo::Role; + + with qw/ + Ker + Splat + /; } BEGIN { @@ -37,6 +51,18 @@ BEGIN { around monkey => sub { 'OW' }; has trap => (is => 'ro', default => sub { -1 }); + + sub has_splat {} +} + +BEGIN { + package KerSplat2; + use Moo::Role; + + with qw/ + Ker + Splat2 + /; } BEGIN { @@ -87,12 +113,57 @@ BEGIN { sub jab { 3 } } +BEGIN { + package KerSplattered; + + use Moo; + + sub monkey { 'WHAT' } + + with qw/ KerSplat /; -foreach my $s (Splattered->new, Splattered2->new, Ker::Splattered->new, Ker::Splattered2->new) { - is($s->punch, 1, 'punch'); - is($s->jab, 3, 'jab'); - is($s->monkey, 'OW', 'monkey'); - is($s->trap, -1, 'trap'); + sub jab { 3 } +} + +BEGIN { + package KerSplattered2; + + use Moo; + + sub monkey { 'WHAT' } + + with qw/ KerSplat2 /; + + sub jab { 3 } +} + +foreach my $s ( + Splattered->new, + Splattered2->new, + Ker::Splattered->new, + Ker::Splattered2->new, + KerSplattered->new, + KerSplattered2->new, +) { + ok($s->can('punch')) + and is($s->punch, 1, 'punch'); + ok($s->can('jab')) + and is($s->jab, 3, 'jab'); + ok($s->can('monkey')) + and is($s->monkey, 'OW', 'monkey'); + ok($s->can('trap')) + and is($s->trap, -1, 'trap'); +} + +foreach my $c (qw/ + Ker::Splattered + Ker::Splattered2 + KerSplattered + KerSplattered2 +/) { + ok $c->can('has_ker'); + ok $c->can('has_splat'); } done_testing; +