6 use Test::More no_plan => 1;
10 use_ok('Class::MOP::SafeMixin');
13 ## Mixin a class without a superclass.
16 sub foo { 'FooMixin::foo' }
19 use metaclass 'Class::MOP::SafeMixin';
20 Foo->meta->mixin('FooMixin');
21 sub new { (shift)->meta->new_object(@_) }
28 is($foo->foo, 'FooMixin::foo', '... got the right value from the mixin method');
30 ## Mixin a class who shares a common ancestor
34 sub baz { 'Baz::baz' }
41 eval { Foo::Baz->meta->mixin('Baz') };
42 ::ok(!$@, '... the classes superclass must extend a subclass of the superclass of the mixins');
46 my $foo_baz = Foo::Baz->new();
47 isa_ok($foo_baz, 'Foo::Baz');
48 isa_ok($foo_baz, 'Foo');
50 can_ok($foo_baz, 'baz');
51 is($foo_baz->baz(), 'Baz::baz', '... got the right value from the mixin method');
55 our @ISA = ('Foo', 'Bar');
57 package Foo::Bar::Baz;
58 our @ISA = ('Foo::Bar');
59 eval { Foo::Bar::Baz->meta->mixin('Baz') };
60 ::ok(!$@, '... the classes superclass must extend a subclass of the superclass of the mixins');
63 my $foo_bar_baz = Foo::Bar::Baz->new();
64 isa_ok($foo_bar_baz, 'Foo::Bar::Baz');
65 isa_ok($foo_bar_baz, 'Foo::Bar');
66 isa_ok($foo_bar_baz, 'Foo');
67 isa_ok($foo_bar_baz, 'Bar');
69 can_ok($foo_bar_baz, 'baz');
70 is($foo_bar_baz->baz(), 'Baz::baz', '... got the right value from the mixin method');