remove extraneous garbage from tests
[gitmo/Class-C3.git] / t / 35_next_method_in_anon.t
CommitLineData
7bb662d7 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
ef29cd70 6use Test::More tests => 2;
7bb662d7 7
8=pod
9
10This tests the successful handling of a next::method call from within an
11anonymous 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 51Class::C3::initialize();
52
7bb662d7 53is(B->foo, "B::foo => A::foo",
54 'method resolved inside anonymous sub');
55
56is(B->bar, "B::bar => A::bar",
57 'method resolved inside nested anonymous subs');
58
59