2 # Copyright (C) 2007, 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 .return('Method from A')
35 .return('Method from B')
39 .return('Method from C')
43 .return('Method from D')
50 $P0 = get_global 'method_A'
51 A.'add_method'('foo', $P0)
52 A.'add_method'('bar', $P0)
56 $P0 = get_global 'method_B'
57 B.'add_method'('foo', $P0)
62 is($S0, 'Method from B', 'Single Parent - Method foo overloaded in B')
63 is($S1, 'Method from A', 'Single Parent - Method bar inherited from A')
70 $P0 = get_global 'method_A'
71 A.'add_method'('foo', $P0)
72 A.'add_method'('bar', $P0)
73 A.'add_method'('baz', $P0)
77 $P0 = get_global 'method_B'
78 B.'add_method'('foo', $P0)
79 B.'add_method'('bar', $P0)
83 $P0 = get_global 'method_C'
84 C.'add_method'('foo', $P0)
90 is($S0, 'Method from C', 'Grandparent - Method foo overloaded in C')
91 is($S1, 'Method from B', 'Grandparent - Method bar inherited from B')
92 is($S2, 'Method from A', 'Grandparent - Method baz inherited from A')
95 .sub multiple_inheritance
99 $P0 = get_global 'method_A'
100 A.'add_method'('foo', $P0)
101 A.'add_method'('bar', $P0)
102 A.'add_method'('baz', $P0)
105 $P0 = get_global 'method_B'
106 B.'add_method'('foo', $P0)
107 B.'add_method'('bar', $P0)
112 $P0 = get_global 'method_C'
113 C.'add_method'('foo', $P0)
119 is($S0, 'Method from C', 'Multiple Inheritance - Method foo overloaded in C')
120 is($S1, 'Method from B', 'Multiple Inheritance - Method bar inherited from B')
121 is($S2, 'Method from A', 'Multiple Inheritance - Method baz inherited from A')
124 .sub diamond_inheritance
125 .local pmc A, B, C, D
128 $P0 = get_global 'method_A'
129 A.'add_method'('foo', $P0)
130 A.'add_method'('bar', $P0)
131 A.'add_method'('baz', $P0)
132 A.'add_method'('wag', $P0)
136 $P0 = get_global 'method_B'
137 B.'add_method'('foo', $P0)
138 B.'add_method'('bar', $P0)
139 B.'add_method'('baz', $P0)
143 $P0 = get_global 'method_C'
144 C.'add_method'('foo', $P0)
145 C.'add_method'('bar', $P0)
150 $P0 = get_global 'method_D'
151 D.'add_method'('foo', $P0)
158 is($S0, 'Method from D', 'Diamond Inheritance - Method foo overloaded in D')
159 is($S1, 'Method from C', 'Diamond Inheritance - Method bar inherited from C')
160 is($S2, 'Method from B', 'Diamond Inheritance - Method baz inherited from B')
161 is($S3, 'Method from A', 'Diamond Inheritance - Method wag inherited from A')
168 # vim: expandtab shiftwidth=4 ft=pir: