Use double-quotes and quotemeta for inlined hash slot access.
[gitmo/Class-MOP.git] / t / 084_get_method_map.t
CommitLineData
481550a7 1use strict;
2use warnings;
3
0eb2340f 4use Test::More tests => 11;
481550a7 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
25Foo->meta->add_method( bar => sub { } );
26
27{
28 my $map = Foo->meta->get_method_map;
8c975dc7 29
481550a7 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.
40Class::MOP::remove_metaclass_by_name('Foo');
41
42{
43 my $map = Foo->meta->get_method_map;
8c975dc7 44
481550a7 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}