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