Class::MOP - refactoring the binary tree test code
[gitmo/Class-MOP.git] / t / 010_self_introspection.t
CommitLineData
a5eca695 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More no_plan => 1;
7use Test::Exception;
8
9BEGIN {
10 use_ok('Class::MOP::Class');
11}
12
2eb717d5 13my $meta = Class::MOP::Class->meta();
a5eca695 14isa_ok($meta, 'Class::MOP::Class');
15
16foreach my $method_name (qw(
2eb717d5 17 meta
18
a5eca695 19 initialize create
552e3d24 20
a5eca695 21 name version
552e3d24 22
a5eca695 23 superclasses class_precedence_list
552e3d24 24
a5eca695 25 has_method get_method add_method remove_method
26 get_method_list compute_all_applicable_methods find_all_methods_by_name
552e3d24 27
28 has_attribute get_attribute add_attribute remove_attribute
2eb717d5 29 get_attribute_list compute_all_applicable_attributes
a5eca695 30 )) {
31 ok($meta->has_method($method_name), '... Class::MOP::Class->has_method(' . $method_name . ')');
32 {
33 no strict 'refs';
34 is($meta->get_method($method_name),
35 \&{'Class::MOP::Class::' . $method_name},
36 '... Class::MOP::Class->get_method(' . $method_name . ') == &Class::MOP::Class::' . $method_name);
37 }
38}
39
2eb717d5 40foreach my $non_method_name (qw(
41 confess
42 blessed reftype
43 subname
44 svref_2object
45 )) {
46 ok(!$meta->has_method($non_method_name), '... NOT Class::MOP::Class->has_method(' . $non_method_name . ')');
47}
48
a5eca695 49is($meta->name, 'Class::MOP::Class', '... Class::MOP::Class->name');
50is($meta->version, $Class::MOP::Class::VERSION, '... Class::MOP::Class->version');
51
52is_deeply(
53 [ $meta->superclasses ],
54 [],
55 '... Class::MOP::Class->superclasses == []');
56
57is_deeply(
58 [ $meta->class_precedence_list ],
59 [ 'Class::MOP::Class' ],
60 '... Class::MOP::Class->class_precedence_list == []');
61