Improve mro merging error messages.
[gitmo/Class-C3-XS.git] / t / 33_next_method_used_with_NEXT.t
CommitLineData
2605e591 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7
8BEGIN {
9 eval "use NEXT";
10 plan skip_all => "NEXT required for this test" if $@;
11 plan tests => 4;
12}
13
14use 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
47is(Foo->foo, 'Foo::foo', '... got the right value from Foo->foo');
48is(Fuz->foo, 'Fuz::foo => Foo::foo', '... got the right value from Fuz->foo');
49is(Bar->foo, 'Bar::foo => Foo::foo', '... got the right value from Bar->foo');
50
51is(Baz->foo, 'Baz::foo => Bar::foo => Fuz::foo => Foo::foo', '... got the right value using NEXT in a subclass of a C3 class');
52