279e542d206beb43f8ca1e115a452473bae131e4
[gitmo/MooseX-ClassAttribute.git] / t / 08-role-composition.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 {
7     package Role;
8
9     use Moose::Role;
10     use MooseX::ClassAttribute;
11
12     class_has 'CA' => (
13         is      => 'ro',
14         isa     => 'HashRef',
15         default => sub { {} },
16     );
17 }
18
19 {
20     package Role2;
21     use Moose::Role;
22 }
23
24 {
25     package Bar;
26     use Moose;
27
28     with 'Role2', 'Role';
29 }
30
31 ok(
32     Bar->can('CA'),
33     'Class attributes are preserved during role composition'
34 );
35
36 {
37     package Role3;
38     use Moose::Role;
39     with 'Role';
40 }
41
42 {
43     package Baz;
44     use Moose;
45
46     with 'Role3';
47 }
48
49 ok(
50     Baz->can('CA'),
51     'Class attributes are preserved when role is applied to another role'
52 );
53
54 done_testing();