File: universal_methods.t

package info (click to toggle)
libmoose-perl 2.4000-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,408 kB
  • sloc: perl: 21,275; ansic: 291; makefile: 10
file content (38 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use strict;
use warnings;

use Test::More;
use Class::MOP;

my $meta_class = Class::MOP::Class->create_anon_class;

my %methods      = map { $_->name => 1 } $meta_class->get_all_methods();
my %method_names = map { $_       => 1 } $meta_class->get_all_method_names();

my @universal_methods = qw/isa can VERSION/;
push @universal_methods, 'DOES' if "$]" >= 5.010;

for my $method (@universal_methods) {
    ok(
        $meta_class->find_method_by_name($method),
        "find_method_by_name finds UNIVERSAL method $method"
    );
    ok(
        $meta_class->find_next_method_by_name($method),
        "find_next_method_by_name finds UNIVERSAL method $method"
    );
    ok(
        scalar $meta_class->find_all_methods_by_name($method),
        "find_all_methods_by_name finds UNIVERSAL method $method"
    );
    ok(
        $methods{$method},
        "get_all_methods includes $method from UNIVERSAL"
    );
    ok(
        $method_names{$method},
        "get_all_method_names includes $method from UNIVERSAL"
    );
}

done_testing;