Commit | Line | Data |
d401eda1 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More tests => 2; |
7 | |
8 | BEGIN { |
9 | use_ok('Class::C3'); |
10 | } |
11 | |
12 | =pod |
13 | |
14 | This example is take from: http://www.python.org/2.3/mro.html |
15 | |
16 | "Serious order disagreement" # From Guido |
17 | class O: pass |
18 | class X(O): pass |
19 | class Y(O): pass |
20 | class A(X,Y): pass |
21 | class B(Y,X): pass |
22 | try: |
23 | class Z(A,B): pass #creates Z(A,B) in Python 2.2 |
24 | except TypeError: |
25 | pass # Z(A,B) cannot be created in Python 2.3 |
26 | |
27 | =cut |
28 | |
29 | { |
30 | package X; |
31 | use Class::C3; |
32 | |
33 | package Y; |
34 | use Class::C3; |
35 | |
36 | package XY; |
37 | use Class::C3; |
38 | use base ('X', 'Y'); |
39 | |
40 | package YX; |
41 | use Class::C3; |
42 | use base ('Y', 'X'); |
43 | |
44 | package Z; |
45 | # use Class::C3; << Dont do this just yet ... |
46 | use base ('XY', 'YX'); |
47 | } |
48 | |
2ffffc6d |
49 | Class::C3::initialize(); |
50 | |
d401eda1 |
51 | eval { |
52 | # now try to calculate the MRO |
53 | # and watch it explode :) |
54 | Class::C3::calculateMRO('Z') |
55 | }; |
4e47d2a4 |
56 | #diag $@; |
d401eda1 |
57 | like($@, qr/^Inconsistent hierarchy/, '... got the right error with an inconsistent hierarchy'); |