don't try to fix compatible metaclasses
[gitmo/Class-MOP.git] / t / 107_C3MethodDispatchOrder_test.t
CommitLineData
f3f5bd34 1use strict;
2use warnings;
3
d89c0fad 4use Test::More;
f3f5bd34 5use File::Spec;
86a4d873 6use Class::MOP;
f3f5bd34 7
d89c0fad 8BEGIN {
9 eval "use Algorithm::C3";
10 plan skip_all => "Algorithm::C3 required for this test" if $@;
10dd437b 11 require_ok(File::Spec->catfile('examples', 'C3MethodDispatchOrder.pod'));
f3f5bd34 12}
13
14{
15 package Diamond_A;
86a4d873 16 use metaclass 'C3MethodDispatchOrder';
17
f3f5bd34 18 sub hello { 'Diamond_A::hello' }
19
20 package Diamond_B;
86a4d873 21 use metaclass 'C3MethodDispatchOrder';
22 __PACKAGE__->meta->superclasses('Diamond_A');
23
f3f5bd34 24 package Diamond_C;
86a4d873 25 use metaclass 'C3MethodDispatchOrder';
26 __PACKAGE__->meta->superclasses('Diamond_A');
27
f3f5bd34 28 sub hello { 'Diamond_C::hello' }
29
30 package Diamond_D;
86a4d873 31 use metaclass 'C3MethodDispatchOrder';
f3f5bd34 32 __PACKAGE__->meta->superclasses('Diamond_B', 'Diamond_C');
33}
34
35is_deeply(
36 [ Diamond_D->meta->class_precedence_list ],
37 [ qw(Diamond_D Diamond_B Diamond_C Diamond_A) ],
38 '... got the right MRO for Diamond_D');
39
40is(Diamond_D->hello, 'Diamond_C::hello', '... got the right dispatch order');
41is(Diamond_D->can('hello')->(), 'Diamond_C::hello', '... can(method) resolved itself as expected');
42
86a4d873 43done_testing;