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