Class-MOP = bunch of moving stuff around
[gitmo/Class-MOP.git] / t / 010_self_introspection.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More no_plan => 1;
7 use Test::Exception;
8
9 BEGIN {
10     use_ok('Class::MOP::Class');        
11 }
12
13 my $meta = Class::MOP::Class->initialize('Class::MOP::Class');
14 isa_ok($meta, 'Class::MOP::Class');
15
16 foreach my $method_name (qw(
17     initialize create
18     
19     name version
20     
21     superclasses class_precedence_list
22     
23     has_method get_method add_method remove_method 
24     get_method_list compute_all_applicable_methods find_all_methods_by_name
25     
26     has_attribute get_attribute add_attribute remove_attribute
27     get_attribute_list compute_all_applicable_attributes create_all_accessors
28     )) {
29     ok($meta->has_method($method_name), '... Class::MOP::Class->has_method(' . $method_name . ')');
30     {
31         no strict 'refs';
32         is($meta->get_method($method_name), 
33            \&{'Class::MOP::Class::' . $method_name},
34            '... Class::MOP::Class->get_method(' . $method_name . ') == &Class::MOP::Class::' . $method_name);        
35     }
36 }
37
38 is($meta->name, 'Class::MOP::Class', '... Class::MOP::Class->name');
39 is($meta->version, $Class::MOP::Class::VERSION, '... Class::MOP::Class->version');
40
41 is_deeply(
42     [ $meta->superclasses ], 
43     [], 
44     '... Class::MOP::Class->superclasses == []');
45     
46 is_deeply(
47     [ $meta->class_precedence_list ], 
48     [ 'Class::MOP::Class' ], 
49     '... Class::MOP::Class->class_precedence_list == []');
50