summaryrefslogtreecommitdiff
path: root/t/mro/inconsistent_c3.t
blob: 68d37950d4f9d09f9c5a8092fc6a3f6b89d9abb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!./perl

use strict;
use warnings;
BEGIN {
    unless (-d 'blib') {
        chdir 't' if -d 't';
        @INC = '../lib';
    }
}

require q(./test.pl); plan(tests => 1);

require mro;

=pod

This example is take from: http://www.python.org/2.3/mro.html

"Serious order disagreement" # From Guido
class O: pass
class X(O): pass
class Y(O): pass
class A(X,Y): pass
class B(Y,X): pass
try:
    class Z(A,B): pass #creates Z(A,B) in Python 2.2
except TypeError:
    pass # Z(A,B) cannot be created in Python 2.3

=cut

{
    package X;
    
    package Y;
    
    package XY;
    our @ISA = ('X', 'Y');
    
    package YX;
    our @ISA = ('Y', 'X');

    package Z;
    our @ISA = ('XY', 'YX');
}

eval { mro::get_linear_isa('Z', 'c3') };
like($@, qr/^Inconsistent /, '... got the right error with an inconsistent hierarchy');