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 |
1d68af04 |
25 | |
5659d76e |
26 | name |
89871ad6 |
27 | has_accessor accessor |
28 | has_writer writer |
29 | has_write_method get_write_method get_write_method_ref |
30 | has_reader reader |
31 | has_read_method get_read_method get_read_method_ref |
32 | has_predicate predicate |
33 | has_clearer clearer |
34 | has_builder builder |
35 | has_init_arg init_arg |
36 | has_default default is_default_a_coderef |
37 | has_initializer initializer |
df3ea00c |
38 | has_insertion_order insertion_order _set_insertion_order |
1d68af04 |
39 | |
d9d99689 |
40 | definition_context |
41 | |
c57c8b10 |
42 | slots |
16e960bd |
43 | get_value |
44 | set_value |
7e5efe15 |
45 | get_raw_value |
46 | set_raw_value |
ef91a0e2 |
47 | set_initial_value |
3545c727 |
48 | has_value |
49 | clear_value |
1d68af04 |
50 | |
5659d76e |
51 | associated_class |
89871ad6 |
52 | attach_to_class |
53 | detach_from_class |
1d68af04 |
54 | |
ba38bf08 |
55 | accessor_metaclass |
1d68af04 |
56 | |
3545c727 |
57 | associated_methods |
58 | associate_method |
1d68af04 |
59 | |
5659d76e |
60 | process_accessors |
45a183fb |
61 | _process_accessors |
5659d76e |
62 | install_accessors |
63 | remove_accessors |
4b698b1a |
64 | |
03a3092d |
65 | inline_get |
66 | inline_set |
67 | inline_has |
68 | inline_clear |
69 | |
4b698b1a |
70 | _new |
9b871d79 |
71 | ); |
1d68af04 |
72 | |
5659d76e |
73 | is_deeply( |
9b871d79 |
74 | [ |
75 | sort Class::MOP::Mixin::AttributeCore->meta->get_method_list, |
76 | $meta->get_method_list |
77 | ], |
7d28758b |
78 | [ sort @methods ], |
9b871d79 |
79 | '... our method list matches' |
80 | ); |
1d68af04 |
81 | |
5659d76e |
82 | foreach my $method_name (@methods) { |
9b871d79 |
83 | ok( $meta->find_method_by_name($method_name), |
84 | '... Class::MOP::Attribute->find_method_by_name(' . $method_name . ')' ); |
5659d76e |
85 | } |
1d68af04 |
86 | |
c23184fc |
87 | my @attributes = ( |
8683db0e |
88 | 'name', |
89 | 'accessor', |
90 | 'reader', |
91 | 'writer', |
92 | 'predicate', |
93 | 'clearer', |
94 | 'builder', |
95 | 'init_arg', |
96 | 'initializer', |
d9d99689 |
97 | 'definition_context', |
8683db0e |
98 | 'default', |
99 | 'associated_class', |
100 | 'associated_methods', |
223ec6f9 |
101 | 'insertion_order', |
1bd2739a |
102 | ); |
5659d76e |
103 | |
104 | is_deeply( |
9b871d79 |
105 | [ |
106 | sort Class::MOP::Mixin::AttributeCore->meta->get_attribute_list, |
107 | $meta->get_attribute_list |
108 | ], |
7d28758b |
109 | [ sort @attributes ], |
9b871d79 |
110 | '... our attribute list matches' |
111 | ); |
1d68af04 |
112 | |
5659d76e |
113 | foreach my $attribute_name (@attributes) { |
9b871d79 |
114 | ok( $meta->find_attribute_by_name($attribute_name), |
115 | '... Class::MOP::Attribute->find_attribute_by_name(' |
116 | . $attribute_name |
117 | . ')' ); |
5659d76e |
118 | } |
1d68af04 |
119 | |
120 | # We could add some tests here to make sure that |
121 | # the attribute have the appropriate |
122 | # accessor/reader/writer/predicate combinations, |
123 | # but that is getting a little excessive so I |
124 | # wont worry about it for now. Maybe if I get |
5659d76e |
125 | # bored I will do it. |
2d711cc8 |
126 | } |
86a4d873 |
127 | |
128 | done_testing; |