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