Allow metaclasses to be reinitialized from an existing metaclass, instead of only...
[gitmo/Class-MOP.git] / t / 041_metaclass_incompatibility.t
CommitLineData
550d56db 1use strict;
2use warnings;
3
efd3d14c 4use Test::More tests => 6;
550d56db 5
efd3d14c 6BEGIN {use metaclass;
550d56db 7}
8
9# meta classes
10{
11 package Foo::Meta;
12 use base 'Class::MOP::Class';
13
14 package Bar::Meta;
15 use base 'Class::MOP::Class';
16
17 package FooBar::Meta;
18 use base 'Foo::Meta', 'Bar::Meta';
19}
20
21$@ = undef;
22eval {
23 package Foo;
24 metaclass->import('Foo::Meta');
25};
26ok(!$@, '... Foo.meta => Foo::Meta is compatible') || diag $@;
27
28$@ = undef;
29eval {
30 package Bar;
31 metaclass->import('Bar::Meta');
32};
33ok(!$@, '... Bar.meta => Bar::Meta is compatible') || diag $@;
34
35$@ = undef;
36eval {
37 package Foo::Foo;
38 use base 'Foo';
39 metaclass->import('Bar::Meta');
40};
41ok($@, '... Foo::Foo.meta => Bar::Meta is not compatible') || diag $@;
42
43$@ = undef;
44eval {
45 package Bar::Bar;
46 use base 'Bar';
47 metaclass->import('Foo::Meta');
48};
49ok($@, '... Bar::Bar.meta => Foo::Meta is not compatible') || diag $@;
50
51$@ = undef;
52eval {
53 package FooBar;
54 use base 'Foo';
55 metaclass->import('FooBar::Meta');
56};
57ok(!$@, '... FooBar.meta => FooBar::Meta is compatible') || diag $@;
58
59$@ = undef;
60eval {
61 package FooBar2;
62 use base 'Bar';
63 metaclass->import('FooBar::Meta');
64};
65ok(!$@, '... FooBar2.meta => FooBar::Meta is compatible') || diag $@;
66
67