merged with delegation_bugs branch
[gitmo/MooseX-ClassAttribute.git] / t / 10-multiple-role-composition.t
diff --git a/t/10-multiple-role-composition.t b/t/10-multiple-role-composition.t
new file mode 100644 (file)
index 0000000..d881845
--- /dev/null
@@ -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,
+    );
+}
+