One last tweak to make sure our Sub::Name-using tests _do_ run when we
[gitmo/Class-MOP.git] / t / 041_metaclass_incompatability.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     use base 'Foo';
42     metaclass->import('Bar::Meta');
43 };
44 ok($@, '... Foo::Foo.meta => Bar::Meta is not compatible') || diag $@;
45
46 $@ = undef;
47 eval {
48     package Bar::Bar;
49     use base 'Bar';
50     metaclass->import('Foo::Meta');
51 };
52 ok($@, '... Bar::Bar.meta => Foo::Meta is not compatible') || diag $@;
53
54 $@ = undef;
55 eval {
56     package FooBar;
57     use base 'Foo';
58     metaclass->import('FooBar::Meta');
59 };
60 ok(!$@, '... FooBar.meta => FooBar::Meta is compatible') || diag $@;
61
62 $@ = undef;
63 eval {
64     package FooBar2;
65     use base 'Bar';
66     metaclass->import('FooBar::Meta');
67 };
68 ok(!$@, '... FooBar2.meta => FooBar::Meta is compatible') || diag $@;
69
70