From: Dave Rolsky Date: Fri, 20 Feb 2009 19:35:08 +0000 (+0000) Subject: Add a test for a problem that the Moose tests were running into when X-Git-Tag: 0.77_01~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=481550a7b2017b399cec3c54ebfeed83bd41cb80;p=gitmo%2FClass-MOP.git Add a test for a problem that the Moose tests were running into when using a pure Perl CMOP --- diff --git a/t/084_get_method_map.t b/t/084_get_method_map.t new file mode 100644 index 0000000..6784548 --- /dev/null +++ b/t/084_get_method_map.t @@ -0,0 +1,48 @@ +use strict; +use warnings; + +use Test::More 'no_plan'; + + +{ + package Foo; + + use metaclass; + + sub foo { } +} + +{ + my $map = Foo->meta->get_method_map; + + is( scalar keys %{$map}, 2, + 'method map for Foo has two key' ); + ok( $map->{foo}, '... has a foo method in the map' ); + ok( $map->{meta}, '... has a meta method in the map' ); +} + + +Foo->meta->add_method( bar => sub { } ); + +{ + my $map = Foo->meta->get_method_map; + is( scalar keys %{$map}, 3, + 'method map for Foo has three keys' ); + ok( $map->{foo}, '... has a foo method in the map' ); + ok( $map->{bar}, '... has a bar method in the map' ); + ok( $map->{meta}, '... has a meta method in the map' ); +} + +# Tests a bug where after a metaclass object was recreated, methods +# added via add_method were not showing up in the map, but only with +# the non-XS version of the code. +Class::MOP::remove_metaclass_by_name('Foo'); + +{ + my $map = Foo->meta->get_method_map; + is( scalar keys %{$map}, 3, + 'method map for Foo has three keys' ); + ok( $map->{foo}, '... has a foo method in the map' ); + ok( $map->{bar}, '... has a bar method in the map' ); + ok( $map->{meta}, '... has a meta method in the map' ); +}