This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make MM_VMS::oneline build continuation lines properly.
[perl5.git] / t / mro / next_NEXT.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use NEXT;
6
7 chdir 't' if -d 't';
8 require './test.pl';
9 plan(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
44 is(Foo->foo, 'Foo::foo', '... got the right value from Foo->foo');
45 is(Fuz->foo, 'Fuz::foo => Foo::foo', '... got the right value from Fuz->foo');
46 is(Bar->foo, 'Bar::foo => Foo::foo', '... got the right value from Bar->foo');
47
48 is(Baz->foo, 'Baz::foo => Bar::foo => Fuz::foo => Foo::foo', '... got the right value using NEXT in a subclass of a C3 class');
49