Commit | Line | Data |
---|---|---|
e1a479c5 BB |
1 | #!./perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | BEGIN { | |
6 | unless (-d 'blib') { | |
7 | chdir 't' if -d 't'; | |
8 | @INC = '../lib'; | |
9 | } | |
10 | } | |
11 | ||
5f5ae4a7 | 12 | require q(./test.pl); plan(tests => 1); |
e1a479c5 | 13 | |
b2685f0c NC |
14 | require mro; |
15 | ||
e1a479c5 BB |
16 | =pod |
17 | ||
18 | This example is take from: http://www.python.org/2.3/mro.html | |
19 | ||
20 | "Serious order disagreement" # From Guido | |
21 | class O: pass | |
22 | class X(O): pass | |
23 | class Y(O): pass | |
24 | class A(X,Y): pass | |
25 | class B(Y,X): pass | |
26 | try: | |
27 | class Z(A,B): pass #creates Z(A,B) in Python 2.2 | |
28 | except TypeError: | |
29 | pass # Z(A,B) cannot be created in Python 2.3 | |
30 | ||
31 | =cut | |
32 | ||
33 | { | |
34 | package X; | |
35 | ||
36 | package Y; | |
37 | ||
38 | package XY; | |
39 | our @ISA = ('X', 'Y'); | |
40 | ||
41 | package YX; | |
42 | our @ISA = ('Y', 'X'); | |
43 | ||
44 | package Z; | |
45 | our @ISA = ('XY', 'YX'); | |
46 | } | |
47 | ||
48 | eval { mro::get_linear_isa('Z', 'c3') }; | |
49 | like($@, qr/^Inconsistent /, '... got the right error with an inconsistent hierarchy'); |