X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F10_Inconsistent_hierarchy.t;fp=t%2F10_Inconsistent_hierarchy.t;h=2378ea3a4c564f0c54ac827541d668be9d3f23bf;hb=8995e8271e0f7f7b9c0942a4425e8a44099bf608;hp=0000000000000000000000000000000000000000;hpb=7cf94227b3d924007404bc5968c7362135d299f8;p=gitmo%2FClass-C3-XS.git diff --git a/t/10_Inconsistent_hierarchy.t b/t/10_Inconsistent_hierarchy.t new file mode 100644 index 0000000..2378ea3 --- /dev/null +++ b/t/10_Inconsistent_hierarchy.t @@ -0,0 +1,57 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 2; + +BEGIN { + use_ok('Class::C3'); +} + +=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; + use Class::C3; + + package Y; + use Class::C3; + + package XY; + use Class::C3; + use base ('X', 'Y'); + + package YX; + use Class::C3; + use base ('Y', 'X'); + + package Z; + # use Class::C3; << Dont do this just yet ... + use base ('XY', 'YX'); +} + +Class::C3::initialize(); + +eval { + # now try to calculate the MRO + # and watch it explode :) + Class::C3::calculateMRO('Z') +}; +#diag $@; +like($@, qr/^Inconsistent hierarchy/, '... got the right error with an inconsistent hierarchy');