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 # Doesn't work with core support, since reinit is not neccesary and the change
85 # takes effect immediately
87 skip "This test does not work with a c3-patched perl interpreter", 1
88 if $Class::C3::C3_IN_CORE;
89 is(Diamond_D->hello, 'Diamond_C::hello', '... method still resolves with old MRO');
92 Class::C3::reinitialize();
94 is(Diamond_D->hello, 'Diamond_E::hello', '... method resolves with reinitialized MRO');