This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(?foo:...) loses passed in charset
[perl5.git] / t / mro / basic_02_dfs_utf8.t
1 #!./perl
2
3 use strict;
4 use warnings;
5 use utf8;
6 use open qw( :utf8 :std );
7
8 require q(./test.pl); plan(tests => 10);
9
10 =pod
11
12 This example is take from: http://www.python.org/2.3/mro.html
13
14 "My first example"
15 class O: pass
16 class F(O): pass
17 class E(O): pass
18 class D(O): pass
19 class C(D,F): pass
20 class B(D,E): pass
21 class A(B,C): pass
22
23
24                           6
25                          ---
26 Level 3                 | O |                  (more general)
27                       /  ---  \
28                      /    |    \                      |
29                     /     |     \                     |
30                    /      |      \                    |
31                   ---    ---    ---                   |
32 Level 2        3 | D | 4| E |  | F | 5                |
33                   ---    ---    ---                   |
34                    \  \ _ /       |                   |
35                     \    / \ _    |                   |
36                      \  /      \  |                   |
37                       ---      ---                    |
38 Level 1            1 | B |    | C | 2                 |
39                       ---      ---                    |
40                         \      /                      |
41                          \    /                      \ /
42                            ---
43 Level 0                 0 | A |                (more specialized)
44                            ---
45
46 =cut
47
48 {
49     package 텟ţ::ᴼ;
50     use mro 'dfs'; 
51     
52     package 텟ţ::Ḟ;   
53     use mro 'dfs';  
54     use base '텟ţ::ᴼ';        
55     
56     package 텟ţ::ऍ;
57     use base '텟ţ::ᴼ';    
58     use mro 'dfs';     
59     
60     sub ƈ_or_ऍ { '텟ţ::ऍ' }
61
62     package 텟ţ::Ḋ;
63     use mro 'dfs'; 
64     use base '텟ţ::ᴼ';     
65     
66     sub ƈ_or_Ḋ { '텟ţ::Ḋ' }
67       
68     package 텟ţ::ƈ;
69     use base ('텟ţ::Ḋ', '텟ţ::Ḟ');
70     use mro 'dfs'; 
71     
72     sub ƈ_or_Ḋ { '텟ţ::ƈ' }
73     sub ƈ_or_ऍ { '텟ţ::ƈ' }
74         
75     package 텟ţ::ᛒ;    
76     use mro 'dfs'; 
77     use base ('텟ţ::Ḋ', '텟ţ::ऍ');    
78         
79     package 텟ţ::ଅ;    
80     use base ('텟ţ::ᛒ', '텟ţ::ƈ');
81     use mro 'dfs';    
82 }
83
84 ok(eq_array(
85     mro::get_linear_isa('텟ţ::Ḟ'),
86     [ qw(텟ţ::Ḟ 텟ţ::ᴼ) ]
87 ), '... got the right MRO for 텟ţ::Ḟ');
88
89 ok(eq_array(
90     mro::get_linear_isa('텟ţ::ऍ'),
91     [ qw(텟ţ::ऍ 텟ţ::ᴼ) ]
92 ), '... got the right MRO for 텟ţ::ऍ');    
93
94 ok(eq_array(
95     mro::get_linear_isa('텟ţ::Ḋ'),
96     [ qw(텟ţ::Ḋ 텟ţ::ᴼ) ]
97 ), '... got the right MRO for 텟ţ::Ḋ');       
98
99 ok(eq_array(
100     mro::get_linear_isa('텟ţ::ƈ'),
101     [ qw(텟ţ::ƈ 텟ţ::Ḋ 텟ţ::ᴼ 텟ţ::Ḟ) ]
102 ), '... got the right MRO for 텟ţ::ƈ'); 
103
104 ok(eq_array(
105     mro::get_linear_isa('텟ţ::ᛒ'),
106     [ qw(텟ţ::ᛒ 텟ţ::Ḋ 텟ţ::ᴼ 텟ţ::ऍ) ]
107 ), '... got the right MRO for 텟ţ::ᛒ');     
108
109 ok(eq_array(
110     mro::get_linear_isa('텟ţ::ଅ'),
111     [ qw(텟ţ::ଅ 텟ţ::ᛒ 텟ţ::Ḋ 텟ţ::ᴼ 텟ţ::ऍ 텟ţ::ƈ 텟ţ::Ḟ) ]
112 ), '... got the right MRO for 텟ţ::ଅ');  
113     
114 is(텟ţ::ଅ->ƈ_or_Ḋ, '텟ţ::Ḋ', '... got the expected method output');
115 is(텟ţ::ଅ->can('ƈ_or_Ḋ')->(), '텟ţ::Ḋ', '... can got the expected method output');
116 is(텟ţ::ଅ->ƈ_or_ऍ, '텟ţ::ऍ', '... got the expected method output');
117 is(텟ţ::ଅ->can('ƈ_or_ऍ')->(), '텟ţ::ऍ', '... can got the expected method output');