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