simplification of code, fixes #45260 and makes behavior same as Moose attributes
[gitmo/MooseX-ClassAttribute.git] / t / 10-multiple-role-composition.t
CommitLineData
a9d2b1a7 1
2# Reported as https://rt.cpan.org/Public/Bug/Display.html?id=59610
3
4{
5 package Role1;
6 use Moose::Role;
7
8 # I do nothing!
9}
10{
11 package Role2;
12
13 use Moose::Role;
14 use MooseX::ClassAttribute;
15
16 # I also do nothing, except use MX:CA
17}
18
19{
20 package Foo;
21 use strict; use warnings;
22 use Moose;
23 with 'Role1';
24 with 'Role2';
25}
26
27{
28 package Bar;
29 use strict; use warnings;
30 use Moose;
31 with 'Role2';
32 with 'Role1';
33}
34
35{
36 package Baz;
37 use strict; use warnings;
38 use Moose;
39 with 'Role1', 'Role2';
40}
41
42{
43 package Quux;
44 use strict; use warnings;
45 use Moose;
46 with 'Role2', 'Role1';
47}
48
49# in this example, all roles actually disappear if the second one uses MX:CA!
50
51package main;
52
53use Test::More tests => 5;
54use Test::NoWarnings;
55use Test::Deep;
56local $TODO = 'Class attributes are lost during role composition';
57foreach my $class (qw(Foo Bar Baz Quux))
58{
59 cmp_deeply(
60 [ map { $_->name} $class->meta->calculate_all_roles ],
61 superbagof(qw(Role1 Role2)),
62 'Both roles are consumed by class ' . $class,
63 );
64}
65