Commit | Line | Data |
---|---|---|
e1a479c5 BB |
1 | #!./perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
e1a479c5 | 5 | |
c94dd5be | 6 | require q(./test.pl); plan(tests => 1); |
e1a479c5 BB |
7 | |
8 | =pod | |
9 | ||
0cd29a24 | 10 | example taken from: L<http://www.opendylan.org/books/drm/Method_Dispatch> |
e1a479c5 BB |
11 | |
12 | Object | |
13 | ^ | |
14 | | | |
15 | LifeForm | |
16 | ^ ^ | |
17 | / \ | |
18 | Sentient BiPedal | |
19 | ^ ^ | |
20 | | | | |
21 | Intelligent Humanoid | |
22 | ^ ^ | |
23 | \ / | |
24 | Vulcan | |
25 | ||
26 | define class <sentient> (<life-form>) end class; | |
27 | define class <bipedal> (<life-form>) end class; | |
28 | define class <intelligent> (<sentient>) end class; | |
29 | define class <humanoid> (<bipedal>) end class; | |
30 | define class <vulcan> (<intelligent>, <humanoid>) end class; | |
31 | ||
32 | =cut | |
33 | ||
34 | { | |
35 | package Object; | |
36 | use mro 'c3'; | |
37 | ||
38 | package LifeForm; | |
39 | use mro 'c3'; | |
40 | use base 'Object'; | |
41 | ||
42 | package Sentient; | |
43 | use mro 'c3'; | |
44 | use base 'LifeForm'; | |
45 | ||
46 | package BiPedal; | |
47 | use mro 'c3'; | |
48 | use base 'LifeForm'; | |
49 | ||
50 | package Intelligent; | |
51 | use mro 'c3'; | |
52 | use base 'Sentient'; | |
53 | ||
54 | package Humanoid; | |
55 | use mro 'c3'; | |
56 | use base 'BiPedal'; | |
57 | ||
58 | package Vulcan; | |
59 | use mro 'c3'; | |
60 | use base ('Intelligent', 'Humanoid'); | |
61 | } | |
62 | ||
c94dd5be | 63 | ok(eq_array( |
e1a479c5 | 64 | mro::get_linear_isa('Vulcan'), |
c94dd5be RGS |
65 | [ qw(Vulcan Intelligent Sentient Humanoid BiPedal LifeForm Object) ] |
66 | ), '... got the right MRO for the Vulcan Dylan Example'); |