adding the some preliminary junk
[gitmo/Class-C3-XS.git] / t / 10_Inconsistent_hierarchy.t
CommitLineData
8995e827 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
29{
30 package X;
31 use Class::C3;
32
33 package Y;
34 use Class::C3;
35
36 package XY;
37 use Class::C3;
38 use base ('X', 'Y');
39
40 package YX;
41 use Class::C3;
42 use base ('Y', 'X');
43
44 package Z;
45 # use Class::C3; << Dont do this just yet ...
46 use base ('XY', 'YX');
47}
48
49Class::C3::initialize();
50
51eval {
52 # now try to calculate the MRO
53 # and watch it explode :)
54 Class::C3::calculateMRO('Z')
55};
56#diag $@;
57like($@, qr/^Inconsistent hierarchy/, '... got the right error with an inconsistent hierarchy');