This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move File::Fetch from lib to ext
[perl5.git] / t / mro / next_NEXT.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use NEXT;
6
7 require './test.pl';
8 plan(tests => 4);
9
10 {
11     package Foo;
12     use strict;
13     use warnings;
14     use mro 'c3';
15     
16     sub foo { 'Foo::foo' }
17     
18     package Fuz;
19     use strict;
20     use warnings;
21     use mro 'c3';
22     use base 'Foo';
23
24     sub foo { 'Fuz::foo => ' . (shift)->next::method }
25         
26     package Bar;
27     use strict;
28     use warnings;    
29     use mro 'c3';
30     use base 'Foo';
31
32     sub foo { 'Bar::foo => ' . (shift)->next::method }
33     
34     package Baz;
35     use strict;
36     use warnings;    
37
38     use base 'Bar', 'Fuz';
39     
40     sub foo { 'Baz::foo => ' . (shift)->NEXT::foo }    
41 }
42
43 is(Foo->foo, 'Foo::foo', '... got the right value from Foo->foo');
44 is(Fuz->foo, 'Fuz::foo => Foo::foo', '... got the right value from Fuz->foo');
45 is(Bar->foo, 'Bar::foo => Foo::foo', '... got the right value from Bar->foo');
46
47 is(Baz->foo, 'Baz::foo => Bar::foo => Fuz::foo => Foo::foo', '... got the right value using NEXT in a subclass of a C3 class');
48