--- /dev/null
+
+# Reported in https://rt.cpan.org/Public/Bug/Display.html?id=59572
+
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+#use Test::NoWarnings;
+use Test::Exception;
+
+{
+ package Role1;
+ use Moose::Role;
+
+ # I do nothing!
+}
+{
+ package Role2;
+
+ use Moose::Role;
+ use MooseX::ClassAttribute;
+
+ class_has attr => (
+ is => 'ro', isa => 'HashRef[Str]',
+ lazy => 1,
+ default => sub { {} },
+ traits => ['Hash'],
+ handles => {
+ has_attr => 'exists',
+ },
+ );
+
+ has foo => ( is => 'rw' );
+
+ sub normal_method
+ {
+ Test::More::pass('a regular method from the role is composed');
+ }
+}
+
+{
+ package Foo;
+ use strict; use warnings;
+ use Moose;
+ with 'Role1', 'Role2';
+ 1;
+}
+
+package main;
+local $TODO = 'Class attributes are lost during role composition';
+# this runs, so Role2 did get composed...
+Foo->normal_method;
+ok(Foo->can('foo'), 'Standard attribute applied ok');
+
+# Except the delegated method ended up in the wrong place!
+
+# ..and MX::Class never got applied properly!
+ok(Moose::Util::does_role(Foo->meta, 'MooseX::ClassAttribute::Trait::Class'),
+ 'metaclass gets MX:CA metaclass trait');
+
+# in Moose 1.08/MooseX::ClassAttribute 0.16, this dies with:
+# Can't locate object method "has_attr" via package "Foo"
+lives_ok { Foo->has_attr('key') }
+ 'Delegated method from native attribute trait is properly composed from a role composed in a list of roles';
+
--- /dev/null
+
+# reported in https://rt.cpan.org/Public/Bug/Display.html?id=59573
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use Test::NoWarnings;
+use Test::Exception;
+
+{
+ package Foo;
+ use Moose;
+ use MooseX::ClassAttribute;
+ class_has attr => (
+ is => 'bare', isa => 'HashRef[Str]',
+ lazy => 1,
+ default => sub { {} },
+ traits => ['Hash'],
+ handles => {
+ has_attr => 'exists',
+ },
+ );
+}
+
+package main;
+
+# in Moose 1.08/MooseX::ClassAttribute 0.16, this dies with:
+# Can't use an undefined value as a HASH reference
+lives_ok { Foo->has_attr('key') }
+ 'Default builder in a native attribute trait is properly run when the attribute is defined with no standard accessors';
+
+
--- /dev/null
+
+# 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,
+ );
+}
+
--- /dev/null
+
+# Reported as https://rt.cpan.org/Public/Bug/Display.html?id=59663
+
+package main;
+use Test::More tests => 3;
+use Test::Exception;
+
+use Test::Requires {
+ 'MooseX::Role::Strict' => 0.01, # skip all if not installed
+};
+
+{
+ package Role;
+
+ use MooseX::Role::Strict;
+ use MooseX::ClassAttribute;
+
+ class_has attr => (
+ is => 'ro', isa => 'HashRef[Str]',
+ lazy => 1,
+ default => sub { {} },
+ traits => ['Hash'],
+ handles => {
+ has_attr => 'exists',
+ },
+ );
+
+
+ sub normal_method
+ {
+ Test::More::pass('a regular method from the role is composed');
+ }
+
+}
+
+{
+ package Foo;
+ use strict; use warnings;
+ use Moose;
+ with 'Role';
+}
+
+package main;
+use Test::NoWarnings;
+
+Foo->normal_method;
+
+lives_ok { Foo->has_attr('key') }
+ 'Delegated method from native attribute trait is properly composed from a strict role';
+
+
--- /dev/null
+use Test::More tests => 4;
+use Test::NoWarnings;
+use Test::Exception;
+
+{
+ package MooseX::Foo;
+
+ use strict;
+ use warnings;
+
+ use Moose::Exporter;
+ use MooseX::ClassAttribute ();
+
+ Moose::Exporter->setup_import_methods(
+ also => [ 'MooseX::ClassAttribute' ],
+ );
+}
+
+{
+ package MyClass;
+
+ use Moose;
+ MooseX::Foo->import;
+ &MyClass::class_has ( attr => ( is => 'ro' ) );
+
+};
+
+
+package main;
+
+ok(MyClass->can('has'));
+ok(MyClass->can('class_has'));
+ok(Moose::Util::does_role(MyClass->meta, 'MooseX::ClassAttribute::Trait::Class'),
+ 'metaclass gets MX:CA metaclass trait');
+