Changes for next release
[gitmo/MooseX-ClassAttribute.git] / t / 10-strict-role-composition.t
1 # Reported as https://rt.cpan.org/Public/Bug/Display.html?id=59663
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 use Test::Fatal;
8
9 use Test::Requires {
10     'MooseX::Role::Strict' => 0.01,
11 };
12
13 {
14     package Role;
15
16     use MooseX::Role::Strict;
17     use MooseX::ClassAttribute;
18
19     class_has attr => (
20         traits  => ['Hash'],
21         is      => 'ro',
22         isa     => 'HashRef[Str]',
23         lazy    => 1,
24         default => sub { {} },
25         handles => {
26             has_attr => 'exists',
27         },
28     );
29
30     sub normal_method {
31         Test::More::pass('a regular method from the role is composed');
32     }
33
34 }
35
36 {
37     package Foo;
38     use Moose;
39
40     with 'Role';
41 }
42
43 Foo->normal_method();
44
45 {
46     local $TODO = 'This test does not yet pass';
47
48     is(
49         exception { Foo->has_attr('key') }, undef,
50         'Delegated method from native attribute trait is properly composed from a strict role'
51     );
52 }
53
54 done_testing();