better accessor context descriptions in general
[gitmo/Moose.git] / t / cmop / attribute_introspection.t
CommitLineData
38bf2a25 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Fatal;
6
7use Class::MOP;
8
9{
10 my $attr = Class::MOP::Attribute->new('$test');
11 is( $attr->meta, Class::MOP::Attribute->meta,
12 '... instance and class both lead to the same meta' );
13}
14
15{
16 my $meta = Class::MOP::Attribute->meta();
17 isa_ok( $meta, 'Class::MOP::Class' );
18
19 my @methods = qw(
20 new
21 clone
22
23 initialize_instance_slot
24 _set_initial_slot_value
25 _make_initializer_writer_callback
26
27 name
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
39 has_insertion_order insertion_order _set_insertion_order
40
41 definition_context
42
43 slots
44 get_value
45 set_value
46 get_raw_value
47 set_raw_value
48 set_initial_value
49 has_value
50 clear_value
51
52 associated_class
53 attach_to_class
54 detach_from_class
55
56 accessor_metaclass
57
58 associated_methods
59 associate_method
60
61 process_accessors
62 _process_accessors
23917eec 63 _accessor_description
38bf2a25 64 install_accessors
65 remove_accessors
66
67 _inline_get_value
68 _inline_set_value
69 _inline_has_value
70 _inline_clear_value
71 _inline_instance_get
72 _inline_instance_set
73 _inline_instance_has
74 _inline_instance_clear
75
76 _new
77 );
78
79 is_deeply(
80 [
81 sort Class::MOP::Mixin::AttributeCore->meta->get_method_list,
82 $meta->get_method_list
83 ],
84 [ sort @methods ],
85 '... our method list matches'
86 );
87
88 foreach my $method_name (@methods) {
89 ok( $meta->find_method_by_name($method_name),
90 '... Class::MOP::Attribute->find_method_by_name(' . $method_name . ')' );
91 }
92
93 my @attributes = (
94 'name',
95 'accessor',
96 'reader',
97 'writer',
98 'predicate',
99 'clearer',
100 'builder',
101 'init_arg',
102 'initializer',
103 'definition_context',
104 'default',
105 'associated_class',
106 'associated_methods',
107 'insertion_order',
108 );
109
110 is_deeply(
111 [
112 sort Class::MOP::Mixin::AttributeCore->meta->get_attribute_list,
113 $meta->get_attribute_list
114 ],
115 [ sort @attributes ],
116 '... our attribute list matches'
117 );
118
119 foreach my $attribute_name (@attributes) {
120 ok( $meta->find_attribute_by_name($attribute_name),
121 '... Class::MOP::Attribute->find_attribute_by_name('
122 . $attribute_name
123 . ')' );
124 }
125
126 # We could add some tests here to make sure that
127 # the attribute have the appropriate
128 # accessor/reader/writer/predicate combinations,
129 # but that is getting a little excessive so I
130 # wont worry about it for now. Maybe if I get
131 # bored I will do it.
132}
133
134done_testing;