avoid needing . in @INC in dev mode
[gitmo/Algorithm-C3.git] / t / 004_merge.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 2;
7
8 BEGIN {
9     use_ok('Algorithm::C3');
10 }
11
12 =pod
13
14 example taken from: L<http://gauss.gwydiondylan.org/books/drm/drm_50.html>
15
16          Object
17            ^
18            |
19         LifeForm 
20          ^    ^
21         /      \
22    Sentient    BiPedal
23       ^          ^
24       |          |
25  Intelligent  Humanoid
26        ^        ^
27         \      /
28          Vulcan
29
30  define class <sentient> (<life-form>) end class;
31  define class <bipedal> (<life-form>) end class;
32  define class <intelligent> (<sentient>) end class;
33  define class <humanoid> (<bipedal>) end class;
34  define class <vulcan> (<intelligent>, <humanoid>) end class;
35
36 =cut
37
38 {
39     package Object;    
40     
41     sub my_ISA {
42         no strict 'refs';
43         @{$_[0] . '::ISA'};
44     }    
45     
46     package LifeForm;
47     use base 'Object';
48     
49     package Sentient;
50     use base 'LifeForm';
51     
52     package BiPedal;
53     use base 'LifeForm';
54     
55     package Intelligent;
56     use base 'Sentient';
57     
58     package Humanoid;
59     use base 'BiPedal';
60     
61     package Vulcan;
62     use base ('Intelligent', 'Humanoid');
63 }
64
65 is_deeply(
66     [ Algorithm::C3::merge('Vulcan', 'my_ISA') ],
67     [ qw(Vulcan Intelligent Sentient Humanoid BiPedal LifeForm Object) ],
68     '... got the right C3 merge order for the Vulcan Dylan Example');