[Moose-commits] r7757 - Class-MOP/trunk/t

autarch at code2.0beta.co.uk autarch at code2.0beta.co.uk
Fri Feb 20 19:35:08 GMT 2009


Author: autarch
Date: 2009-02-20 11:35:08 -0800 (Fri, 20 Feb 2009)
New Revision: 7757

Added:
   Class-MOP/trunk/t/084_get_method_map.t
Log:
Add a test for a problem that the Moose tests were running into when
using a pure Perl CMOP


Added: Class-MOP/trunk/t/084_get_method_map.t
===================================================================
--- Class-MOP/trunk/t/084_get_method_map.t	                        (rev 0)
+++ Class-MOP/trunk/t/084_get_method_map.t	2009-02-20 19:35:08 UTC (rev 7757)
@@ -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' );
+}


Property changes on: Class-MOP/trunk/t/084_get_method_map.t
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Rev
Name: svn:eol-style
   + native




More information about the Moose-commits mailing list