fix broken gotos for Catalyst::Plugin::C3, added slightly modified next::method tests...
[gitmo/Class-C3-XS.git] / t / 35_next_method_in_anon.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 3;
7
8 BEGIN { use_ok('Class::C3::XS') }
9
10 =pod
11
12 This tests the successful handling of a next::method call from within an
13 anonymous subroutine.
14
15 =cut
16
17 {
18     package A;
19
20     sub foo {
21       return 'A::foo';
22     }
23
24     sub bar {
25       return 'A::bar';
26     }
27 }
28
29 {
30     package B;
31     use base 'A';
32     
33     sub foo {
34       my $code = sub {
35         return 'B::foo => ' . (shift)->next::method();
36       };
37       return (shift)->$code;
38     }
39
40     sub bar {
41       my $code1 = sub {
42         my $code2 = sub {
43           return 'B::bar => ' . (shift)->next::method();
44         };
45         return (shift)->$code2;
46       };
47       return (shift)->$code1;
48     }
49 }
50
51 is(B->foo, "B::foo => A::foo",
52    'method resolved inside anonymous sub');
53
54 is(B->bar, "B::bar => A::bar",
55    'method resolved inside nested anonymous subs');
56
57