Remove shebangs from tests.
[gitmo/Class-MOP.git] / t / 014_attribute_introspection.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 62;
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         name
26         has_accessor      accessor
27         has_writer        writer
28         has_write_method  get_write_method  get_write_method_ref
29         has_reader        reader
30         has_read_method   get_read_method   get_read_method_ref
31         has_predicate     predicate
32         has_clearer       clearer
33         has_builder       builder
34         has_init_arg      init_arg
35         has_default       default           is_default_a_coderef
36         has_initializer   initializer
37
38         slots
39         get_value
40         set_value
41         set_initial_value
42         has_value
43         clear_value
44
45         associated_class
46         attach_to_class
47         detach_from_class
48
49         accessor_metaclass
50
51         associated_methods
52         associate_method
53
54         process_accessors
55         install_accessors
56         remove_accessors
57
58         _new
59         );
60
61     is_deeply(
62         [ sort $meta->get_method_list ],
63         [ sort @methods ],
64         '... our method list matches');
65
66     foreach my $method_name (@methods) {
67         ok($meta->has_method($method_name), '... Class::MOP::Attribute->has_method(' . $method_name . ')');
68     }
69
70     my @attributes = (
71         'name',
72         'accessor',
73         'reader',
74         'writer',
75         'predicate',
76         'clearer',
77         'builder',
78         'init_arg',
79         'initializer',
80         'default',
81         'associated_class',
82         'associated_methods',
83     );
84
85     is_deeply(
86         [ sort $meta->get_attribute_list ],
87         [ sort @attributes ],
88         '... our attribute list matches');
89
90     foreach my $attribute_name (@attributes) {
91         ok($meta->has_attribute($attribute_name), '... Class::MOP::Attribute->has_attribute(' . $attribute_name . ')');
92     }
93
94     # We could add some tests here to make sure that
95     # the attribute have the appropriate
96     # accessor/reader/writer/predicate combinations,
97     # but that is getting a little excessive so I
98     # wont worry about it for now. Maybe if I get
99     # bored I will do it.
100 }