We only need local $? if we inline calls to DEMOLISH
[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
38bf2a25 61 _process_accessors
0ea503fa 62 _accessor_description
38bf2a25 63 install_accessors
64 remove_accessors
65
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
74
75 _new
76 );
77
78 is_deeply(
79 [
80 sort Class::MOP::Mixin::AttributeCore->meta->get_method_list,
81 $meta->get_method_list
82 ],
83 [ sort @methods ],
84 '... our method list matches'
85 );
86
87 foreach my $method_name (@methods) {
88 ok( $meta->find_method_by_name($method_name),
89 '... Class::MOP::Attribute->find_method_by_name(' . $method_name . ')' );
90 }
91
92 my @attributes = (
93 'name',
94 'accessor',
95 'reader',
96 'writer',
97 'predicate',
98 'clearer',
99 'builder',
100 'init_arg',
101 'initializer',
102 'definition_context',
103 'default',
104 'associated_class',
105 'associated_methods',
106 'insertion_order',
107 );
108
109 is_deeply(
110 [
111 sort Class::MOP::Mixin::AttributeCore->meta->get_attribute_list,
112 $meta->get_attribute_list
113 ],
114 [ sort @attributes ],
115 '... our attribute list matches'
116 );
117
118 foreach my $attribute_name (@attributes) {
119 ok( $meta->find_attribute_by_name($attribute_name),
120 '... Class::MOP::Attribute->find_attribute_by_name('
121 . $attribute_name
122 . ')' );
123 }
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
130 # bored I will do it.
131}
132
133done_testing;