0.02 release
[gitmo/Class-C3.git] / t / 02_MRO.t
index 643cdec..f04b193 100644 (file)
@@ -7,10 +7,25 @@ use Test::More tests => 15;
 
 BEGIN {
     use_ok('Class::C3');
+    # uncomment this line, and re-run the
+    # test to see the normal p5 dispatch order
+    #$Class::C3::TURN_OFF_C3 = 1;    
 }
 
 =pod
 
+This example is take from: http://www.python.org/2.3/mro.html
+
+"My first example"
+class O: pass
+class F(O): pass
+class E(O): pass
+class D(O): pass
+class C(D,F): pass
+class B(D,E): pass
+class A(B,C): pass
+
+
                           6
                          ---
 Level 3                 | O |                  (more general)
@@ -104,13 +119,16 @@ is_deeply(
 is(Test::A->C_or_D, 'Test::C', '... got the expected method output');
 is(Test::A->can('C_or_D')->(), 'Test::C', '... can got the expected method output');
 
-is(Test::B->C_or_D, 'Test::D', '... got the expected method output');
-is(Test::B->can('C_or_D')->(), 'Test::D', '... can got the expected method output');
-
 is(Test::A->C_or_E, 'Test::C', '... got the expected method output');
 is(Test::A->can('C_or_E')->(), 'Test::C', '... can got the expected method output');
 
-is(Test::B->C_or_E, 'Test::E', '... got the expected method output');
-is(Test::B->can('C_or_E')->(), 'Test::E', '... can got the expected method output');
+# remove the C3
+Class::C3::uninitialize();
+
+is(Test::A->C_or_D, 'Test::D', '...  old method resolution has been restored');
+is(Test::A->can('C_or_D')->(), 'Test::D', '...  old can(method) resolution has been restored');
+
+is(Test::A->C_or_E, 'Test::E', '...  old method resolution has been restored');
+is(Test::A->can('C_or_E')->(), 'Test::E', '...  old can(method) resolution has been restored');
 
     
\ No newline at end of file