renaming test
[gitmo/Class-MOP.git] / t / 014_attribute_introspection.t
CommitLineData
5659d76e 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 38;
7use Test::Exception;
8
9BEGIN {
10 use_ok('Class::MOP');
11}
12
13{
14 my $meta = Class::MOP::Attribute->meta();
15 isa_ok($meta, 'Class::MOP::Class');
16
17 my @methods = qw(
aa448b16 18 meta
5659d76e 19 new clone
20 name
21 has_accessor accessor
22 has_writer writer
23 has_reader reader
24 has_predicate predicate
25 has_init_arg init_arg
26 has_default default
27
28 associated_class
29 attach_to_class detach_from_class
30
31 generate_accessor_method
32 generate_reader_method
33 generate_writer_method
34 generate_predicate_method
35
36 process_accessors
37 install_accessors
38 remove_accessors
39 );
40
41 is_deeply(
42 [ sort @methods ],
43 [ sort $meta->get_method_list ],
44 '... our method list matches');
45
46 foreach my $method_name (@methods) {
47 ok($meta->has_method($method_name), '... Class::MOP::Attribute->has_method(' . $method_name . ')');
48 }
49
50 my @attributes = qw(
51 name accessor reader writer predicate
52 init_arg default associated_class
53 );
54
55 is_deeply(
56 [ sort @attributes ],
57 [ sort $meta->get_attribute_list ],
58 '... our attribute list matches');
59
60 foreach my $attribute_name (@attributes) {
61 ok($meta->has_attribute($attribute_name), '... Class::MOP::Attribute->has_attribute(' . $attribute_name . ')');
62 }
63
64 # We could add some tests here to make sure that
65 # the attribute have the appropriate
66 # accessor/reader/writer/predicate combinations,
67 # but that is getting a little excessive so I
68 # wont worry about it for now. Maybe if I get
69 # bored I will do it.
70}