NEXT/next::method thing needed updated for removal of the c3 assumption in next:...
[gitmo/Class-C3.git] / t / 33_next_method_used_with_NEXT.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 BEGIN {
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     use Class::C3;
42     require NEXT; # load this as late as possible so we can catch the test skip
43
44     use base 'Bar', 'Fuz';
45     
46     sub foo { 'Baz::foo => ' . (shift)->NEXT::foo }    
47 }
48
49 Class::C3::initialize();
50
51 is(Foo->foo, 'Foo::foo', '... got the right value from Foo->foo');
52 is(Fuz->foo, 'Fuz::foo => Foo::foo', '... got the right value from Fuz->foo');
53 is(Bar->foo, 'Bar::foo => Foo::foo', '... got the right value from Bar->foo');
54
55 is(Baz->foo, 'Baz::foo => Bar::foo => Fuz::foo => Foo::foo', '... got the right value using NEXT in a subclass of a C3 class');
56