X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F08-role-composition.t;h=1e8d0bb345953396be7383472e5be5b6654c4787;hb=e5fa95baab2413d6eea127014ba8fa291ce3ab3e;hp=a3bb0e99e7b8f55e47800ff810aeb2e23b2cd89b;hpb=d4e93624b4c9c91673a7b7961e365e1c0f921c29;p=gitmo%2FMooseX-ClassAttribute.git diff --git a/t/08-role-composition.t b/t/08-role-composition.t index a3bb0e9..1e8d0bb 100644 --- a/t/08-role-composition.t +++ b/t/08-role-composition.t @@ -2,7 +2,6 @@ use strict; use warnings; use Test::More; -use Test::Exception; { package Role; @@ -26,12 +25,83 @@ use Test::Exception; 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();