closed
[gitmo/Class-MOP.git] / t / 004_advanced_methods.t
index 83efe42..4a091d3 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 14;
 use Test::Exception;
 
 BEGIN {
@@ -36,7 +36,6 @@ A more real-world example would be a nice addition :)
     package Baz;
     our @ISA = ('Bar');
     
-    sub BUILD { 'Baz::BUILD' }    
     sub baz { 'Baz::baz' }
     sub foo { 'Baz::foo' }           
     
@@ -54,6 +53,25 @@ A more real-world example would be a nice addition :)
     sub foobarbaz { 'Foo::Bar::Baz::foobarbaz' }    
 }
 
+ok(!defined(Class::MOP::Class->initialize('Foo')->find_next_method_by_name('BUILD')), 
+   '... Foo::BUILD has not next method');
+
+is(Class::MOP::Class->initialize('Bar')->find_next_method_by_name('BUILD'), 
+   Class::MOP::Class->initialize('Foo')->get_method('BUILD'),     
+   '... Bar::BUILD does have a next method');
+   
+is(Class::MOP::Class->initialize('Baz')->find_next_method_by_name('BUILD'), 
+   Class::MOP::Class->initialize('Bar')->get_method('BUILD'),     
+   '... Baz->BUILD does have a next method');   
+   
+is(Class::MOP::Class->initialize('Foo::Bar')->find_next_method_by_name('BUILD'), 
+   Class::MOP::Class->initialize('Foo')->get_method('BUILD'),     
+   '... Foo::Bar->BUILD does have a next method');   
+   
+is(Class::MOP::Class->initialize('Foo::Bar::Baz')->find_next_method_by_name('BUILD'), 
+   Class::MOP::Class->initialize('Foo')->get_method('BUILD'),     
+   '... Foo::Bar::Baz->BUILD does have a next method');   
+
 is_deeply(
     [ sort { $a->{name} cmp $b->{name} } Class::MOP::Class->initialize('Foo')->compute_all_applicable_methods() ],
     [
@@ -94,11 +112,11 @@ is_deeply(
 
 is_deeply(
     [ sort { $a->{name} cmp $b->{name} } Class::MOP::Class->initialize('Baz')->compute_all_applicable_methods() ],
-    [
+    [   
         {
             name  => 'BUILD',
-            class => 'Baz',
-            code  => \&Baz::BUILD 
+            class => 'Bar',
+            code  => \&Bar::BUILD 
         },    
         {
             name  => 'bar',
@@ -215,11 +233,6 @@ is_deeply(
             name  => 'BUILD',
             class => 'Bar',
             code  => \&Bar::BUILD 
-        },    
-        {
-            name  => 'BUILD',
-            class => 'Baz',
-            code  => \&Baz::BUILD 
-        },        
+        },            
     ],
     '... got the right list of BUILD methods for Foo::Bar::Baz');
\ No newline at end of file