2 # Copyright (C) 2007-2010, Parrot Foundation.
7 t/oo/mro-c3.t - test the C3 Method Resolution Order for Parrot OO
15 Tests the C3 Method Resolution order for the OO implementation.
20 .include 'test_more.pir'
26 multiple_inheritance()
31 .sub method_A :method :nsentry('method_A')
32 .return('Method from A')
35 .sub method_B :method :nsentry('method_B')
36 .return('Method from B')
39 .sub method_C :method :nsentry('method_C')
40 .return('Method from C')
43 .sub method_D :method :nsentry('method_D')
44 .return('Method from D')
51 $P0 = get_global 'method_A'
52 A.'add_method'('foo', $P0)
53 A.'add_method'('bar', $P0)
57 $P0 = get_global 'method_B'
58 B.'add_method'('foo', $P0)
63 is($S0, 'Method from B', 'Single Parent - Method foo overloaded in B')
64 is($S1, 'Method from A', 'Single Parent - Method bar inherited from A')
71 $P0 = get_global 'method_A'
72 A.'add_method'('foo', $P0)
73 A.'add_method'('bar', $P0)
74 A.'add_method'('baz', $P0)
78 $P0 = get_global 'method_B'
79 B.'add_method'('foo', $P0)
80 B.'add_method'('bar', $P0)
84 $P0 = get_global 'method_C'
85 C.'add_method'('foo', $P0)
91 is($S0, 'Method from C', 'Grandparent - Method foo overloaded in C')
92 is($S1, 'Method from B', 'Grandparent - Method bar inherited from B')
93 is($S2, 'Method from A', 'Grandparent - Method baz inherited from A')
96 .sub multiple_inheritance
100 $P0 = get_global 'method_A'
101 A.'add_method'('foo', $P0)
102 A.'add_method'('bar', $P0)
103 A.'add_method'('baz', $P0)
106 $P0 = get_global 'method_B'
107 B.'add_method'('foo', $P0)
108 B.'add_method'('bar', $P0)
113 $P0 = get_global 'method_C'
114 C.'add_method'('foo', $P0)
120 is($S0, 'Method from C', 'Multiple Inheritance - Method foo overloaded in C')
121 is($S1, 'Method from B', 'Multiple Inheritance - Method bar inherited from B')
122 is($S2, 'Method from A', 'Multiple Inheritance - Method baz inherited from A')
125 .sub diamond_inheritance
126 .local pmc A, B, C, D
129 $P0 = get_global 'method_A'
130 A.'add_method'('foo', $P0)
131 A.'add_method'('bar', $P0)
132 A.'add_method'('baz', $P0)
133 A.'add_method'('wag', $P0)
137 $P0 = get_global 'method_B'
138 B.'add_method'('foo', $P0)
139 B.'add_method'('bar', $P0)
140 B.'add_method'('baz', $P0)
144 $P0 = get_global 'method_C'
145 C.'add_method'('foo', $P0)
146 C.'add_method'('bar', $P0)
151 $P0 = get_global 'method_D'
152 D.'add_method'('foo', $P0)
159 is($S0, 'Method from D', 'Diamond Inheritance - Method foo overloaded in D')
160 is($S1, 'Method from C', 'Diamond Inheritance - Method bar inherited from C')
161 is($S2, 'Method from B', 'Diamond Inheritance - Method baz inherited from B')
162 is($S3, 'Method from A', 'Diamond Inheritance - Method wag inherited from A')
172 $P0 = get_global 'method_C'
173 C.'add_method'('bar', $P0)
177 $P0 = get_global 'method_B'
178 B.'add_method'('bar', $P0)
183 $P0 = get_global 'method_A'
184 A.'add_method'('foo', $P0)
189 is($S0, 'Method from B', 'Merge Two Pairs - Method A.bar added from B')
195 todo(0, 'Merge Two Pairs - Method A.bar added from B', 'See TT#1426')
201 # vim: expandtab shiftwidth=4 ft=pir: