summaryrefslogtreecommitdiff
path: root/t/mro/next_NEXT.t
blob: 7f61c4d92f3faa95ce88acec3e22b00af3873f3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl

use strict;
use warnings;
use NEXT;

chdir 't' if -d 't';
require './test.pl';
plan(tests => 4);

{
    package Foo;
    use strict;
    use warnings;
    use mro 'c3';
    
    sub foo { 'Foo::foo' }
    
    package Fuz;
    use strict;
    use warnings;
    use mro 'c3';
    use base 'Foo';

    sub foo { 'Fuz::foo => ' . (shift)->next::method }
        
    package Bar;
    use strict;
    use warnings;    
    use mro 'c3';
    use base 'Foo';

    sub foo { 'Bar::foo => ' . (shift)->next::method }
    
    package Baz;
    use strict;
    use warnings;    

    use base 'Bar', 'Fuz';
    
    sub foo { 'Baz::foo => ' . (shift)->NEXT::foo }    
}

is(Foo->foo, 'Foo::foo', '... got the right value from Foo->foo');
is(Fuz->foo, 'Fuz::foo => Foo::foo', '... got the right value from Fuz->foo');
is(Bar->foo, 'Bar::foo => Foo::foo', '... got the right value from Bar->foo');

is(Baz->foo, 'Baz::foo => Bar::foo => Fuz::foo => Foo::foo', '... got the right value using NEXT in a subclass of a C3 class');