This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Typos, POD errors, etc.
[perl5.git] / t / mro / basic_05_c3.t
CommitLineData
e1a479c5
BB
1#!./perl
2
3use strict;
4use warnings;
e1a479c5 5
c94dd5be 6require q(./test.pl); plan(tests => 2);
e1a479c5
BB
7
8=pod
9
10This tests a strange bug found by Matt S. Trout
11while building DBIx::Class. Thanks Matt!!!!
12
13 <A>
14 / \
15<C> <B>
16 \ /
17 <D>
18
19=cut
20
21{
22 package Diamond_A;
23 use mro 'c3';
24
25 sub foo { 'Diamond_A::foo' }
26}
27{
28 package Diamond_B;
29 use base 'Diamond_A';
30 use mro 'c3';
31
32 sub foo { 'Diamond_B::foo => ' . (shift)->SUPER::foo }
33}
34{
35 package Diamond_C;
36 use mro 'c3';
37 use base 'Diamond_A';
38
39}
40{
41 package Diamond_D;
42 use base ('Diamond_C', 'Diamond_B');
43 use mro 'c3';
44
45 sub foo { 'Diamond_D::foo => ' . (shift)->SUPER::foo }
46}
47
c94dd5be 48ok(eq_array(
e1a479c5 49 mro::get_linear_isa('Diamond_D'),
c94dd5be
RGS
50 [ qw(Diamond_D Diamond_C Diamond_B Diamond_A) ]
51), '... got the right MRO for Diamond_D');
e1a479c5
BB
52
53is(Diamond_D->foo,
54 'Diamond_D::foo => Diamond_B::foo => Diamond_A::foo',
55 '... got the right next::method dispatch path');