Commit | Line | Data |
2605e591 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | |
8 | BEGIN { |
9 | eval "use NEXT"; |
10 | plan skip_all => "NEXT required for this test" if $@; |
11 | plan tests => 4; |
12 | } |
13 | |
14 | use Class::C3::XS; |
15 | |
16 | { |
17 | package Foo; |
18 | use strict; |
19 | use warnings; |
20 | |
21 | sub foo { 'Foo::foo' } |
22 | |
23 | package Fuz; |
24 | use strict; |
25 | use warnings; |
26 | use base 'Foo'; |
27 | |
28 | sub foo { 'Fuz::foo => ' . (shift)->next::method } |
29 | |
30 | package Bar; |
31 | use strict; |
32 | use warnings; |
33 | use base 'Foo'; |
34 | |
35 | sub foo { 'Bar::foo => ' . (shift)->next::method } |
36 | |
37 | package Baz; |
38 | use strict; |
39 | use warnings; |
40 | require NEXT; # load this as late as possible so we can catch the test skip |
41 | |
42 | use base 'Bar', 'Fuz'; |
43 | |
44 | sub foo { 'Baz::foo => ' . (shift)->NEXT::foo } |
45 | } |
46 | |
47 | is(Foo->foo, 'Foo::foo', '... got the right value from Foo->foo'); |
48 | is(Fuz->foo, 'Fuz::foo => Foo::foo', '... got the right value from Fuz->foo'); |
49 | is(Bar->foo, 'Bar::foo => Foo::foo', '... got the right value from Bar->foo'); |
50 | |
51 | is(Baz->foo, 'Baz::foo => Bar::foo => Fuz::foo => Foo::foo', '... got the right value using NEXT in a subclass of a C3 class'); |
52 | |