X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F10-multiple-role-composition.t;fp=t%2F10-multiple-role-composition.t;h=d8818455932031cf1572aa174ca32acac3e17f70;hb=a9d2b1a78f09fa9f0413953fb089ba0918e5da13;hp=0000000000000000000000000000000000000000;hpb=d0f129f508a6f1cc66edd10eb50005c01ca6bee5;p=gitmo%2FMooseX-ClassAttribute.git diff --git a/t/10-multiple-role-composition.t b/t/10-multiple-role-composition.t new file mode 100644 index 0000000..d881845 --- /dev/null +++ b/t/10-multiple-role-composition.t @@ -0,0 +1,65 @@ + +# Reported as https://rt.cpan.org/Public/Bug/Display.html?id=59610 + +{ + package Role1; + use Moose::Role; + + # I do nothing! +} +{ + package Role2; + + use Moose::Role; + use MooseX::ClassAttribute; + + # I also do nothing, except use MX:CA +} + +{ + package Foo; + use strict; use warnings; + use Moose; + with 'Role1'; + with 'Role2'; +} + +{ + package Bar; + use strict; use warnings; + use Moose; + with 'Role2'; + with 'Role1'; +} + +{ + package Baz; + use strict; use warnings; + use Moose; + with 'Role1', 'Role2'; +} + +{ + package Quux; + use strict; use warnings; + use Moose; + with 'Role2', 'Role1'; +} + +# in this example, all roles actually disappear if the second one uses MX:CA! + +package main; + +use Test::More tests => 5; +use Test::NoWarnings; +use Test::Deep; +local $TODO = 'Class attributes are lost during role composition'; +foreach my $class (qw(Foo Bar Baz Quux)) +{ + cmp_deeply( + [ map { $_->name} $class->meta->calculate_all_roles ], + superbagof(qw(Role1 Role2)), + 'Both roles are consumed by class ' . $class, + ); +} +