6 use Test::More tests => 6;
9 use lib 'opt', '../opt', '..';
11 # uncomment this line, and re-run the
12 # test to see the normal p5 dispatch order
13 #$Class::C3::TURN_OFF_C3 = 1;
18 This tests the classic diamond inheritence pattern.
31 sub hello { 'Diamond_A::hello' }
32 sub foo { 'Diamond_A::foo' }
38 sub foo { 'Diamond_B::foo => ' . (shift)->next::method() }
45 sub hello { 'Diamond_C::hello => ' . (shift)->next::method() }
46 sub foo { 'Diamond_C::foo => ' . (shift)->next::method() }
50 use base ('Diamond_B', 'Diamond_C');
53 sub foo { 'Diamond_D::foo => ' . (shift)->next::method() }
57 [ Class::C3::calculateMRO('Diamond_D') ],
58 [ qw(Diamond_D Diamond_B Diamond_C Diamond_A) ],
59 '... got the right MRO for Diamond_D');
61 is(Diamond_D->hello, 'Diamond_C::hello => Diamond_A::hello', '... method resolved itself as expected');
63 is(Diamond_D->can('hello')->('Diamond_D'),
64 'Diamond_C::hello => Diamond_A::hello',
65 '... can(method) resolved itself as expected');
67 is(UNIVERSAL::can("Diamond_D", 'hello')->('Diamond_D'),
68 'Diamond_C::hello => Diamond_A::hello',
69 '... can(method) resolved itself as expected');
72 'Diamond_D::foo => Diamond_B::foo => Diamond_C::foo => Diamond_A::foo',
73 '... method foo resolved itself as expected');