Commit | Line | Data |
a5e3ddfd |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use lib 't/lib'; |
5 | |
ee29de7b |
6 | use Test::More; |
a5e3ddfd |
7 | |
8 | # We just want the class definitions in here. |
9 | use SharedTests; |
10 | |
a3ced883 |
11 | ok( |
12 | HasClassAttribute->meta()->has_class_attribute('ObjectCount'), |
13 | q{has_class_attribute('ObjectCount') returns true} |
14 | ); |
a5e3ddfd |
15 | |
a3ced883 |
16 | ok( |
17 | HasClassAttribute->meta()->get_class_attribute('ObjectCount')->meta() |
18 | ->does_role('MooseX::ClassAttribute::Role::Meta::Attribute'), |
19 | 'get_class_attribute_list returns an object which does the MooseX::ClassAttribute::Role::Meta::Attribute role' |
20 | ); |
a5e3ddfd |
21 | |
8207dfe7 |
22 | my @ca = qw( Delegatee |
a3ced883 |
23 | LazyAttribute |
24 | ManyNames |
25 | Mapping |
26 | ObjectCount |
27 | ReadOnlyAttribute |
28 | WeakAttribute |
29 | Built |
30 | LazyBuilt |
31 | Triggerish |
32 | ); |
33 | |
34 | is_deeply( |
35 | [ sort HasClassAttribute->meta()->get_class_attribute_list() ], |
36 | [ sort @ca ], |
37 | 'HasClassAttribute get_class_attribute_list gets all class attributes' |
38 | ); |
39 | |
40 | is_deeply( |
41 | [ |
42 | sort map { $_->name() } |
43 | HasClassAttribute->meta()->get_all_attributes() |
44 | ], |
45 | ['size'], |
46 | 'HasClassAttribute get_all_attributes only finds size attribute' |
47 | ); |
48 | |
49 | is_deeply( |
50 | [ |
51 | sort map { $_->name() } |
52 | HasClassAttribute->meta()->get_all_class_attributes() |
53 | ], |
54 | [ sort @ca ], |
55 | 'HasClassAttribute get_all_class_attributes gets all class attributes' |
56 | ); |
57 | |
58 | is_deeply( |
59 | [ sort keys %{ HasClassAttribute->meta()->get_class_attribute_map() } ], |
60 | [ sort @ca ], |
61 | 'HasClassAttribute get_class_attribute_map gets all class attributes' |
62 | ); |
63 | |
64 | is_deeply( |
65 | [ sort map { $_->name() } Child->meta()->get_all_class_attributes() ], |
66 | [ sort ( @ca, 'YetAnotherAttribute' ) ], |
67 | 'Child get_class_attribute_map gets all class attributes' |
68 | ); |
69 | |
70 | ok( |
71 | !Child->meta()->has_class_attribute('ObjectCount'), |
72 | q{has_class_attribute('ObjectCount') returns false for Child} |
73 | ); |
74 | |
75 | ok( |
76 | Child->meta()->has_class_attribute('YetAnotherAttribute'), |
77 | q{has_class_attribute('YetAnotherAttribute') returns true for Child} |
78 | ); |
79 | |
80 | ok( |
81 | Child->can('YetAnotherAttribute'), |
82 | 'Child has accessor for YetAnotherAttribute' |
83 | ); |
84 | |
85 | ok( |
86 | Child->meta()->has_class_attribute_value('YetAnotherAttribute'), |
87 | 'Child has class attribute value for YetAnotherAttribute' |
88 | ); |
a5e3ddfd |
89 | |
90 | Child->meta()->remove_class_attribute('YetAnotherAttribute'); |
91 | |
a3ced883 |
92 | ok( |
93 | !Child->meta()->has_class_attribute('YetAnotherAttribute'), |
94 | q{... has_class_attribute('YetAnotherAttribute') returns false after remove_class_attribute} |
95 | ); |
a5e3ddfd |
96 | |
a3ced883 |
97 | ok( |
98 | !Child->can('YetAnotherAttribute'), |
99 | 'accessor for YetAnotherAttribute has been removed' |
100 | ); |
a5e3ddfd |
101 | |
a3ced883 |
102 | ok( |
103 | !Child->meta()->has_class_attribute_value('YetAnotherAttribute'), |
104 | 'Child does not have a class attribute value for YetAnotherAttribute' |
105 | ); |
ee29de7b |
106 | |
107 | done_testing(); |