6 use Test::More tests => 5;
10 # uncomment this line, and re-run the
11 # test to see the normal p5 dispatch order
12 #$Class::C3::TURN_OFF_C3 = 1;
30 sub hello { 'Diamond_A::hello' }
41 sub hello { 'Diamond_C::hello' }
45 use base ('Diamond_B', 'Diamond_C');
49 Class::C3::initialize();
52 [ Class::C3::calculateMRO('Diamond_D') ],
53 [ qw(Diamond_D Diamond_B Diamond_C Diamond_A) ],
54 '... got the right MRO for Diamond_D');
58 Then change it to this:
71 sub hello { 'Diamond_E::hello' }
76 unshift @{"Diamond_B::ISA"} => 'Diamond_E';
80 [ Class::C3::calculateMRO('Diamond_D') ],
81 [ qw(Diamond_D Diamond_B Diamond_E Diamond_C Diamond_A) ],
82 '... got the new MRO for Diamond_D');
84 is(Diamond_D->hello, 'Diamond_C::hello', '... method still resolves with old MRO');
86 Class::C3::reinitialize();
88 is(Diamond_D->hello, 'Diamond_E::hello', '... method resolves with reinitialized MRO');