Class-C3 - the real 0.08, released as 0.09
[gitmo/Class-C3.git] / t / 33_next_method_used_with_NEXT.t
CommitLineData
5d5c86d9 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 5;
7
8BEGIN {
9 use_ok('Class::C3');
10}
11
12{
13 package Foo;
14 use strict;
15 use warnings;
16 use Class::C3;
17
18 sub foo { 'Foo::foo' }
19
20 package Fuz;
21 use strict;
22 use warnings;
23 use Class::C3;
24 use base 'Foo';
25
26 sub foo { 'Fuz::foo => ' . (shift)->next::method }
27
28 package Bar;
29 use strict;
30 use warnings;
31 use Class::C3;
32 use base 'Foo';
33
34 sub foo { 'Bar::foo => ' . (shift)->next::method }
35
36 package Baz;
37 use strict;
38 use warnings;
39 use NEXT;
40
41 use base 'Bar', 'Fuz';
42
43 sub foo { 'Baz::foo => ' . (shift)->NEXT::foo }
44}
45
46is(Foo->foo, 'Foo::foo', '... got the right value from Foo->foo');
47is(Fuz->foo, 'Fuz::foo => Foo::foo', '... got the right value from Fuz->foo');
48is(Bar->foo, 'Bar::foo => Foo::foo', '... got the right value from Bar->foo');
49
50is(Baz->foo, 'Baz::foo => Bar::foo => Fuz::foo => Foo::foo', '... got the right value using NEXT in a subclass of a C3 class');
51