Commit | Line | Data |
a5eca695 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
351bd7d4 |
6 | use Test::More tests => 60; |
a5eca695 |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
727919c5 |
10 | use_ok('Class::MOP'); |
a5eca695 |
11 | use_ok('Class::MOP::Class'); |
12 | } |
13 | |
2eb717d5 |
14 | my $meta = Class::MOP::Class->meta(); |
a5eca695 |
15 | isa_ok($meta, 'Class::MOP::Class'); |
16 | |
17 | foreach my $method_name (qw( |
2eb717d5 |
18 | meta |
19 | |
a5eca695 |
20 | initialize create |
552e3d24 |
21 | |
a5eca695 |
22 | name version |
552e3d24 |
23 | |
a5eca695 |
24 | superclasses class_precedence_list |
552e3d24 |
25 | |
a5eca695 |
26 | has_method get_method add_method remove_method |
27 | get_method_list compute_all_applicable_methods find_all_methods_by_name |
552e3d24 |
28 | |
29 | has_attribute get_attribute add_attribute remove_attribute |
2eb717d5 |
30 | get_attribute_list compute_all_applicable_attributes |
a5eca695 |
31 | )) { |
32 | ok($meta->has_method($method_name), '... Class::MOP::Class->has_method(' . $method_name . ')'); |
33 | { |
34 | no strict 'refs'; |
35 | is($meta->get_method($method_name), |
36 | \&{'Class::MOP::Class::' . $method_name}, |
37 | '... Class::MOP::Class->get_method(' . $method_name . ') == &Class::MOP::Class::' . $method_name); |
38 | } |
39 | } |
40 | |
2eb717d5 |
41 | foreach my $non_method_name (qw( |
42 | confess |
43 | blessed reftype |
44 | subname |
45 | svref_2object |
46 | )) { |
47 | ok(!$meta->has_method($non_method_name), '... NOT Class::MOP::Class->has_method(' . $non_method_name . ')'); |
48 | } |
49 | |
727919c5 |
50 | foreach my $attribute_name ( |
351bd7d4 |
51 | '$:package', '%:attributes', |
52 | '$:attribute_metaclass', '$:method_metaclass' |
727919c5 |
53 | ) { |
54 | ok($meta->has_attribute($attribute_name), '... Class::MOP::Class->has_attribute(' . $attribute_name . ')'); |
55 | isa_ok($meta->get_attribute($attribute_name), 'Class::MOP::Attribute'); |
56 | } |
57 | |
a5eca695 |
58 | is($meta->name, 'Class::MOP::Class', '... Class::MOP::Class->name'); |
59 | is($meta->version, $Class::MOP::Class::VERSION, '... Class::MOP::Class->version'); |
60 | |
61 | is_deeply( |
62 | [ $meta->superclasses ], |
63 | [], |
64 | '... Class::MOP::Class->superclasses == []'); |
65 | |
66 | is_deeply( |
67 | [ $meta->class_precedence_list ], |
68 | [ 'Class::MOP::Class' ], |
69 | '... Class::MOP::Class->class_precedence_list == []'); |
70 | |