File: 10_Inconsistent_hierarchy.t

package info (click to toggle)
libclass-c3-perl 0.35-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 260 kB
  • sloc: perl: 476; makefile: 8
file content (51 lines) | stat: -rw-r--r-- 1,019 bytes parent folder | download | duplicates (3)
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
50
51
use strict;
use warnings;

use Test::More tests => 1;

=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

eval q{
    {
        package X;
        use Class::C3;

        package Y;
        use Class::C3;

        package XY;
        use Class::C3;
        BEGIN { our @ISA = ('X', 'Y'); }

        package YX;
        use Class::C3;
        BEGIN { our @ISA = ('Y', 'X'); }

        package Z;
        eval 'use Class::C3' if $Class::C3::C3_IN_CORE;
        BEGIN { our @ISA = ('XY', 'YX'); }
    }

    Class::C3::initialize();

    # 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');