new c3.patch with next::method in core, new changes here to support it
[gitmo/Class-C3.git] / t / 10_Inconsistent_hierarchy.t
CommitLineData
d401eda1 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 2;
7
8BEGIN {
9 use_ok('Class::C3');
10}
11
12=pod
13
14This example is take from: http://www.python.org/2.3/mro.html
15
16"Serious order disagreement" # From Guido
17class O: pass
18class X(O): pass
19class Y(O): pass
20class A(X,Y): pass
21class B(Y,X): pass
22try:
23 class Z(A,B): pass #creates Z(A,B) in Python 2.2
24except TypeError:
25 pass # Z(A,B) cannot be created in Python 2.3
26
27=cut
28
8fca9ed2 29eval 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 57like($@, qr/Inconsistent hierarchy /, '... got the right error with an inconsistent hierarchy');