merged with delegation_bugs branch
[gitmo/MooseX-ClassAttribute.git] / t / 11-strict-role-composition.t
diff --git a/t/11-strict-role-composition.t b/t/11-strict-role-composition.t
new file mode 100644 (file)
index 0000000..cbbadbd
--- /dev/null
@@ -0,0 +1,51 @@
+
+# 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';
+
+