summaryrefslogtreecommitdiff
path: root/t/cmop/metaclass_incompatibility_dyn.t
blob: dccec28fe6c38e27013b52ca241c43fca7e0447d (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
use strict;
use warnings;

use Test::More;

use metaclass;

# meta classes
{
    package Foo::Meta;
    use parent 'Class::MOP::Class';

    package Bar::Meta;
    use parent 'Class::MOP::Class';

    package FooBar::Meta;
    use parent -norequire => 'Foo::Meta', 'Bar::Meta';
}

$@ = undef;
eval {
    package Foo;
    metaclass->import('Foo::Meta');
};
ok(!$@, '... Foo.meta => Foo::Meta is compatible') || diag $@;

$@ = undef;
eval {
    package Bar;
    metaclass->import('Bar::Meta');
};
ok(!$@, '... Bar.meta => Bar::Meta is compatible') || diag $@;

$@ = undef;
eval {
    package Foo::Foo;
    metaclass->import('Bar::Meta');
    Foo::Foo->meta->superclasses('Foo');
};
ok($@, '... Foo::Foo.meta => Bar::Meta is not compatible') || diag $@;

$@ = undef;
eval {
    package Bar::Bar;
    metaclass->import('Foo::Meta');
    Bar::Bar->meta->superclasses('Bar');
};
ok($@, '... Bar::Bar.meta => Foo::Meta is not compatible') || diag $@;

$@ = undef;
eval {
    package FooBar;
    metaclass->import('FooBar::Meta');
    FooBar->meta->superclasses('Foo');
};
ok(!$@, '... FooBar.meta => FooBar::Meta is compatible') || diag $@;

$@ = undef;
eval {
    package FooBar2;
    metaclass->import('FooBar::Meta');
    FooBar2->meta->superclasses('Bar');
};
ok(!$@, '... FooBar2.meta => FooBar::Meta is compatible') || diag $@;

done_testing;