Test that UNIVERSAL methods are found through all method introspection methods
[gitmo/Moose.git] / t / cmop / universal_methods.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Class::MOP;
6
7 my $meta_class = Class::MOP::Class->create_anon_class;
8
9 my %methods      = map { $_->name => 1 } $meta_class->get_all_methods();
10 my %method_names = map { $_       => 1 } $meta_class->get_all_method_names();
11
12 my @universal_methods = qw/isa can VERSION/;
13 push @universal_methods, 'DOES' if $] >= 5.010;
14
15 for my $method (@universal_methods) {
16     ok(
17         $meta_class->find_method_by_name($method),
18         "find_method_by_name finds UNIVERSAL method $method"
19     );
20     ok(
21         $meta_class->find_next_method_by_name($method),
22         "find_next_method_by_name finds UNIVERSAL method $method"
23     );
24     ok(
25         scalar $meta_class->find_all_methods_by_name($method),
26         "find_all_methods_by_name finds UNIVERSAL method $method"
27     );
28     ok(
29         $methods{$method},
30         "get_all_methods includes $method from UNIVERSAL"
31     );
32     ok(
33         $method_names{$method},
34         "get_all_method_names includes $method from UNIVERSAL"
35     );
36 }
37
38 done_testing;