summaryrefslogtreecommitdiff
path: root/t/mro/isa_c3.t
blob: 713d10ef3a2d6b7134f71ce8696c0d86d008bb8e (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!perl -w

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
    require "./test.pl";
}

use strict;

plan 'no_plan';

# package klonk doesn't have a stash.

package kapow;
use mro 'c3';

# No parents

package urkkk;
use mro 'c3';

# 1 parent
@urkkk::ISA = 'klonk';

package kayo;
use mro 'c3';

# 2 parents
@urkkk::ISA = ('klonk', 'kapow');

package thwacke;
use mro 'c3';

# No parents, has @ISA
@thwacke::ISA = ();

package zzzzzwap;
use mro 'c3';

@zzzzzwap::ISA = ('thwacke', 'kapow');

package whamm;
use mro 'c3';

@whamm::ISA = ('kapow', 'thwacke');

package main;

my %expect =
    (
     klonk => [qw(klonk)],
     urkkk => [qw(urkkk klonk kapow)],
     kapow => [qw(kapow)],
     kayo => [qw(kayo)],
     thwacke => [qw(thwacke)],
     zzzzzwap => [qw(zzzzzwap thwacke kapow)],
     whamm => [qw(whamm kapow thwacke)],
    );

foreach my $package (qw(klonk urkkk kapow kayo thwacke zzzzzwap whamm)) {
    my $ref = bless [], $package;
    my $isa = $expect{$package};
    is("@{mro::get_linear_isa($package)}", "@$isa", "\@ISA for $package");

    foreach my $class ($package, @$isa, 'UNIVERSAL') {
	isa_ok($ref, $class, $package);
    }
}