Commit | Line | Data |
5d5c86d9 |
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 Foo; |
14 | use strict; |
15 | use warnings; |
16 | use Class::C3; |
17 | |
18 | sub foo { 'Foo::foo' } |
19 | |
20 | package Fuz; |
21 | use strict; |
22 | use warnings; |
23 | use Class::C3; |
24 | use base 'Foo'; |
25 | |
26 | sub foo { 'Fuz::foo => ' . (shift)->next::method } |
27 | |
28 | package Bar; |
29 | use strict; |
30 | use warnings; |
31 | use Class::C3; |
32 | use base 'Foo'; |
33 | |
34 | sub foo { 'Bar::foo => ' . (shift)->next::method } |
35 | |
36 | package Baz; |
37 | use strict; |
38 | use warnings; |
39 | use NEXT; |
40 | |
41 | use base 'Bar', 'Fuz'; |
42 | |
43 | sub foo { 'Baz::foo => ' . (shift)->NEXT::foo } |
44 | } |
45 | |
46 | is(Foo->foo, 'Foo::foo', '... got the right value from Foo->foo'); |
47 | is(Fuz->foo, 'Fuz::foo => Foo::foo', '... got the right value from Fuz->foo'); |
48 | is(Bar->foo, 'Bar::foo => Foo::foo', '... got the right value from Bar->foo'); |
49 | |
50 | is(Baz->foo, 'Baz::foo => Bar::foo => Fuz::foo => Foo::foo', '... got the right value using NEXT in a subclass of a C3 class'); |
51 | |