Commit | Line | Data |
---|---|---|
e1a479c5 BB |
1 | #!./perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | BEGIN { | |
6 | unless (-d 'blib') { | |
7 | chdir 't' if -d 't'; | |
8 | @INC = '../lib'; | |
9 | } | |
10 | } | |
11 | ||
12 | use Test::More tests => 1; | |
13 | use mro; | |
14 | ||
15 | =pod | |
16 | ||
17 | example taken from: L<http://gauss.gwydiondylan.org/books/drm/drm_50.html> | |
18 | ||
19 | Object | |
20 | ^ | |
21 | | | |
22 | LifeForm | |
23 | ^ ^ | |
24 | / \ | |
25 | Sentient BiPedal | |
26 | ^ ^ | |
27 | | | | |
28 | Intelligent Humanoid | |
29 | ^ ^ | |
30 | \ / | |
31 | Vulcan | |
32 | ||
33 | define class <sentient> (<life-form>) end class; | |
34 | define class <bipedal> (<life-form>) end class; | |
35 | define class <intelligent> (<sentient>) end class; | |
36 | define class <humanoid> (<bipedal>) end class; | |
37 | define class <vulcan> (<intelligent>, <humanoid>) end class; | |
38 | ||
39 | =cut | |
40 | ||
41 | { | |
42 | package Object; | |
43 | use mro 'c3'; | |
44 | ||
45 | package LifeForm; | |
46 | use mro 'c3'; | |
47 | use base 'Object'; | |
48 | ||
49 | package Sentient; | |
50 | use mro 'c3'; | |
51 | use base 'LifeForm'; | |
52 | ||
53 | package BiPedal; | |
54 | use mro 'c3'; | |
55 | use base 'LifeForm'; | |
56 | ||
57 | package Intelligent; | |
58 | use mro 'c3'; | |
59 | use base 'Sentient'; | |
60 | ||
61 | package Humanoid; | |
62 | use mro 'c3'; | |
63 | use base 'BiPedal'; | |
64 | ||
65 | package Vulcan; | |
66 | use mro 'c3'; | |
67 | use base ('Intelligent', 'Humanoid'); | |
68 | } | |
69 | ||
70 | is_deeply( | |
71 | mro::get_linear_isa('Vulcan'), | |
72 | [ qw(Vulcan Intelligent Sentient Humanoid BiPedal LifeForm Object) ], | |
73 | '... got the right MRO for the Vulcan Dylan Example'); |