6 use Test::More tests => 10;
10 This tests the classic diamond inheritence pattern.
23 sub hello { 'Diamond_A::hello' }
35 sub hello { 'Diamond_C::hello' }
39 use base ('Diamond_B', 'Diamond_C');
43 Class::C3::initialize();
47 [ Class::C3::calculateMRO('Diamond_D') ],
48 [ qw(Diamond_D Diamond_B Diamond_C Diamond_A) ],
49 '... got the right MRO for Diamond_D');
51 is(Diamond_D->hello, 'Diamond_C::hello', '... method resolved itself as expected');
53 is(Diamond_D->can('hello')->(), 'Diamond_C::hello', '... can(method) resolved itself as expected');
54 is(UNIVERSAL::can("Diamond_D", 'hello')->(), 'Diamond_C::hello', '... can(method) resolved itself as expected');
57 Class::C3::uninitialize();
59 is(Diamond_D->hello, 'Diamond_A::hello', '... old method resolution has been restored');
61 is(Diamond_D->can('hello')->(), 'Diamond_A::hello', '... can(method) resolution has been restored');
62 is(UNIVERSAL::can("Diamond_D", 'hello')->(), 'Diamond_A::hello', '... can(method) resolution has been restored');
64 Class::C3::initialize();
66 is(Diamond_D->hello, 'Diamond_C::hello', '... C3 method restored itself as expected');
68 is(Diamond_D->can('hello')->(), 'Diamond_C::hello', '... C3 can(method) restored itself as expected');
69 is(UNIVERSAL::can("Diamond_D", 'hello')->(), 'Diamond_C::hello', '... C3 can(method) restored itself as expected');