This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Encode to CPAN version 2.78
[perl5.git] / t / mro / next_inanon_utf8.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use utf8;
6 use open qw( :utf8 :std );
7 require q(./test.pl); plan(tests => 2);
8
9 =pod
10
11 This tests the successful handling of a next::method call from within an
12 anonymous subroutine.
13
14 =cut
15
16 {
17     package ㅏ;
18     use mro 'c3'; 
19
20     sub ᕘ {
21       return 'ㅏ::ᕘ';
22     }
23
24     sub Ḃᛆ {
25       return 'ㅏ::Ḃᛆ';
26     }
27 }
28
29 {
30     package Ḃ;
31     use base 'ㅏ';
32     use mro 'c3'; 
33     
34     sub ᕘ {
35       my $code = sub {
36         return 'Ḃ::ᕘ => ' . (shift)->next::method();
37       };
38       return (shift)->$code;
39     }
40
41     sub Ḃᛆ {
42       my $code1 = sub {
43         my $code2 = sub {
44           return 'Ḃ::Ḃᛆ => ' . (shift)->next::method();
45         };
46         return (shift)->$code2;
47       };
48       return (shift)->$code1;
49     }
50 }
51
52 is(Ḃ->ᕘ, "Ḃ::ᕘ => ㅏ::ᕘ",
53    'method resolved inside anonymous sub');
54
55 is(Ḃ->Ḃᛆ, "Ḃ::Ḃᛆ => ㅏ::Ḃᛆ",
56    'method resolved inside nested anonymous subs');
57
58