X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F08-role-composition.t;h=1e8d0bb345953396be7383472e5be5b6654c4787;hb=56a8f20e0fb722749bf37ba9c3f83ae24d765edb;hp=81eeb4415fd1352a18e86d835de2a2dfa8587aa9;hpb=4293d02612f63c83ef8ba27ade067f81cb34d0c6;p=gitmo%2FMooseX-ClassAttribute.git diff --git a/t/08-role-composition.t b/t/08-role-composition.t index 81eeb44..1e8d0bb 100644 --- a/t/08-role-composition.t +++ b/t/08-role-composition.t @@ -25,12 +25,83 @@ use Test::More; package Bar; use Moose; - with( 'Role2', 'Role' ); + with 'Role2', 'Role'; +} + +ok( + Bar->can('CA'), + 'Class attributes are preserved during role composition' +); + +{ + package Role3; + use Moose::Role; + with 'Role'; } { - local $TODO = 'Class attributes are lost during role composition'; - can_ok( 'Bar', 'CA', ); + package Baz; + use Moose; + + with 'Role3'; +} + +ok( + Baz->can('CA'), + 'Class attributes are preserved when role is applied to another role' +); + +{ + package Role4; + use Moose::Role; + + use MooseX::ClassAttribute; + + class_has 'CA2' => ( + is => 'ro', + isa => 'HashRef', + default => sub { {} }, + ); } +{ + package Buz; + use Moose; + + with 'Role', 'Role4'; +} + +ok( + Buz->can('CA'), + 'Class attributes are merged from two roles (CA)' +); + +ok( + Buz->can('CA2'), + 'Class attributes are merged from two roles (CA2)' +); + +{ + package Role5; + use Moose::Role; + with 'Role', 'Role4'; +} + +{ + package Quux; + use Moose; + + with 'Role5'; +} + +ok( + Quux->can('CA'), + 'Class attributes are merged from two roles (CA)' +); + +ok( + Quux->can('CA2'), + 'Class attributes are merged from two roles (CA2)' +); + done_testing();