Do not return anything from load_class.
[gitmo/Class-MOP.git] / t / 084_get_method_map.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 11;
5
6
7 {
8     package Foo;
9
10     use metaclass;
11
12     sub foo { }
13 }
14
15 {
16     my $map = Foo->meta->get_method_map;
17
18     is( scalar keys %{$map}, 2,
19         'method map for Foo has two key' );
20     ok( $map->{foo}, '... has a foo method in the map' );
21     ok( $map->{meta}, '... has a meta method in the map' );
22 }
23
24
25 Foo->meta->add_method( bar => sub { } );
26
27 {
28     my $map = Foo->meta->get_method_map;
29
30     is( scalar keys %{$map}, 3,
31         'method map for Foo has three keys' );
32     ok( $map->{foo}, '... has a foo method in the map' );
33     ok( $map->{bar}, '... has a bar method in the map' );
34     ok( $map->{meta}, '... has a meta method in the map' );
35 }
36
37 # Tests a bug where after a metaclass object was recreated, methods
38 # added via add_method were not showing up in the map, but only with
39 # the non-XS version of the code.
40 Class::MOP::remove_metaclass_by_name('Foo');
41
42 {
43     my $map = Foo->meta->get_method_map;
44
45     is( scalar keys %{$map}, 3,
46         'method map for Foo has three keys' );
47     ok( $map->{foo}, '... has a foo method in the map' );
48     ok( $map->{bar}, '... has a bar method in the map' );
49     ok( $map->{meta}, '... has a meta method in the map' );
50 }