OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // A plain class that implements many fields. | 7 // A plain class that implements many fields. |
8 class A { | 8 class A { |
9 var fieldA1 = 0x1; | 9 var fieldA1 = 0x1; |
10 var fieldA2 = 0x2; | 10 var fieldA2 = 0x2; |
11 var fieldA3 = 0x4; | 11 var fieldA3 = 0x4; |
12 var fieldA4 = 0x8; | 12 var fieldA4 = 0x8; |
13 | 13 |
14 var fieldB1 = 0x10; | 14 var fieldB1 = 0x10; |
15 var fieldB2 = 0x20; | 15 var fieldB2 = 0x20; |
16 var fieldB3 = 0x40; | 16 var fieldB3 = 0x40; |
17 var fieldB4 = 0x80; | 17 var fieldB4 = 0x80; |
18 | 18 |
19 var fieldC1 = 0x100; | 19 var fieldC1 = 0x100; |
20 var fieldC2 = 0x200; | 20 var fieldC2 = 0x200; |
21 var fieldC3 = 0x400; | 21 var fieldC3 = 0x400; |
22 var fieldC4 = 0x800; | 22 var fieldC4 = 0x800; |
23 | 23 |
24 var fieldD1 = 0x1000; | 24 var fieldD1 = 0x1000; |
25 var fieldD2 = 0x2000; | 25 var fieldD2 = 0x2000; |
26 var fieldD3 = 0x4000; | 26 var fieldD3 = 0x4000; |
27 var fieldD4 = 0x8000; | 27 var fieldD4 = 0x8000; |
28 | 28 |
29 var fieldXA1 = 0x1; | 29 var fieldXA1 = 0x1; |
30 var fieldXA2 = 0x2; | 30 var fieldXA2 = 0x2; |
31 var fieldXA3 = 0x4; | 31 var fieldXA3 = 0x4; |
32 var fieldXA4 = 0x8; | 32 var fieldXA4 = 0x8; |
33 | 33 |
34 var fieldXB1 = 0x10; | 34 var fieldXB1 = 0x10; |
35 var fieldXB2 = 0x20; | 35 var fieldXB2 = 0x20; |
36 var fieldXB3 = 0x40; | 36 var fieldXB3 = 0x40; |
37 var fieldXB4 = 0x80; | 37 var fieldXB4 = 0x80; |
38 | 38 |
39 var fieldXC1 = 0x1; | 39 var fieldXC1 = 0x1; |
40 var fieldXC2 = 0x2; | 40 var fieldXC2 = 0x2; |
41 var fieldXC3 = 0x4; | 41 var fieldXC3 = 0x4; |
42 var fieldXC4 = 0x8; | 42 var fieldXC4 = 0x8; |
43 | 43 |
44 var fieldXD1 = 0x10; | 44 var fieldXD1 = 0x10; |
45 var fieldXD2 = 0x20; | 45 var fieldXD2 = 0x20; |
46 var fieldXD3 = 0x40; | 46 var fieldXD3 = 0x40; |
47 var fieldXD4 = 0x80; | 47 var fieldXD4 = 0x80; |
48 | 48 |
49 var fieldYA1 = 0x1; | 49 var fieldYA1 = 0x1; |
50 var fieldYA2 = 0x200; | 50 var fieldYA2 = 0x200; |
51 var fieldYA3 = 0x400; | 51 var fieldYA3 = 0x400; |
52 var fieldYA4 = 0x800; | 52 var fieldYA4 = 0x800; |
53 | 53 |
54 var fieldYB1 = 0x10; | 54 var fieldYB1 = 0x10; |
55 var fieldYB2 = 0x200; | 55 var fieldYB2 = 0x200; |
56 var fieldYB3 = 0x400; | 56 var fieldYB3 = 0x400; |
57 var fieldYB4 = 0x800; | 57 var fieldYB4 = 0x800; |
58 | 58 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 var fieldYC3 = 0x420; | 128 var fieldYC3 = 0x420; |
129 var fieldYC4 = 0x800; | 129 var fieldYC4 = 0x800; |
130 | 130 |
131 var fieldYD1 = 0x1008; | 131 var fieldYD1 = 0x1008; |
132 var fieldYD2 = 0x2004; | 132 var fieldYD2 = 0x2004; |
133 var fieldYD3 = 0x4002; | 133 var fieldYD3 = 0x4002; |
134 var fieldYD4 = 0x8000; | 134 var fieldYD4 = 0x8000; |
135 } | 135 } |
136 | 136 |
137 // Mix in the mixin into the full implementation, shadowing some fields. | 137 // Mix in the mixin into the full implementation, shadowing some fields. |
138 class E extends A with C { | 138 class E extends A with C {} |
139 } | |
140 | 139 |
141 // Another mixin for block C. | 140 // Another mixin for block C. |
142 class F { | 141 class F { |
143 var fieldYA1 = 0x0001; | 142 var fieldYA1 = 0x0001; |
144 var fieldYA2 = 0x1022; | 143 var fieldYA2 = 0x1022; |
145 var fieldYA3 = 0x0004; | 144 var fieldYA3 = 0x0004; |
146 var fieldYA4 = 0x0088; | 145 var fieldYA4 = 0x0088; |
147 | 146 |
148 var fieldYB1 = 0x0410; | 147 var fieldYB1 = 0x0410; |
149 var fieldYB2 = 0x0022; | 148 var fieldYB2 = 0x0022; |
150 var fieldYB3 = 0x0040; | 149 var fieldYB3 = 0x0040; |
151 var fieldYB4 = 0x0880; | 150 var fieldYB4 = 0x0880; |
152 | 151 |
153 var fieldYC1 = 0x1001; | 152 var fieldYC1 = 0x1001; |
154 var fieldYC2 = 0x2200; | 153 var fieldYC2 = 0x2200; |
155 var fieldYC3 = 0x4400; | 154 var fieldYC3 = 0x4400; |
156 var fieldYC4 = 0x8800; | 155 var fieldYC4 = 0x8800; |
157 | 156 |
158 var fieldYD1 = 0x1108; | 157 var fieldYD1 = 0x1108; |
159 var fieldYD2 = 0x2200; | 158 var fieldYD2 = 0x2200; |
160 var fieldYD3 = 0x4044; | 159 var fieldYD3 = 0x4044; |
161 var fieldYD4 = 0x8001; | 160 var fieldYD4 = 0x8001; |
162 } | 161 } |
163 | 162 |
164 // Use two mixins in a single class. | 163 // Use two mixins in a single class. |
165 class G extends B with C, F { | 164 class G extends B with C, F {} |
166 } | |
167 | 165 |
168 bool checkFields(cls) { | 166 bool checkFields(cls) { |
169 var blockA = | 167 var blockA = cls.fieldA1 ^ |
170 cls.fieldA1 ^ cls.fieldA2 ^ cls.fieldA3 ^ cls.fieldA4 ^ | 168 cls.fieldA2 ^ |
171 cls.fieldB1 ^ cls.fieldB2 ^ cls.fieldB3 ^ cls.fieldB4 ^ | 169 cls.fieldA3 ^ |
172 cls.fieldC1 ^ cls.fieldC2 ^ cls.fieldC3 ^ cls.fieldC4 ^ | 170 cls.fieldA4 ^ |
173 cls.fieldD1 ^ cls.fieldD2 ^ cls.fieldD3 ^ cls.fieldD4; | 171 cls.fieldB1 ^ |
174 var blockB = | 172 cls.fieldB2 ^ |
175 cls.fieldXA1 ^ cls.fieldXA2 ^ cls.fieldXA3 ^ cls.fieldXA4 ^ | 173 cls.fieldB3 ^ |
176 cls.fieldXB1 ^ cls.fieldXB2 ^ cls.fieldXB3 ^ cls.fieldXB4 ^ | 174 cls.fieldB4 ^ |
177 cls.fieldXC1 ^ cls.fieldXC2 ^ cls.fieldXC3 ^ cls.fieldXC4 ^ | 175 cls.fieldC1 ^ |
178 cls.fieldXD1 ^ cls.fieldXD2 ^ cls.fieldXD3 ^ cls.fieldXD4; | 176 cls.fieldC2 ^ |
179 var blockC = | 177 cls.fieldC3 ^ |
180 cls.fieldYA1 ^ cls.fieldYA2 ^ cls.fieldYA3 ^ cls.fieldYA4 ^ | 178 cls.fieldC4 ^ |
181 cls.fieldYB1 ^ cls.fieldYB2 ^ cls.fieldYB3 ^ cls.fieldYB4 ^ | 179 cls.fieldD1 ^ |
182 cls.fieldYC1 ^ cls.fieldYC2 ^ cls.fieldYC3 ^ cls.fieldYC4 ^ | 180 cls.fieldD2 ^ |
183 cls.fieldYD1 ^ cls.fieldYD2 ^ cls.fieldYD3 ^ cls.fieldYD4; | 181 cls.fieldD3 ^ |
| 182 cls.fieldD4; |
| 183 var blockB = cls.fieldXA1 ^ |
| 184 cls.fieldXA2 ^ |
| 185 cls.fieldXA3 ^ |
| 186 cls.fieldXA4 ^ |
| 187 cls.fieldXB1 ^ |
| 188 cls.fieldXB2 ^ |
| 189 cls.fieldXB3 ^ |
| 190 cls.fieldXB4 ^ |
| 191 cls.fieldXC1 ^ |
| 192 cls.fieldXC2 ^ |
| 193 cls.fieldXC3 ^ |
| 194 cls.fieldXC4 ^ |
| 195 cls.fieldXD1 ^ |
| 196 cls.fieldXD2 ^ |
| 197 cls.fieldXD3 ^ |
| 198 cls.fieldXD4; |
| 199 var blockC = cls.fieldYA1 ^ |
| 200 cls.fieldYA2 ^ |
| 201 cls.fieldYA3 ^ |
| 202 cls.fieldYA4 ^ |
| 203 cls.fieldYB1 ^ |
| 204 cls.fieldYB2 ^ |
| 205 cls.fieldYB3 ^ |
| 206 cls.fieldYB4 ^ |
| 207 cls.fieldYC1 ^ |
| 208 cls.fieldYC2 ^ |
| 209 cls.fieldYC3 ^ |
| 210 cls.fieldYC4 ^ |
| 211 cls.fieldYD1 ^ |
| 212 cls.fieldYD2 ^ |
| 213 cls.fieldYD3 ^ |
| 214 cls.fieldYD4; |
184 return blockA == 0xFFFF && blockB == 0x0000 && blockC == 0x1111; | 215 return blockA == 0xFFFF && blockB == 0x0000 && blockC == 0x1111; |
185 } | 216 } |
186 | 217 |
187 main () { | 218 main() { |
188 var instances = [new A(), new D(), new E(), new G()]; | 219 var instances = [new A(), new D(), new E(), new G()]; |
189 for (var instance in instances) { | 220 for (var instance in instances) { |
190 Expect.isTrue(checkFields(instance)); | 221 Expect.isTrue(checkFields(instance)); |
191 } | 222 } |
192 } | 223 } |
OLD | NEW |