remove extraneous garbage from tests
[gitmo/Class-C3.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 => 2;
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;
17     use Class::C3; 
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';
31     use Class::C3; 
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 Class::C3::initialize();  
52
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