This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
OS2-Process/Process.pm: Fix broken pod links
[perl5.git] / t / mro / complex_dfs.t
CommitLineData
e1a479c5
BB
1#!./perl
2
3use strict;
4use warnings;
e1a479c5 5
c94dd5be 6require q(./test.pl); plan(tests => 11);
e1a479c5
BB
7
8=pod
9
10This example is taken from: http://rt.cpan.org/Public/Bug/Display.html?id=20879
11
12 --- --- ---
13Level 5 8 | A | 9 | B | A | C | (More General)
14 --- --- --- V
15 \ | / |
16 \ | / |
17 \ | / |
18 \ | / |
19 --- |
20Level 4 7 | D | |
21 --- |
22 / \ |
23 / \ |
24 --- --- |
25Level 3 4 | G | 6 | E | |
26 --- --- |
27 | | |
28 | | |
29 --- --- |
30Level 2 3 | H | 5 | F | |
31 --- --- |
32 \ / | |
33 \ / | |
34 \ | |
35 / \ | |
36 / \ | |
37 --- --- |
38Level 1 1 | J | 2 | I | |
39 --- --- |
40 \ / |
41 \ / |
42 --- v
43Level 0 0 | K | (More Specialized)
44 ---
45
46
470123456789A
48KJIHGFEDABC
49
50=cut
51
52{
53 package Test::A; use mro 'dfs';
54
55 package Test::B; use mro 'dfs';
56
57 package Test::C; use mro 'dfs';
58
59 package Test::D; use mro 'dfs';
60 use base qw/Test::A Test::B Test::C/;
61
62 package Test::E; use mro 'dfs';
63 use base qw/Test::D/;
64
65 package Test::F; use mro 'dfs';
66 use base qw/Test::E/;
67
68 package Test::G; use mro 'dfs';
69 use base qw/Test::D/;
70
71 package Test::H; use mro 'dfs';
72 use base qw/Test::G/;
73
74 package Test::I; use mro 'dfs';
75 use base qw/Test::H Test::F/;
76
77 package Test::J; use mro 'dfs';
78 use base qw/Test::F/;
79
80 package Test::K; use mro 'dfs';
81 use base qw/Test::J Test::I/;
82}
83
c94dd5be 84ok(eq_array(
e1a479c5 85 mro::get_linear_isa('Test::A'),
c94dd5be
RGS
86 [ qw(Test::A) ]
87), '... got the right DFS merge order for Test::A');
e1a479c5 88
c94dd5be 89ok(eq_array(
e1a479c5 90 mro::get_linear_isa('Test::B'),
c94dd5be
RGS
91 [ qw(Test::B) ]
92), '... got the right DFS merge order for Test::B');
e1a479c5 93
c94dd5be 94ok(eq_array(
e1a479c5 95 mro::get_linear_isa('Test::C'),
c94dd5be
RGS
96 [ qw(Test::C) ]
97), '... got the right DFS merge order for Test::C');
e1a479c5 98
c94dd5be 99ok(eq_array(
e1a479c5 100 mro::get_linear_isa('Test::D'),
c94dd5be
RGS
101 [ qw(Test::D Test::A Test::B Test::C) ]
102), '... got the right DFS merge order for Test::D');
e1a479c5 103
c94dd5be 104ok(eq_array(
e1a479c5 105 mro::get_linear_isa('Test::E'),
c94dd5be
RGS
106 [ qw(Test::E Test::D Test::A Test::B Test::C) ]
107), '... got the right DFS merge order for Test::E');
e1a479c5 108
c94dd5be 109ok(eq_array(
e1a479c5 110 mro::get_linear_isa('Test::F'),
c94dd5be
RGS
111 [ qw(Test::F Test::E Test::D Test::A Test::B Test::C) ]
112), '... got the right DFS merge order for Test::F');
e1a479c5 113
c94dd5be 114ok(eq_array(
e1a479c5 115 mro::get_linear_isa('Test::G'),
c94dd5be
RGS
116 [ qw(Test::G Test::D Test::A Test::B Test::C) ]
117), '... got the right DFS merge order for Test::G');
e1a479c5 118
c94dd5be 119ok(eq_array(
e1a479c5 120 mro::get_linear_isa('Test::H'),
c94dd5be
RGS
121 [ qw(Test::H Test::G Test::D Test::A Test::B Test::C) ]
122), '... got the right DFS merge order for Test::H');
e1a479c5 123
c94dd5be 124ok(eq_array(
e1a479c5 125 mro::get_linear_isa('Test::I'),
c94dd5be
RGS
126 [ qw(Test::I Test::H Test::G Test::D Test::A Test::B Test::C Test::F Test::E) ]
127), '... got the right DFS merge order for Test::I');
e1a479c5 128
c94dd5be 129ok(eq_array(
e1a479c5 130 mro::get_linear_isa('Test::J'),
c94dd5be
RGS
131 [ qw(Test::J Test::F Test::E Test::D Test::A Test::B Test::C) ]
132), '... got the right DFS merge order for Test::J');
e1a479c5 133
c94dd5be 134ok(eq_array(
e1a479c5 135 mro::get_linear_isa('Test::K'),
c94dd5be
RGS
136 [ qw(Test::K Test::J Test::F Test::E Test::D Test::A Test::B Test::C Test::I Test::H Test::G) ]
137), '... got the right DFS merge order for Test::K');