Commit | Line | Data |
7bb662d7 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
ef29cd70 |
6 | use Test::More tests => 2; |
7bb662d7 |
7 | |
8 | =pod |
9 | |
10 | This tests the successful handling of a next::method call from within an |
11 | anonymous subroutine. |
12 | |
13 | =cut |
14 | |
15 | { |
16 | package A; |
ef29cd70 |
17 | use Class::C3; |
7bb662d7 |
18 | |
19 | sub foo { |
20 | return 'A::foo'; |
21 | } |
22 | |
23 | sub bar { |
24 | return 'A::bar'; |
25 | } |
26 | } |
27 | |
28 | { |
29 | package B; |
30 | use base 'A'; |
ef29cd70 |
31 | use Class::C3; |
7bb662d7 |
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 | |
2ffffc6d |
51 | Class::C3::initialize(); |
52 | |
7bb662d7 |
53 | is(B->foo, "B::foo => A::foo", |
54 | 'method resolved inside anonymous sub'); |
55 | |
56 | is(B->bar, "B::bar => A::bar", |
57 | 'method resolved inside nested anonymous subs'); |
58 | |
59 | |