Class::MOP with XS
[gitmo/Class-MOP.git] / t / 003_methods.t
index 4d46a68..9dfcb9e 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 64;
+use Test::More tests => 66;
 use Test::Exception;
 
 use Scalar::Util qw/reftype/;
@@ -21,6 +21,9 @@ BEGIN {
     # import a sub
     use Scalar::Util 'blessed'; 
     
+    sub pie;
+    sub cake ();
+
     use constant FOO_CONSTANT => 'Foo-CONSTANT';
     
     # define a sub in package
@@ -56,6 +59,9 @@ BEGIN {
 
 my $Foo = Class::MOP::Class->initialize('Foo');
 
+ok(!$Foo->has_method('pie'), '... got the method stub pie');
+ok(!$Foo->has_method('cake'), '... got the constant method stub cake');
+
 my $foo = sub { 'Foo::foo' };
 
 ok(!UNIVERSAL::isa($foo, 'Class::MOP::Method'), '... our method is not yet blessed');
@@ -95,7 +101,7 @@ ok(!$OinkyBoinky->has_method('bar'), "the method 'bar' is not defined in OinkyBo
 
 ok(my $bar = $OinkyBoinky->find_method_by_name('bar'), "but if you look in the inheritence chain then 'bar' does exist");
 
-is( reftype($bar), "CODE", "the returned value is a code ref" );
+is( reftype($bar->body), "CODE", "the returned value is a code ref" );
 
 
 # calling get_method blessed them all
@@ -110,7 +116,7 @@ for my $method_name (qw/FOO_CONSTANT
     isa_ok($Foo->get_method($method_name), 'Class::MOP::Method');
     {
         no strict 'refs';
-        is($Foo->get_method($method_name)->body, \&{'Foo::' . $method_name}, '... body matches CODE ref in package');
+        is($Foo->get_method($method_name)->body, \&{'Foo::' . $method_name}, '... body matches CODE ref in package for ' . $method_name);
     }
 }