This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Encode to CPAN version 2.78
[perl5.git] / t / mro / inconsistent_c3.t
1 #!./perl
2
3 BEGIN {
4     unless (-d 'blib') {
5         chdir 't' if -d 't';
6         @INC = '../lib';
7     }
8 }
9
10 use strict;
11 use warnings;
12
13 require q(./test.pl); plan(tests => 1);
14
15 require mro;
16
17 =pod
18
19 This example is take from: http://www.python.org/2.3/mro.html
20
21 "Serious order disagreement" # From Guido
22 class O: pass
23 class X(O): pass
24 class Y(O): pass
25 class A(X,Y): pass
26 class B(Y,X): pass
27 try:
28     class Z(A,B): pass #creates Z(A,B) in Python 2.2
29 except TypeError:
30     pass # Z(A,B) cannot be created in Python 2.3
31
32 =cut
33
34 {
35     package X;
36     
37     package Y;
38     
39     package XY;
40     our @ISA = ('X', 'Y');
41     
42     package YX;
43     our @ISA = ('Y', 'X');
44
45     package Z;
46     our @ISA = ('XY', 'YX');
47 }
48
49 eval { mro::get_linear_isa('Z', 'c3') };
50 like($@, qr/^Inconsistent hierarchy during C3 merge of class 'Z'/,
51      '... got the right error with an inconsistent hierarchy');