Commit | Line | Data |
5659d76e |
1 | use strict; |
2 | use warnings; |
3 | |
86a4d873 |
4 | use Test::More; |
871e9eb5 |
5 | use Test::Fatal; |
5659d76e |
6 | |
efd3d14c |
7 | use Class::MOP; |
5659d76e |
8 | |
9 | { |
013b1897 |
10 | my $attr = Class::MOP::Attribute->new('$test'); |
9b871d79 |
11 | is( $attr->meta, Class::MOP::Attribute->meta, |
12 | '... instance and class both lead to the same meta' ); |
013b1897 |
13 | } |
14 | |
15 | { |
5659d76e |
16 | my $meta = Class::MOP::Attribute->meta(); |
9b871d79 |
17 | isa_ok( $meta, 'Class::MOP::Class' ); |
1d68af04 |
18 | |
5659d76e |
19 | my @methods = qw( |
89871ad6 |
20 | new |
21 | clone |
1d68af04 |
22 | |
bd4e03f9 |
23 | initialize_instance_slot |
8ee74136 |
24 | _set_initial_slot_value |
a0c6ecac |
25 | _make_initializer_writer_callback |
1d68af04 |
26 | |
5659d76e |
27 | name |
89871ad6 |
28 | has_accessor accessor |
29 | has_writer writer |
30 | has_write_method get_write_method get_write_method_ref |
31 | has_reader reader |
32 | has_read_method get_read_method get_read_method_ref |
33 | has_predicate predicate |
34 | has_clearer clearer |
35 | has_builder builder |
36 | has_init_arg init_arg |
37 | has_default default is_default_a_coderef |
38 | has_initializer initializer |
df3ea00c |
39 | has_insertion_order insertion_order _set_insertion_order |
1d68af04 |
40 | |
d9d99689 |
41 | definition_context |
42 | |
c57c8b10 |
43 | slots |
16e960bd |
44 | get_value |
45 | set_value |
7e5efe15 |
46 | get_raw_value |
47 | set_raw_value |
ef91a0e2 |
48 | set_initial_value |
3545c727 |
49 | has_value |
50 | clear_value |
1d68af04 |
51 | |
5659d76e |
52 | associated_class |
89871ad6 |
53 | attach_to_class |
54 | detach_from_class |
1d68af04 |
55 | |
ba38bf08 |
56 | accessor_metaclass |
1d68af04 |
57 | |
3545c727 |
58 | associated_methods |
59 | associate_method |
1d68af04 |
60 | |
5659d76e |
61 | process_accessors |
45a183fb |
62 | _process_accessors |
5659d76e |
63 | install_accessors |
64 | remove_accessors |
4b698b1a |
65 | |
5e5102f1 |
66 | _inline_get_value |
67 | _inline_set_value |
68 | _inline_has_value |
69 | _inline_clear_value |
70 | _inline_instance_get |
71 | _inline_instance_set |
72 | _inline_instance_has |
73 | _inline_instance_clear |
03a3092d |
74 | |
4b698b1a |
75 | _new |
9b871d79 |
76 | ); |
1d68af04 |
77 | |
5659d76e |
78 | is_deeply( |
9b871d79 |
79 | [ |
80 | sort Class::MOP::Mixin::AttributeCore->meta->get_method_list, |
81 | $meta->get_method_list |
82 | ], |
7d28758b |
83 | [ sort @methods ], |
9b871d79 |
84 | '... our method list matches' |
85 | ); |
1d68af04 |
86 | |
5659d76e |
87 | foreach my $method_name (@methods) { |
9b871d79 |
88 | ok( $meta->find_method_by_name($method_name), |
89 | '... Class::MOP::Attribute->find_method_by_name(' . $method_name . ')' ); |
5659d76e |
90 | } |
1d68af04 |
91 | |
c23184fc |
92 | my @attributes = ( |
8683db0e |
93 | 'name', |
94 | 'accessor', |
95 | 'reader', |
96 | 'writer', |
97 | 'predicate', |
98 | 'clearer', |
99 | 'builder', |
100 | 'init_arg', |
101 | 'initializer', |
d9d99689 |
102 | 'definition_context', |
8683db0e |
103 | 'default', |
104 | 'associated_class', |
105 | 'associated_methods', |
223ec6f9 |
106 | 'insertion_order', |
1bd2739a |
107 | ); |
5659d76e |
108 | |
109 | is_deeply( |
9b871d79 |
110 | [ |
111 | sort Class::MOP::Mixin::AttributeCore->meta->get_attribute_list, |
112 | $meta->get_attribute_list |
113 | ], |
7d28758b |
114 | [ sort @attributes ], |
9b871d79 |
115 | '... our attribute list matches' |
116 | ); |
1d68af04 |
117 | |
5659d76e |
118 | foreach my $attribute_name (@attributes) { |
9b871d79 |
119 | ok( $meta->find_attribute_by_name($attribute_name), |
120 | '... Class::MOP::Attribute->find_attribute_by_name(' |
121 | . $attribute_name |
122 | . ')' ); |
5659d76e |
123 | } |
1d68af04 |
124 | |
125 | # We could add some tests here to make sure that |
126 | # the attribute have the appropriate |
127 | # accessor/reader/writer/predicate combinations, |
128 | # but that is getting a little excessive so I |
129 | # wont worry about it for now. Maybe if I get |
5659d76e |
130 | # bored I will do it. |
2d711cc8 |
131 | } |
86a4d873 |
132 | |
133 | done_testing; |