File: vulcan_dfs.t

package info (click to toggle)
perl 5.20.2-3%2Bdeb8u11
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 102,964 kB
  • sloc: perl: 555,553; ansic: 214,041; sh: 38,121; pascal: 8,783; cpp: 3,895; makefile: 2,393; xml: 2,325; yacc: 1,741
file content (66 lines) | stat: -rw-r--r-- 1,341 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!./perl

use strict;
use warnings;

require q(./test.pl); plan(tests => 1);

=pod

example taken from: L<http://www.opendylan.org/books/drm/Method_Dispatch>

         Object
           ^
           |
        LifeForm 
         ^    ^
        /      \
   Sentient    BiPedal
      ^          ^
      |          |
 Intelligent  Humanoid
       ^        ^
        \      /
         Vulcan

 define class <sentient> (<life-form>) end class;
 define class <bipedal> (<life-form>) end class;
 define class <intelligent> (<sentient>) end class;
 define class <humanoid> (<bipedal>) end class;
 define class <vulcan> (<intelligent>, <humanoid>) end class;

=cut

{
    package Object;    
    use mro 'dfs';
    
    package LifeForm;
    use mro 'dfs';
    use base 'Object';
    
    package Sentient;
    use mro 'dfs';
    use base 'LifeForm';
    
    package BiPedal;
    use mro 'dfs';    
    use base 'LifeForm';
    
    package Intelligent;
    use mro 'dfs';    
    use base 'Sentient';
    
    package Humanoid;
    use mro 'dfs';    
    use base 'BiPedal';
    
    package Vulcan;
    use mro 'dfs';    
    use base ('Intelligent', 'Humanoid');
}

ok(eq_array(
    mro::get_linear_isa('Vulcan'),
    [ qw(Vulcan Intelligent Sentient LifeForm Object Humanoid BiPedal) ]
), '... got the right MRO for the Vulcan Dylan Example');