adding the some preliminary junk
[gitmo/Class-C3-XS.git] / t / 33_next_method_used_with_NEXT.t
CommitLineData
8995e827 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7
8BEGIN {
9 eval "use NEXT";
10 plan skip_all => "NEXT required for this test" if $@;
11 plan tests => 4;
12}
13
14{
15 package Foo;
16 use strict;
17 use warnings;
18 use Class::C3;
19
20 sub foo { 'Foo::foo' }
21
22 package Fuz;
23 use strict;
24 use warnings;
25 use Class::C3;
26 use base 'Foo';
27
28 sub foo { 'Fuz::foo => ' . (shift)->next::method }
29
30 package Bar;
31 use strict;
32 use warnings;
33 use Class::C3;
34 use base 'Foo';
35
36 sub foo { 'Bar::foo => ' . (shift)->next::method }
37
38 package Baz;
39 use strict;
40 use warnings;
41 require NEXT; # load this as late as possible so we can catch the test skip
42
43 use base 'Bar', 'Fuz';
44
45 sub foo { 'Baz::foo => ' . (shift)->NEXT::foo }
46}
47
48Class::C3::initialize();
49
50is(Foo->foo, 'Foo::foo', '... got the right value from Foo->foo');
51is(Fuz->foo, 'Fuz::foo => Foo::foo', '... got the right value from Fuz->foo');
52is(Bar->foo, 'Bar::foo => Foo::foo', '... got the right value from Bar->foo');
53
54is(Baz->foo, 'Baz::foo => Bar::foo => Fuz::foo => Foo::foo', '... got the right value using NEXT in a subclass of a C3 class');
55