whoopse forgot the changelog and to update the MANIFEST
[gitmo/Class-C3.git] / t / 01_MRO.t
CommitLineData
95bebf8c 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 5;
7
8BEGIN {
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
35is_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
40is(Diamond_D->hello, 'Diamond_C::hello', '... method resolved itself as expected');
41is(Diamond_D->can('hello')->(), 'Diamond_C::hello', '... can(method) resolved itself as expected');
42
43is(UNIVERSAL::can("Diamond_D", 'hello')->(), 'Diamond_C::hello', '... can(method) resolved itself as expected');