6 use Test::More tests => 11;
10 # uncomment this line, and re-run the
11 # test to see the normal p5 dispatch order
12 #$Class::C3::TURN_OFF_C3 = 1;
17 This tests the classic diamond inheritence pattern.
30 sub hello { 'Diamond_A::hello' }
42 sub hello { 'Diamond_C::hello' }
46 use base ('Diamond_B', 'Diamond_C');
51 [ Class::C3::calculateMRO('Diamond_D') ],
52 [ qw(Diamond_D Diamond_B Diamond_C Diamond_A) ],
53 '... got the right MRO for Diamond_D');
55 is(Diamond_D->hello, 'Diamond_C::hello', '... method resolved itself as expected');
57 is(Diamond_D->can('hello')->(), 'Diamond_C::hello', '... can(method) resolved itself as expected');
58 is(UNIVERSAL::can("Diamond_D", 'hello')->(), 'Diamond_C::hello', '... can(method) resolved itself as expected');
61 Class::C3::uninitialize();
63 is(Diamond_D->hello, 'Diamond_A::hello', '... old method resolution has been restored');
65 is(Diamond_D->can('hello')->(), 'Diamond_A::hello', '... can(method) resolution has been restored');
66 is(UNIVERSAL::can("Diamond_D", 'hello')->(), 'Diamond_A::hello', '... can(method) resolution has been restored');
68 Class::C3::initialize();
70 is(Diamond_D->hello, 'Diamond_C::hello', '... C3 method restored itself as expected');
72 is(Diamond_D->can('hello')->(), 'Diamond_C::hello', '... C3 can(method) restored itself as expected');
73 is(UNIVERSAL::can("Diamond_D", 'hello')->(), 'Diamond_C::hello', '... C3 can(method) restored itself as expected');