X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F02_MRO.t;h=eb989d43206fce692d7157b4990cf72bd3f44bf8;hb=4ae4bd680ce54f13382324bc268361d17c3503f1;hp=643cdec8cba0b329c1c7ebf00b84ca625201aa58;hpb=95bebf8c9b18222ddc1363d529f6fd6db46ae50a;p=gitmo%2FClass-C3.git diff --git a/t/02_MRO.t b/t/02_MRO.t index 643cdec..eb989d4 100644 --- a/t/02_MRO.t +++ b/t/02_MRO.t @@ -3,14 +3,22 @@ use strict; use warnings; -use Test::More tests => 15; - -BEGIN { - use_ok('Class::C3'); -} +use Test::More tests => 14; =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) @@ -71,6 +79,8 @@ Level 0 0 | A | (more specialized) use Class::C3; } +Class::C3::initialize(); + is_deeply( [ Class::C3::calculateMRO('Test::F') ], [ qw(Test::F Test::O) ], @@ -104,13 +114,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'); - \ No newline at end of file +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'); + +