6 use Test::More tests => 14;
10 This example is take from: http://www.python.org/2.3/mro.html
24 Level 3 | O | (more general)
30 Level 2 3 | D | 4| E | | F | 5 |
36 Level 1 1 | B | | C | 2 |
41 Level 0 0 | A | (more specialized)
58 sub C_or_E { 'Test::E' }
64 sub C_or_D { 'Test::D' }
67 use base ('Test::D', 'Test::F');
70 sub C_or_D { 'Test::C' }
71 sub C_or_E { 'Test::C' }
75 use base ('Test::D', 'Test::E');
78 use base ('Test::B', 'Test::C');
82 Class::C3::initialize();
85 [ Class::C3::calculateMRO('Test::F') ],
86 [ qw(Test::F Test::O) ],
87 '... got the right MRO for Test::F');
90 [ Class::C3::calculateMRO('Test::E') ],
91 [ qw(Test::E Test::O) ],
92 '... got the right MRO for Test::E');
95 [ Class::C3::calculateMRO('Test::D') ],
96 [ qw(Test::D Test::O) ],
97 '... got the right MRO for Test::D');
100 [ Class::C3::calculateMRO('Test::C') ],
101 [ qw(Test::C Test::D Test::F Test::O) ],
102 '... got the right MRO for Test::C');
105 [ Class::C3::calculateMRO('Test::B') ],
106 [ qw(Test::B Test::D Test::E Test::O) ],
107 '... got the right MRO for Test::B');
110 [ Class::C3::calculateMRO('Test::A') ],
111 [ qw(Test::A Test::B Test::C Test::D Test::E Test::F Test::O) ],
112 '... got the right MRO for Test::A');
114 is(Test::A->C_or_D, 'Test::C', '... got the expected method output');
115 is(Test::A->can('C_or_D')->(), 'Test::C', '... can got the expected method output');
117 is(Test::A->C_or_E, 'Test::C', '... got the expected method output');
118 is(Test::A->can('C_or_E')->(), 'Test::C', '... can got the expected method output');
121 Class::C3::uninitialize();
123 is(Test::A->C_or_D, 'Test::D', '... old method resolution has been restored');
124 is(Test::A->can('C_or_D')->(), 'Test::D', '... old can(method) resolution has been restored');
126 is(Test::A->C_or_E, 'Test::E', '... old method resolution has been restored');
127 is(Test::A->can('C_or_E')->(), 'Test::E', '... old can(method) resolution has been restored');