Commit | Line | Data |
95bebf8c |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More tests => 5; |
7 | |
8 | BEGIN { |
9 | use_ok('Class::C3'); |
10 | } |
11 | |
12 | { |
13 | package Diamond_A; |
14 | use Class::C3; |
15 | sub hello { 'Diamond_A::hello' } |
16 | } |
17 | { |
18 | package Diamond_B; |
19 | use base 'Diamond_A'; |
20 | use Class::C3; |
21 | } |
22 | { |
23 | package Diamond_C; |
24 | use Class::C3; |
25 | use base 'Diamond_A'; |
26 | |
27 | sub hello { 'Diamond_C::hello' } |
28 | } |
29 | { |
30 | package Diamond_D; |
31 | use base ('Diamond_B', 'Diamond_C'); |
32 | use Class::C3; |
33 | } |
34 | |
35 | is_deeply( |
36 | [ Class::C3::calculateMRO('Diamond_D') ], |
37 | [ qw(Diamond_D Diamond_B Diamond_C Diamond_A) ], |
38 | '... got the right MRO for Diamond_D'); |
39 | |
40 | is(Diamond_D->hello, 'Diamond_C::hello', '... method resolved itself as expected'); |
41 | is(Diamond_D->can('hello')->(), 'Diamond_C::hello', '... can(method) resolved itself as expected'); |
42 | |
43 | is(UNIVERSAL::can("Diamond_D", 'hello')->(), 'Diamond_C::hello', '... can(method) resolved itself as expected'); |