6 require q(./test.pl); plan(tests => 5);
10 This tests the classic diamond inheritence pattern.
23 sub hello { 'Diamond_A::hello' }
24 sub foo { 'Diamond_A::foo' }
30 sub foo { 'Diamond_B::foo => ' . (shift)->next::method() }
37 sub hello { 'Diamond_C::hello => ' . (shift)->next::method() }
38 sub foo { 'Diamond_C::foo => ' . (shift)->next::method() }
42 use base ('Diamond_B', 'Diamond_C');
45 sub foo { 'Diamond_D::foo => ' . (shift)->next::method() }
49 mro::get_linear_isa('Diamond_D'),
50 [ qw(Diamond_D Diamond_B Diamond_C Diamond_A) ]
51 ), '... got the right MRO for Diamond_D');
53 is(Diamond_D->hello, 'Diamond_C::hello => Diamond_A::hello', '... method resolved itself as expected');
55 is(Diamond_D->can('hello')->('Diamond_D'),
56 'Diamond_C::hello => Diamond_A::hello',
57 '... can(method) resolved itself as expected');
59 is(UNIVERSAL::can("Diamond_D", 'hello')->('Diamond_D'),
60 'Diamond_C::hello => Diamond_A::hello',
61 '... can(method) resolved itself as expected');
64 'Diamond_D::foo => Diamond_B::foo => Diamond_C::foo => Diamond_A::foo',
65 '... method foo resolved itself as expected');