blob: cb1e4afeab64be41b5956f446eb28c8f41f17e9c [file] [log] [blame]
Aart Bikd141f452015-07-16 17:40:44 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//
18// Test on (in)variant static and instance field and array references in loops.
19//
20public class Main {
21
22 private static Object anObject = new Object();
23 private static Object anotherObject = new Object();
24
25 //
26 // Static fields.
27 //
28
29 private static boolean sZ;
30 private static byte sB;
31 private static char sC;
32 private static short sS;
33 private static int sI;
34 private static long sJ;
35 private static float sF;
36 private static double sD;
37 private static Object sL;
38
39 //
40 // Static arrays.
41 //
42
43 private static boolean[] sArrZ;
44 private static byte[] sArrB;
45 private static char[] sArrC;
46 private static short[] sArrS;
47 private static int[] sArrI;
48 private static long[] sArrJ;
49 private static float[] sArrF;
50 private static double[] sArrD;
51 private static Object[] sArrL;
52
53 //
54 // Instance fields.
55 //
56
57 private boolean mZ;
58 private byte mB;
59 private char mC;
60 private short mS;
61 private int mI;
62 private long mJ;
63 private float mF;
64 private double mD;
65 private Object mL;
66
67 //
68 // Instance arrays.
69 //
70
71 private boolean[] mArrZ;
72 private byte[] mArrB;
73 private char[] mArrC;
74 private short[] mArrS;
75 private int[] mArrI;
76 private long[] mArrJ;
77 private float[] mArrF;
78 private double[] mArrD;
79 private Object[] mArrL;
80
81 //
82 // Loops on static arrays with invariant static field references.
83 //
84
85 private static void SInvLoopZ() {
86 for (int i = 0; i < sArrZ.length; i++) {
87 sArrZ[i] = sZ;
88 }
89 }
90
91 private static void SInvLoopB() {
92 for (int i = 0; i < sArrB.length; i++) {
93 sArrB[i] = sB;
94 }
95 }
96
97 private static void SInvLoopC() {
98 for (int i = 0; i < sArrC.length; i++) {
99 sArrC[i] = sC;
100 }
101 }
102
103 private static void SInvLoopS() {
104 for (int i = 0; i < sArrS.length; i++) {
105 sArrS[i] = sS;
106 }
107 }
108
109 private static void SInvLoopI() {
110 for (int i = 0; i < sArrI.length; i++) {
111 sArrI[i] = sI;
112 }
113 }
114
115 private static void SInvLoopJ() {
116 for (int i = 0; i < sArrJ.length; i++) {
117 sArrJ[i] = sJ;
118 }
119 }
120
121 private static void SInvLoopF() {
122 for (int i = 0; i < sArrF.length; i++) {
123 sArrF[i] = sF;
124 }
125 }
126
127 private static void SInvLoopD() {
128 for (int i = 0; i < sArrD.length; i++) {
129 sArrD[i] = sD;
130 }
131 }
132
133 private static void SInvLoopL() {
134 for (int i = 0; i < sArrL.length; i++) {
135 sArrL[i] = sL;
136 }
137 }
138
139 //
140 // Loops on static arrays with variant static field references.
141 //
142
143 private static void SVarLoopZ() {
144 for (int i = 0; i < sArrZ.length; i++) {
145 sArrZ[i] = sZ;
146 if (i == 10)
147 sZ = !sZ;
148 }
149 }
150
151 private static void SVarLoopB() {
152 for (int i = 0; i < sArrB.length; i++) {
153 sArrB[i] = sB;
154 if (i == 10)
155 sB++;
156 }
157 }
158
159 private static void SVarLoopC() {
160 for (int i = 0; i < sArrC.length; i++) {
161 sArrC[i] = sC;
162 if (i == 10)
163 sC++;
164 }
165 }
166
167 private static void SVarLoopS() {
168 for (int i = 0; i < sArrS.length; i++) {
169 sArrS[i] = sS;
170 if (i == 10)
171 sS++;
172 }
173 }
174
175 private static void SVarLoopI() {
176 for (int i = 0; i < sArrI.length; i++) {
177 sArrI[i] = sI;
178 if (i == 10)
179 sI++;
180 }
181 }
182
183 private static void SVarLoopJ() {
184 for (int i = 0; i < sArrJ.length; i++) {
185 sArrJ[i] = sJ;
186 if (i == 10)
187 sJ++;
188 }
189 }
190
191 private static void SVarLoopF() {
192 for (int i = 0; i < sArrF.length; i++) {
193 sArrF[i] = sF;
194 if (i == 10)
195 sF++;
196 }
197 }
198
199 private static void SVarLoopD() {
200 for (int i = 0; i < sArrD.length; i++) {
201 sArrD[i] = sD;
202 if (i == 10)
203 sD++;
204 }
205 }
206
207 private static void SVarLoopL() {
208 for (int i = 0; i < sArrL.length; i++) {
209 sArrL[i] = sL;
210 if (i == 10)
211 sL = anotherObject;
212 }
213 }
214
215 //
Aart Bik5ef79942015-07-17 10:21:15 -0700216 // Loops on static arrays with a cross-over reference.
217 //
218
219 private static void SCrossOverLoopZ() {
220 for (int i = 0; i < sArrZ.length; i++) {
221 sArrZ[i] = !sArrZ[20];
222 }
223 }
224
225 private static void SCrossOverLoopB() {
226 for (int i = 0; i < sArrB.length; i++) {
227 sArrB[i] = (byte)(sArrB[20] + 2);
228 }
229 }
230
231 private static void SCrossOverLoopC() {
232 for (int i = 0; i < sArrC.length; i++) {
233 sArrC[i] = (char)(sArrC[20] + 2);
234 }
235 }
236
237 private static void SCrossOverLoopS() {
238 for (int i = 0; i < sArrS.length; i++) {
239 sArrS[i] = (short)(sArrS[20] + 2);
240 }
241 }
242
243 private static void SCrossOverLoopI() {
244 for (int i = 0; i < sArrI.length; i++) {
245 sArrI[i] = sArrI[20] + 2;
246 }
247 }
248
249 private static void SCrossOverLoopJ() {
250 for (int i = 0; i < sArrJ.length; i++) {
251 sArrJ[i] = sArrJ[20] + 2;
252 }
253 }
254
255 private static void SCrossOverLoopF() {
256 for (int i = 0; i < sArrF.length; i++) {
257 sArrF[i] = sArrF[20] + 2;
258 }
259 }
260
261 private static void SCrossOverLoopD() {
262 for (int i = 0; i < sArrD.length; i++) {
263 sArrD[i] = sArrD[20] + 2;
264 }
265 }
266
267 private static void SCrossOverLoopL() {
268 for (int i = 0; i < sArrL.length; i++) {
269 sArrL[i] = (sArrL[20] == anObject) ? anotherObject : anObject;
270 }
271 }
272
273 //
Aart Bikd141f452015-07-16 17:40:44 -0700274 // Loops on instance arrays with invariant instance field references.
275 //
276
277 private void InvLoopZ() {
278 for (int i = 0; i < mArrZ.length; i++) {
279 mArrZ[i] = mZ;
280 }
281 }
282
283 private void InvLoopB() {
284 for (int i = 0; i < mArrB.length; i++) {
285 mArrB[i] = mB;
286 }
287 }
288
289 private void InvLoopC() {
290 for (int i = 0; i < mArrC.length; i++) {
291 mArrC[i] = mC;
292 }
293 }
294
295 private void InvLoopS() {
296 for (int i = 0; i < mArrS.length; i++) {
297 mArrS[i] = mS;
298 }
299 }
300
301 private void InvLoopI() {
302 for (int i = 0; i < mArrI.length; i++) {
303 mArrI[i] = mI;
304 }
305 }
306
307 private void InvLoopJ() {
308 for (int i = 0; i < mArrJ.length; i++) {
309 mArrJ[i] = mJ;
310 }
311 }
312
313 private void InvLoopF() {
314 for (int i = 0; i < mArrF.length; i++) {
315 mArrF[i] = mF;
316 }
317 }
318
319 private void InvLoopD() {
320 for (int i = 0; i < mArrD.length; i++) {
321 mArrD[i] = mD;
322 }
323 }
324
325 private void InvLoopL() {
326 for (int i = 0; i < mArrL.length; i++) {
327 mArrL[i] = mL;
328 }
329 }
330
331 //
332 // Loops on instance arrays with variant instance field references.
333 //
334
335 private void VarLoopZ() {
336 for (int i = 0; i < mArrZ.length; i++) {
337 mArrZ[i] = mZ;
338 if (i == 10)
339 mZ = !mZ;
340 }
341 }
342
343 private void VarLoopB() {
344 for (int i = 0; i < mArrB.length; i++) {
345 mArrB[i] = mB;
346 if (i == 10)
347 mB++;
348 }
349 }
350
351 private void VarLoopC() {
352 for (int i = 0; i < mArrC.length; i++) {
353 mArrC[i] = mC;
354 if (i == 10)
355 mC++;
356 }
357 }
358
359 private void VarLoopS() {
360 for (int i = 0; i < mArrS.length; i++) {
361 mArrS[i] = mS;
362 if (i == 10)
363 mS++;
364 }
365 }
366
367 private void VarLoopI() {
368 for (int i = 0; i < mArrI.length; i++) {
369 mArrI[i] = mI;
370 if (i == 10)
371 mI++;
372 }
373 }
374
375 private void VarLoopJ() {
376 for (int i = 0; i < mArrJ.length; i++) {
377 mArrJ[i] = mJ;
378 if (i == 10)
379 mJ++;
380 }
381 }
382
383 private void VarLoopF() {
384 for (int i = 0; i < mArrF.length; i++) {
385 mArrF[i] = mF;
386 if (i == 10)
387 mF++;
388 }
389 }
390
391 private void VarLoopD() {
392 for (int i = 0; i < mArrD.length; i++) {
393 mArrD[i] = mD;
394 if (i == 10)
395 mD++;
396 }
397 }
398
399 private void VarLoopL() {
400 for (int i = 0; i < mArrL.length; i++) {
401 mArrL[i] = mL;
402 if (i == 10)
403 mL = anotherObject;
404 }
405 }
Aart Bik5ef79942015-07-17 10:21:15 -0700406
407 //
408 // Loops on instance arrays with a cross-over reference.
409 //
410
411 private void CrossOverLoopZ() {
412 for (int i = 0; i < mArrZ.length; i++) {
413 mArrZ[i] = !mArrZ[20];
414 }
415 }
416
417 private void CrossOverLoopB() {
418 for (int i = 0; i < mArrB.length; i++) {
419 mArrB[i] = (byte)(mArrB[20] + 2);
420 }
421 }
422
423 private void CrossOverLoopC() {
424 for (int i = 0; i < mArrC.length; i++) {
425 mArrC[i] = (char)(mArrC[20] + 2);
426 }
427 }
428
429 private void CrossOverLoopS() {
430 for (int i = 0; i < mArrS.length; i++) {
431 mArrS[i] = (short)(mArrS[20] + 2);
432 }
433 }
434
435 private void CrossOverLoopI() {
436 for (int i = 0; i < mArrI.length; i++) {
437 mArrI[i] = mArrI[20] + 2;
438 }
439 }
440
441 private void CrossOverLoopJ() {
442 for (int i = 0; i < mArrJ.length; i++) {
443 mArrJ[i] = mArrJ[20] + 2;
444 }
445 }
446
447 private void CrossOverLoopF() {
448 for (int i = 0; i < mArrF.length; i++) {
449 mArrF[i] = mArrF[20] + 2;
450 }
451 }
452
453 private void CrossOverLoopD() {
454 for (int i = 0; i < mArrD.length; i++) {
455 mArrD[i] = mArrD[20] + 2;
456 }
457 }
458
459 private void CrossOverLoopL() {
460 for (int i = 0; i < mArrL.length; i++) {
461 mArrL[i] = (mArrL[20] == anObject) ? anotherObject : anObject;
462 }
463 }
464
Aart Bikd141f452015-07-16 17:40:44 -0700465 //
466 // Driver and testers.
467 //
468
469 public static void main(String[] args) {
470 DoStaticTests();
471 new Main().DoInstanceTests();
472 }
473
474 private static void DoStaticTests() {
475 // Type Z.
476 sZ = true;
477 sArrZ = new boolean[100];
478 SInvLoopZ();
479 for (int i = 0; i < sArrZ.length; i++) {
480 expectEquals(true, sArrZ[i]);
481 }
482 SVarLoopZ();
483 for (int i = 0; i < sArrZ.length; i++) {
484 expectEquals(i <= 10, sArrZ[i]);
485 }
Aart Bik5ef79942015-07-17 10:21:15 -0700486 SCrossOverLoopZ();
487 for (int i = 0; i < sArrZ.length; i++) {
488 expectEquals(i <= 20, sArrZ[i]);
489 }
Aart Bikd141f452015-07-16 17:40:44 -0700490 // Type B.
491 sB = 1;
492 sArrB = new byte[100];
493 SInvLoopB();
494 for (int i = 0; i < sArrB.length; i++) {
495 expectEquals(1, sArrB[i]);
496 }
497 SVarLoopB();
498 for (int i = 0; i < sArrB.length; i++) {
499 expectEquals(i <= 10 ? 1 : 2, sArrB[i]);
500 }
Aart Bik5ef79942015-07-17 10:21:15 -0700501 SCrossOverLoopB();
502 for (int i = 0; i < sArrB.length; i++) {
503 expectEquals(i <= 20 ? 4 : 6, sArrB[i]);
504 }
Aart Bikd141f452015-07-16 17:40:44 -0700505 // Type C.
506 sC = 2;
507 sArrC = new char[100];
508 SInvLoopC();
509 for (int i = 0; i < sArrC.length; i++) {
510 expectEquals(2, sArrC[i]);
511 }
512 SVarLoopC();
513 for (int i = 0; i < sArrC.length; i++) {
514 expectEquals(i <= 10 ? 2 : 3, sArrC[i]);
515 }
Aart Bik5ef79942015-07-17 10:21:15 -0700516 SCrossOverLoopC();
517 for (int i = 0; i < sArrC.length; i++) {
518 expectEquals(i <= 20 ? 5 : 7, sArrC[i]);
519 }
Aart Bikd141f452015-07-16 17:40:44 -0700520 // Type S.
521 sS = 3;
522 sArrS = new short[100];
523 SInvLoopS();
524 for (int i = 0; i < sArrS.length; i++) {
525 expectEquals(3, sArrS[i]);
526 }
527 SVarLoopS();
528 for (int i = 0; i < sArrS.length; i++) {
529 expectEquals(i <= 10 ? 3 : 4, sArrS[i]);
530 }
Aart Bik5ef79942015-07-17 10:21:15 -0700531 SCrossOverLoopS();
532 for (int i = 0; i < sArrS.length; i++) {
533 expectEquals(i <= 20 ? 6 : 8, sArrS[i]);
534 }
Aart Bikd141f452015-07-16 17:40:44 -0700535 // Type I.
536 sI = 4;
537 sArrI = new int[100];
538 SInvLoopI();
539 for (int i = 0; i < sArrI.length; i++) {
540 expectEquals(4, sArrI[i]);
541 }
542 SVarLoopI();
543 for (int i = 0; i < sArrI.length; i++) {
544 expectEquals(i <= 10 ? 4 : 5, sArrI[i]);
545 }
Aart Bik5ef79942015-07-17 10:21:15 -0700546 SCrossOverLoopI();
547 for (int i = 0; i < sArrI.length; i++) {
548 expectEquals(i <= 20 ? 7 : 9, sArrI[i]);
549 }
Aart Bikd141f452015-07-16 17:40:44 -0700550 // Type J.
551 sJ = 5;
552 sArrJ = new long[100];
553 SInvLoopJ();
554 for (int i = 0; i < sArrJ.length; i++) {
555 expectEquals(5, sArrJ[i]);
556 }
557 SVarLoopJ();
558 for (int i = 0; i < sArrJ.length; i++) {
559 expectEquals(i <= 10 ? 5 : 6, sArrJ[i]);
560 }
Aart Bik5ef79942015-07-17 10:21:15 -0700561 SCrossOverLoopJ();
562 for (int i = 0; i < sArrJ.length; i++) {
563 expectEquals(i <= 20 ? 8 : 10, sArrJ[i]);
564 }
Aart Bikd141f452015-07-16 17:40:44 -0700565 // Type F.
566 sF = 6.0f;
567 sArrF = new float[100];
568 SInvLoopF();
569 for (int i = 0; i < sArrF.length; i++) {
570 expectEquals(6, sArrF[i]);
571 }
572 SVarLoopF();
573 for (int i = 0; i < sArrF.length; i++) {
574 expectEquals(i <= 10 ? 6 : 7, sArrF[i]);
575 }
Aart Bik5ef79942015-07-17 10:21:15 -0700576 SCrossOverLoopF();
577 for (int i = 0; i < sArrF.length; i++) {
578 expectEquals(i <= 20 ? 9 : 11, sArrF[i]);
579 }
Aart Bikd141f452015-07-16 17:40:44 -0700580 // Type D.
581 sD = 7.0;
582 sArrD = new double[100];
583 SInvLoopD();
584 for (int i = 0; i < sArrD.length; i++) {
585 expectEquals(7.0, sArrD[i]);
586 }
587 SVarLoopD();
588 for (int i = 0; i < sArrD.length; i++) {
589 expectEquals(i <= 10 ? 7 : 8, sArrD[i]);
590 }
Aart Bik5ef79942015-07-17 10:21:15 -0700591 SCrossOverLoopD();
592 for (int i = 0; i < sArrD.length; i++) {
593 expectEquals(i <= 20 ? 10 : 12, sArrD[i]);
594 }
Aart Bikd141f452015-07-16 17:40:44 -0700595 // Type L.
596 sL = anObject;
597 sArrL = new Object[100];
598 SInvLoopL();
599 for (int i = 0; i < sArrL.length; i++) {
600 expectEquals(anObject, sArrL[i]);
601 }
602 SVarLoopL();
603 for (int i = 0; i < sArrL.length; i++) {
604 expectEquals(i <= 10 ? anObject : anotherObject, sArrL[i]);
605 }
Aart Bik5ef79942015-07-17 10:21:15 -0700606 SCrossOverLoopL();
607 for (int i = 0; i < sArrL.length; i++) {
608 expectEquals(i <= 20 ? anObject : anotherObject, sArrL[i]);
609 }
Aart Bikd141f452015-07-16 17:40:44 -0700610 }
611
612 private void DoInstanceTests() {
613 // Type Z.
614 mZ = true;
615 mArrZ = new boolean[100];
616 InvLoopZ();
617 for (int i = 0; i < mArrZ.length; i++) {
618 expectEquals(true, mArrZ[i]);
619 }
620 VarLoopZ();
621 for (int i = 0; i < mArrZ.length; i++) {
622 expectEquals(i <= 10, mArrZ[i]);
623 }
Aart Bik5ef79942015-07-17 10:21:15 -0700624 CrossOverLoopZ();
625 for (int i = 0; i < mArrZ.length; i++) {
626 expectEquals(i <= 20, mArrZ[i]);
627 }
Aart Bikd141f452015-07-16 17:40:44 -0700628 // Type B.
629 mB = 1;
630 mArrB = new byte[100];
631 InvLoopB();
632 for (int i = 0; i < mArrB.length; i++) {
633 expectEquals(1, mArrB[i]);
634 }
635 VarLoopB();
636 for (int i = 0; i < mArrB.length; i++) {
637 expectEquals(i <= 10 ? 1 : 2, mArrB[i]);
638 }
Aart Bik5ef79942015-07-17 10:21:15 -0700639 CrossOverLoopB();
640 for (int i = 0; i < mArrB.length; i++) {
641 expectEquals(i <= 20 ? 4 : 6, mArrB[i]);
642 }
Aart Bikd141f452015-07-16 17:40:44 -0700643 // Type C.
644 mC = 2;
645 mArrC = new char[100];
646 InvLoopC();
647 for (int i = 0; i < mArrC.length; i++) {
648 expectEquals(2, mArrC[i]);
649 }
650 VarLoopC();
651 for (int i = 0; i < mArrC.length; i++) {
652 expectEquals(i <= 10 ? 2 : 3, mArrC[i]);
653 }
Aart Bik5ef79942015-07-17 10:21:15 -0700654 CrossOverLoopC();
655 for (int i = 0; i < mArrC.length; i++) {
656 expectEquals(i <= 20 ? 5 : 7, mArrC[i]);
657 }
Aart Bikd141f452015-07-16 17:40:44 -0700658 // Type S.
659 mS = 3;
660 mArrS = new short[100];
661 InvLoopS();
662 for (int i = 0; i < mArrS.length; i++) {
663 expectEquals(3, mArrS[i]);
664 }
665 VarLoopS();
666 for (int i = 0; i < mArrS.length; i++) {
667 expectEquals(i <= 10 ? 3 : 4, mArrS[i]);
668 }
Aart Bik5ef79942015-07-17 10:21:15 -0700669 CrossOverLoopS();
670 for (int i = 0; i < mArrS.length; i++) {
671 expectEquals(i <= 20 ? 6 : 8, mArrS[i]);
672 }
Aart Bikd141f452015-07-16 17:40:44 -0700673 // Type I.
674 mI = 4;
675 mArrI = new int[100];
676 InvLoopI();
677 for (int i = 0; i < mArrI.length; i++) {
678 expectEquals(4, mArrI[i]);
679 }
680 VarLoopI();
681 for (int i = 0; i < mArrI.length; i++) {
682 expectEquals(i <= 10 ? 4 : 5, mArrI[i]);
683 }
Aart Bik5ef79942015-07-17 10:21:15 -0700684 CrossOverLoopI();
685 for (int i = 0; i < mArrI.length; i++) {
686 expectEquals(i <= 20 ? 7 : 9, mArrI[i]);
687 }
Aart Bikd141f452015-07-16 17:40:44 -0700688 // Type J.
689 mJ = 5;
690 mArrJ = new long[100];
691 InvLoopJ();
692 for (int i = 0; i < mArrJ.length; i++) {
693 expectEquals(5, mArrJ[i]);
694 }
695 VarLoopJ();
696 for (int i = 0; i < mArrJ.length; i++) {
697 expectEquals(i <= 10 ? 5 : 6, mArrJ[i]);
698 }
Aart Bik5ef79942015-07-17 10:21:15 -0700699 CrossOverLoopJ();
700 for (int i = 0; i < mArrJ.length; i++) {
701 expectEquals(i <= 20 ? 8 : 10, mArrJ[i]);
702 }
Aart Bikd141f452015-07-16 17:40:44 -0700703 // Type F.
704 mF = 6.0f;
705 mArrF = new float[100];
706 InvLoopF();
707 for (int i = 0; i < mArrF.length; i++) {
708 expectEquals(6, mArrF[i]);
709 }
710 VarLoopF();
711 for (int i = 0; i < mArrF.length; i++) {
712 expectEquals(i <= 10 ? 6 : 7, mArrF[i]);
713 }
Aart Bik5ef79942015-07-17 10:21:15 -0700714 CrossOverLoopF();
715 for (int i = 0; i < mArrF.length; i++) {
716 expectEquals(i <= 20 ? 9 : 11, mArrF[i]);
717 }
Aart Bikd141f452015-07-16 17:40:44 -0700718 // Type D.
719 mD = 7.0;
720 mArrD = new double[100];
721 InvLoopD();
722 for (int i = 0; i < mArrD.length; i++) {
723 expectEquals(7.0, mArrD[i]);
724 }
725 VarLoopD();
726 for (int i = 0; i < mArrD.length; i++) {
727 expectEquals(i <= 10 ? 7 : 8, mArrD[i]);
728 }
Aart Bik5ef79942015-07-17 10:21:15 -0700729 CrossOverLoopD();
730 for (int i = 0; i < mArrD.length; i++) {
731 expectEquals(i <= 20 ? 10 : 12, mArrD[i]);
732 }
Aart Bikd141f452015-07-16 17:40:44 -0700733 // Type L.
734 mL = anObject;
735 mArrL = new Object[100];
736 InvLoopL();
737 for (int i = 0; i < mArrL.length; i++) {
738 expectEquals(anObject, mArrL[i]);
739 }
740 VarLoopL();
741 for (int i = 0; i < mArrL.length; i++) {
742 expectEquals(i <= 10 ? anObject : anotherObject, mArrL[i]);
743 }
Aart Bik5ef79942015-07-17 10:21:15 -0700744 CrossOverLoopL();
745 for (int i = 0; i < mArrL.length; i++) {
746 expectEquals(i <= 20 ? anObject : anotherObject, mArrL[i]);
747 }
Aart Bikd141f452015-07-16 17:40:44 -0700748 }
749
750 private static void expectEquals(boolean expected, boolean result) {
751 if (expected != result) {
752 throw new Error("Expected: " + expected + ", found: " + result);
753 }
754 }
755
756 private static void expectEquals(byte expected, byte result) {
757 if (expected != result) {
758 throw new Error("Expected: " + expected + ", found: " + result);
759 }
760 }
761
762 private static void expectEquals(char expected, char result) {
763 if (expected != result) {
764 throw new Error("Expected: " + expected + ", found: " + result);
765 }
766 }
767
768 private static void expectEquals(short expected, short result) {
769 if (expected != result) {
770 throw new Error("Expected: " + expected + ", found: " + result);
771 }
772 }
773
774 private static void expectEquals(int expected, int result) {
775 if (expected != result) {
776 throw new Error("Expected: " + expected + ", found: " + result);
777 }
778 }
779
780 private static void expectEquals(long expected, long result) {
781 if (expected != result) {
782 throw new Error("Expected: " + expected + ", found: " + result);
783 }
784 }
785
786 private static void expectEquals(float expected, float result) {
787 if (expected != result) {
788 throw new Error("Expected: " + expected + ", found: " + result);
789 }
790 }
791
792 private static void expectEquals(double expected, double result) {
793 if (expected != result) {
794 throw new Error("Expected: " + expected + ", found: " + result);
795 }
796 }
797
798 private static void expectEquals(Object expected, Object result) {
799 if (expected != result) {
800 throw new Error("Expected: " + expected + ", found: " + result);
801 }
802 }
803}