6 use Test::More tests => 7;
11 This example is take from: http://www.python.org/2.3/mro.html
30 Level 2 2 | E | 4 | D | | F | 5
36 Level 1 1 | B | | C | 3
45 (<class '__main__.A'>, <class '__main__.B'>, <class '__main__.E'>,
46 <class '__main__.C'>, <class '__main__.D'>, <class '__main__.F'>,
55 sub O_or_D { 'Test::O' }
56 sub O_or_F { 'Test::O' }
62 sub O_or_F { 'Test::F' }
72 sub O_or_D { 'Test::D' }
73 sub C_or_D { 'Test::D' }
76 use base ('Test::D', 'Test::F');
79 sub C_or_D { 'Test::C' }
82 use base ('Test::E', 'Test::D');
86 use base ('Test::B', 'Test::C');
90 Class::C3::initialize();
93 [ Class::C3::calculateMRO('Test::A') ],
94 [ qw(Test::A Test::B Test::E Test::C Test::D Test::F Test::O) ],
95 '... got the right MRO for Test::A');
97 is(Test::A->O_or_D, 'Test::D', '... got the right method dispatch');
98 is(Test::A->O_or_F, 'Test::F', '... got the right method dispatch');
101 # this test is particularly interesting because the p5 dispatch
102 # would actually call Test::D before Test::C and Test::D is a
103 # subclass of Test::C
104 is(Test::A->C_or_D, 'Test::C', '... got the right method dispatch');
106 Class::C3::uninitialize();
108 is(Test::A->O_or_D, 'Test::O', '... old dispatch order is restored');
109 is(Test::A->O_or_F, 'Test::O', '... old dispatch order is restored');
110 is(Test::A->C_or_D, 'Test::D', '... old dispatch order is restored');