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 | |
8fca9ed2 |
29 | eval q{ |
30 | { |
31 | package X; |
32 | use Class::C3; |
33 | |
34 | package Y; |
35 | use Class::C3; |
36 | |
37 | package XY; |
38 | use Class::C3; |
39 | use base ('X', 'Y'); |
40 | |
41 | package YX; |
42 | use Class::C3; |
43 | use base ('Y', 'X'); |
44 | |
45 | package Z; |
46 | eval 'use Class::C3' if $Class::C3::C3_IN_CORE; |
47 | use base ('XY', 'YX'); |
48 | } |
d401eda1 |
49 | |
8fca9ed2 |
50 | Class::C3::initialize(); |
2ffffc6d |
51 | |
d401eda1 |
52 | # now try to calculate the MRO |
53 | # and watch it explode :) |
8fca9ed2 |
54 | Class::C3::calculateMRO('Z'); |
d401eda1 |
55 | }; |
4e47d2a4 |
56 | #diag $@; |
8fca9ed2 |
57 | like($@, qr/Inconsistent hierarchy /, '... got the right error with an inconsistent hierarchy'); |