Fix tests after bootstrap change
[gitmo/Class-MOP.git] / t / 014_attribute_introspection.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 72;
5 use Test::Exception;
6
7 use Class::MOP;
8
9 {
10     my $attr = Class::MOP::Attribute->new('$test');
11     is($attr->meta, Class::MOP::Attribute->meta, '... instance and class both lead to the same meta');
12 }
13
14 {
15     my $meta = Class::MOP::Attribute->meta();
16     isa_ok($meta, 'Class::MOP::Class');
17
18     my @methods = qw(
19         new
20         clone
21
22         initialize_instance_slot
23         _set_initial_slot_value
24
25         is_lazy
26         name
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
38         has_insertion_order insertion_order _set_insertion_order
39
40         definition_context
41
42         slots
43         get_value
44         set_value
45         get_raw_value
46         set_raw_value
47         set_initial_value
48         has_value
49         clear_value
50
51         associated_class
52         attach_to_class
53         detach_from_class
54
55         accessor_metaclass
56
57         associated_methods
58         associate_method
59
60         process_accessors
61         _process_accessors
62         install_accessors
63         remove_accessors
64
65         _call_builder
66         _new
67         );
68
69     is_deeply(
70         [ sort $meta->get_method_list ],
71         [ sort @methods ],
72         '... our method list matches');
73
74     foreach my $method_name (@methods) {
75         ok($meta->has_method($method_name), '... Class::MOP::Attribute->has_method(' . $method_name . ')');
76     }
77
78     my @attributes = (
79         'lazy',
80         'name',
81         'accessor',
82         'reader',
83         'writer',
84         'predicate',
85         'clearer',
86         'builder',
87         'init_arg',
88         'initializer',
89         'definition_context',
90         'default',
91         'associated_class',
92         'associated_methods',
93         'insertion_order',
94     );
95
96     is_deeply(
97         [ sort $meta->get_attribute_list ],
98         [ sort @attributes ],
99         '... our attribute list matches');
100
101     foreach my $attribute_name (@attributes) {
102         ok($meta->has_attribute($attribute_name), '... Class::MOP::Attribute->has_attribute(' . $attribute_name . ')');
103     }
104
105     # We could add some tests here to make sure that
106     # the attribute have the appropriate
107     # accessor/reader/writer/predicate combinations,
108     # but that is getting a little excessive so I
109     # wont worry about it for now. Maybe if I get
110     # bored I will do it.
111 }