xref: /openbsd-src/gnu/usr.bin/perl/t/mro/next_NEXT.t (revision b8851fcc53cbe24fd20b090f26dd149e353f6174)
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use NEXT;
6
7chdir 't' if -d 't';
8require './test.pl';
9plan(tests => 4);
10
11{
12    package Foo;
13    use strict;
14    use warnings;
15    use mro 'c3';
16
17    sub foo { 'Foo::foo' }
18
19    package Fuz;
20    use strict;
21    use warnings;
22    use mro 'c3';
23    use base 'Foo';
24
25    sub foo { 'Fuz::foo => ' . (shift)->next::method }
26
27    package Bar;
28    use strict;
29    use warnings;
30    use mro 'c3';
31    use base 'Foo';
32
33    sub foo { 'Bar::foo => ' . (shift)->next::method }
34
35    package Baz;
36    use strict;
37    use warnings;
38
39    use base 'Bar', 'Fuz';
40
41    sub foo { 'Baz::foo => ' . (shift)->NEXT::foo }
42}
43
44is(Foo->foo, 'Foo::foo', '... got the right value from Foo->foo');
45is(Fuz->foo, 'Fuz::foo => Foo::foo', '... got the right value from Fuz->foo');
46is(Bar->foo, 'Bar::foo => Foo::foo', '... got the right value from Bar->foo');
47
48is(Baz->foo, 'Baz::foo => Bar::foo => Fuz::foo => Foo::foo', '... got the right value using NEXT in a subclass of a C3 class');
49
50