blob: 4c445b76b1e3d43ea896000e868363e0f0871880 [file] [log] [blame]
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
buzbee4a3164f2011-09-03 11:25:10 -07003class IntMath extends IntMathBase {
Brian Carlstrom9f30b382011-08-28 22:41:38 -07004
5 public static boolean mBoolean1, mBoolean2;
6 public static byte mByte1, mByte2;
7 public static char mChar1, mChar2;
8 public static short mShort1, mShort2;
9 public static int mInt1, mInt2;
10 public static float mFloat1, mFloat2;
11 public static long mLong1, mLong2;
12 public static double mDouble1, mDouble2;
13 public static volatile long mVolatileLong1, mVolatileLong2;
14
15
16 private int foo_;
17
18 public IntMath(int stuff) {
buzbee4a3164f2011-09-03 11:25:10 -070019 super();
Brian Carlstrom9f30b382011-08-28 22:41:38 -070020 foo_ = stuff;
21 }
22
23 public IntMath() {
buzbee4a3164f2011-09-03 11:25:10 -070024 super();
Brian Carlstrom9f30b382011-08-28 22:41:38 -070025 foo_ = 123;
26 }
27
buzbeef0cde542011-09-13 14:55:02 -070028 /* Regression test: triggered an SSA renaming bug. */
29 static long divideLongByBillion(long a) {
30 long quot;
31 long rem;
32
33 if (a >= 0) {
34 long bLong = 1000000000L;
35 quot = (a / bLong);
36 rem = (a % bLong);
37 } else {
38 /*
39 * Make the dividend positive shifting it right by 1 bit then get
40 * the quotient an remainder and correct them properly
41 */
42 long aPos = a >>> 1;
43 long bPos = 1000000000L >>> 1;
44 quot = aPos / bPos;
45 rem = aPos % bPos;
46 // double the remainder and add 1 if 'a' is odd
47 rem = (rem << 1) + (a & 1);
48 }
49 return ((rem << 32) | (quot & 0xFFFFFFFFL));
50 }
51
52
buzbee2a475e72011-09-07 17:19:17 -070053 static int instanceTest(int x) {
54 IntMathBase a = new IntMathBase();
55 IntMath b = new IntMath();
56
57 if (a instanceof IntMathBase) {
58 x = x * 2;
59 }
60
61 if (a instanceof IntMath) {
62 x = x + 13;
63 }
64
65 if (b instanceof IntMathBase) {
66 x = x -1;
67 }
68
69 if (b instanceof IntMath) {
70 x = x + 1333;
71 }
72 return x;
73 }
74
buzbee4a3164f2011-09-03 11:25:10 -070075 int tryThing() {
76 int val = super.tryThing();
77 return val + 10;
78 }
79
80 static int superTest(int x) {
81 IntMath instance = new IntMath();
82 IntMath base = instance;
83 int val1 = instance.tryThing();
84 int val2 = base.tryThing();
85 return val1 + val2 + x;
86 }
87
buzbee561227c2011-09-02 15:28:19 -070088 static int constClassTest(int x) {
89 Class c = String.class;
90 if (c != null) {
91 return x * 2;
92 } else {
93 return x;
94 }
95 }
96
buzbee1b4c8592011-08-31 10:43:51 -070097 static int constStringTest(int x) {
buzbee1b4c8592011-08-31 10:43:51 -070098 String str = "Hello World!";
buzbee2a475e72011-09-07 17:19:17 -070099 return x + str.length();
buzbee1b4c8592011-08-31 10:43:51 -0700100 }
101
102 static void throwNullPointerException() {
103 throw new NullPointerException();
104 }
105
106 static int catchBlock(int x) {
107 try {
108 x += 123;
109 throwNullPointerException();
110 } catch (NullPointerException npe) {
111 x += 456;
112 }
113 return x;
114 }
115
buzbeee9a72f62011-09-04 17:59:07 -0700116 static int catchBlockNoThrow(int x) {
117 try {
118 x += 123;
119 } catch (NullPointerException npe) {
120 x += 456;
121 }
122 return x;
123 }
124
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700125 static int staticFieldTest(int x) {
126 mBoolean1 = true;
127 mBoolean2 = false;
128 mByte1 = 127;
129 mByte2 = -128;
130 mChar1 = 32767;
131 mChar2 = 65535;
132 mShort1 = 32767;
133 mShort2 = -32768;
134 mInt1 = 65537;
135 mInt2 = -65537;
136 mFloat1 = 3.1415f;
137 mFloat2 = -1.0f / 0.0f; // -inf
138 mLong1 = 1234605616436508552L; // 0x1122334455667788
139 mLong2 = -1234605616436508552L;
140 mDouble1 = 3.1415926535;
141 mDouble2 = 1.0 / 0.0; // +inf
142 mVolatileLong1 = mLong1 - 1;
143 mVolatileLong2 = mLong2 + 1;
144
145 if (!mBoolean1) { return 10; }
146 if (mBoolean2) { return 11; }
147 if (mByte1 != 127) { return 12; }
148 if (mByte2 != -128) { return 13; }
149 if (mChar1 != 32767) { return 14; }
150 if (mChar2 != 65535) { return 15; }
151 if (mShort1 != 32767) { return 16; }
152 if (mShort2 != -32768) { return 17; }
153 if (mInt1 != 65537) { return 18; }
154 if (mInt2 != -65537) { return 19; }
155 if (!(mFloat1 > 3.141f && mFloat1 < 3.142f)) { return 20; }
156 if (mFloat2 >= mFloat1) { return 21; }
157 if (mLong1 != 1234605616436508552L) { return 22; }
158 if (mLong2 != -1234605616436508552L) { return 23; }
159 if (!(mDouble1 > 3.141592653 && mDouble1 < 3.141592654)) { return 24; }
160 if (mDouble2 <= mDouble1) { return 25; }
161 if (mVolatileLong1 != 1234605616436508551L) { return 26; }
162 if (mVolatileLong2 != -1234605616436508551L) { return 27; }
163
164 return 1000 + x;
165 }
166
167 /*
168 * Try to cause some unary operations.
169 */
170 static int unopTest(int x) {
171 x = -x;
172 x ^= 0xffffffff;
173 return x;
174 }
175
176 static int shiftTest1() {
177 final int[] mBytes = {
178 0x11, 0x22, 0x33, 0x44, 0x88, 0x99, 0xaa, 0xbb
179 };
180 long l;
181 int i1, i2;
182
183 if (mBytes[0] != 0x11) return 20;
184 if (mBytes[1] != 0x22) return 21;
185 if (mBytes[2] != 0x33) return 22;
186 if (mBytes[3] != 0x44) return 23;
187 if (mBytes[4] != 0x88) return 24;
188 if (mBytes[5] != 0x99) return 25;
189 if (mBytes[6] != 0xaa) return 26;
190 if (mBytes[7] != 0xbb) return 27;
191
192 i1 = mBytes[0] | mBytes[1] << 8 | mBytes[2] << 16 | mBytes[3] << 24;
193 i2 = mBytes[4] | mBytes[5] << 8 | mBytes[6] << 16 | mBytes[7] << 24;
194 l = i1 | ((long)i2 << 32);
195
196 if (i1 != 0x44332211) { return 0x80000000 | i1; }
197 if (i2 != 0xbbaa9988) { return 2; }
198 if (l != 0xbbaa998844332211L) { return 3; }
199
200 l = (long)mBytes[0]
201 | (long)mBytes[1] << 8
202 | (long)mBytes[2] << 16
203 | (long)mBytes[3] << 24
204 | (long)mBytes[4] << 32
205 | (long)mBytes[5] << 40
206 | (long)mBytes[6] << 48
207 | (long)mBytes[7] << 56;
208
209 if (l != 0xbbaa998844332211L) { return 4; }
210 return 0;
211 }
212
213 static int shiftTest2() {
214
215 long a = 0x11;
216 long b = 0x22;
217 long c = 0x33;
218 long d = 0x44;
219 long e = 0x55;
220 long f = 0x66;
221 long g = 0x77;
222 long h = 0x88;
223
224 long result = ((a << 56) | (b << 48) | (c << 40) | (d << 32) |
225 (e << 24) | (f << 16) | (g << 8) | h);
226
227 if (result != 0x1122334455667788L) { return 1; }
228 return 0;
229 }
230
231 static int unsignedShiftTest() {
232 byte b = -4;
233 short s = -4;
234 char c = 0xfffc;
235 int i = -4;
236
237 b >>>= 4;
238 s >>>= 4;
239 c >>>= 4;
240 i >>>= 4;
241
242 if ((int) b != -1) { return 1; }
243 if ((int) s != -1) { return 2; }
244 if ((int) c != 0x0fff) { return 3; }
245 if (i != 268435455) { return 4; }
246 return 0;
247 }
248
249 static int convTest() {
250
251 float f;
252 double d;
253 int i;
254 long l;
255
256 /* int --> long */
257 i = 7654;
258 l = (long) i;
259 if (l != 7654L) { return 1; }
260
261 i = -7654;
262 l = (long) i;
263 if (l != -7654L) { return 2; }
264
265 /* long --> int (with truncation) */
266 l = 5678956789L;
267 i = (int) l;
268 if (i != 1383989493) { return 3; }
269
270 l = -5678956789L;
271 i = (int) l;
272 if (i != -1383989493) { return 4; }
273 return 0;
274 }
275
276 static int charSubTest() {
277
278 char char1 = 0x00e9;
279 char char2 = 0xffff;
280 int i;
281
282 /* chars are unsigned-expanded to ints before subtraction */
283 i = char1 - char2;
284 if (i != 0xffff00ea) { return 1; }
285 return 0;
286 }
287
288 /*
289 * We pass in the arguments and return the results so the compiler
290 * doesn't do the math for us. (x=70000, y=-3)
291 */
292 static int intOperTest(int x, int y) {
293 int[] results = new int[10];
294
295 /* this seems to generate "op-int" instructions */
296 results[0] = x + y;
297 results[1] = x - y;
298 results[2] = x * y;
299 results[3] = x * x;
300 results[4] = x / y;
301 results[5] = x % -y;
302 results[6] = x & y;
303 results[7] = x | y;
304 results[8] = x ^ y;
305
306 /* this seems to generate "op-int/2addr" instructions */
307 results[9] = x + ((((((((x + y) - y) * y) / y) % y) & y) | y) ^ y);
308
309 /* check this edge case while we're here (div-int/2addr) */
310 int minInt = -2147483648;
311 int negOne = -results[5];
312 int plusOne = 1;
313 int result = (((minInt + plusOne) - plusOne) / negOne) / negOne;
314
315 if (result != minInt) { return 1;};
316 if (results[0] != 69997) { return 2;};
317 if (results[1] != 70003) { return 3;};
318 if (results[2] != -210000) { return 4;};
319 if (results[3] != 605032704) { return 5;};
320 if (results[4] != -23333) { return 6;};
321 if (results[5] != 1) { return 7;};
322 if (results[6] != 70000) { return 8;};
323 if (results[7] != -3) { return 9;};
324 if (results[8] != -70003) { return 10;};
325 if (results[9] != 70000) { return 11;};
326
327 return 0;
328 }
329
330 /*
331 * More operations, this time with 16-bit constants. (x=77777)
332 */
333 static int lit16Test(int x) {
334
335 int[] results = new int[8];
336
337 /* try to generate op-int/lit16" instructions */
338 results[0] = x + 1000;
339 results[1] = 1000 - x;
340 results[2] = x * 1000;
341 results[3] = x / 1000;
342 results[4] = x % 1000;
343 results[5] = x & 1000;
344 results[6] = x | -1000;
345 results[7] = x ^ -1000;
346
347 if (results[0] != 78777) { return 1; }
348 if (results[1] != -76777) { return 2; }
349 if (results[2] != 77777000) { return 3; }
350 if (results[3] != 77) { return 4; }
351 if (results[4] != 777) { return 5; }
352 if (results[5] != 960) { return 6; }
353 if (results[6] != -39) { return 7; }
354 if (results[7] != -76855) { return 8; }
355 return 0;
356 }
357
358 /*
359 * More operations, this time with 8-bit constants. (x=-55555)
360 */
361 static int lit8Test(int x) {
362
363 int[] results = new int[8];
364
365 /* try to generate op-int/lit8" instructions */
366 results[0] = x + 10;
367 results[1] = 10 - x;
368 results[2] = x * 10;
369 results[3] = x / 10;
370 results[4] = x % 10;
371 results[5] = x & 10;
372 results[6] = x | -10;
373 results[7] = x ^ -10;
374 int minInt = -2147483648;
375 int result = minInt / -1;
376 if (result != minInt) {return 1; }
377 if (results[0] != -55545) {return 2; }
378 if (results[1] != 55565) {return 3; }
379 if (results[2] != -555550) {return 4; }
380 if (results[3] != -5555) {return 5; }
381 if (results[4] != -5) {return 6; }
382 if (results[5] != 8) {return 7; }
383 if (results[6] != -1) {return 8; }
384 if (results[7] != 55563) {return 9; }
385 return 0;
386 }
387
388
389 /*
390 * Shift some data. (value=0xff00aa01, dist=8)
391 */
392 static int intShiftTest(int value, int dist) {
393 int results[] = new int[4];
394 results[0] = value << dist;
395 results[1] = value >> dist;
396 results[2] = value >>> dist;
397 results[3] = (((value << dist) >> dist) >>> dist) << dist;
398 if (results[0] != 0x00aa0100) {return 1; }
399 if (results[1] != 0xffff00aa) {return 2; }
400 if (results[2] != 0x00ff00aa) {return 3; }
401 if (results[3] != 0xaa00) {return 4; }
402 return 0;
403 }
404
405 /*
406 * We pass in the arguments and return the results so the compiler
407 * doesn't do the math for us. (x=70000000000, y=-3)
408 */
409 static int longOperTest(long x, long y) {
410 long[] results = new long[10];
411
412 /* this seems to generate "op-long" instructions */
413 results[0] = x + y;
414 results[1] = x - y;
415 results[2] = x * y;
416 results[3] = x * x;
417 results[4] = x / y;
418 results[5] = x % -y;
419 results[6] = x & y;
420 results[7] = x | y;
421 results[8] = x ^ y;
422 /* this seems to generate "op-long/2addr" instructions */
423 results[9] = x + ((((((((x + y) - y) * y) / y) % y) & y) | y) ^ y);
424 /* check this edge case while we're here (div-long/2addr) */
425 long minLong = -9223372036854775808L;
426 long negOne = -results[5];
427 long plusOne = 1;
428 long result = (((minLong + plusOne) - plusOne) / negOne) / negOne;
429 if (result != minLong) { return 1; }
430 if (results[0] != 69999999997L) { return 2; }
431 if (results[1] != 70000000003L) { return 3; }
432 if (results[2] != -210000000000L) { return 4; }
433 if (results[3] != -6833923606740729856L) { return 5; } // overflow
434 if (results[4] != -23333333333L) { return 6; }
435 if (results[5] != 1) { return 7; }
436 if (results[6] != 70000000000L) { return 8; }
437 if (results[7] != -3) { return 9; }
438 if (results[8] != -70000000003L) { return 10; }
439 if (results[9] != 70000000000L) { return 11; }
440 if (results.length != 10) { return 12; }
441 return 0;
442 }
443
444 /*
445 * Shift some data. (value=0xd5aa96deff00aa01, dist=16)
446 */
447 static long longShiftTest(long value, int dist) {
448 long results[] = new long[4];
449 results[0] = value << dist;
450 results[1] = value >> dist;
451 results[2] = value >>> dist;
452 results[3] = (((value << dist) >> dist) >>> dist) << dist;
453 if (results[0] != 0x96deff00aa010000L) { return results[0]; }
454 if (results[1] != 0xffffd5aa96deff00L) { return results[1]; }
455 if (results[2] != 0x0000d5aa96deff00L) { return results[2]; }
456 if (results[3] != 0xffff96deff000000L) { return results[3]; }
457 if (results.length != 4) { return 5; }
458
459 return results[0]; // test return-long
460 }
461
462 static int switchTest(int a) {
463 int res = 1234;
464
465 switch (a) {
466 case -1: res = 1; return res;
467 case 0: res = 2; return res;
468 case 1: /*correct*/ break;
469 case 2: res = 3; return res;
470 case 3: res = 4; return res;
471 case 4: res = 5; return res;
472 default: res = 6; return res;
473 }
474 switch (a) {
475 case 3: res = 7; return res;
476 case 4: res = 8; return res;
477 default: /*correct*/ break;
478 }
479
480 a = 0x12345678;
481
482 switch (a) {
483 case 0x12345678: /*correct*/ break;
484 case 0x12345679: res = 9; return res;
485 default: res = 1; return res;
486 }
487 switch (a) {
488 case 57: res = 10; return res;
489 case -6: res = 11; return res;
490 case 0x12345678: /*correct*/ break;
491 case 22: res = 12; return res;
492 case 3: res = 13; return res;
493 default: res = 14; return res;
494 }
495 switch (a) {
496 case -6: res = 15; return res;
497 case 3: res = 16; return res;
498 default: /*correct*/ break;
499 }
500
501 a = -5;
502 switch (a) {
503 case 12: res = 17; return res;
504 case -5: /*correct*/ break;
505 case 0: res = 18; return res;
506 default: res = 19; return res;
507 }
508
509 switch (a) {
510 default: /*correct*/ break;
511 }
512 return res;
513 }
514 /*
515 * Test the integer comparisons in various ways.
516 */
517 static int testIntCompare(int minus, int plus, int plus2, int zero) {
518 int res = 1111;
519
520 if (minus > plus)
521 return 1;
522 if (minus >= plus)
523 return 2;
524 if (plus < minus)
525 return 3;
526 if (plus <= minus)
527 return 4;
528 if (plus == minus)
529 return 5;
530 if (plus != plus2)
531 return 6;
532
533 /* try a branch-taken */
534 if (plus != minus) {
535 res = res;
536 } else {
537 return 7;
538 }
539
540 if (minus > 0)
541 return 8;
542 if (minus >= 0)
543 return 9;
544 if (plus < 0)
545 return 10;
546 if (plus <= 0)
547 return 11;
548 if (plus == 0)
549 return 12;
550 if (zero != 0)
551 return 13;
552
553 if (zero == 0) {
554 res = res;
555 } else {
556 return 14;
557 }
558 return res;
559 }
560
561 /*
562 * Test cmp-long.
563 *
564 * minus=-5, alsoMinus=0xFFFFFFFF00000009, plus=4, alsoPlus=8
565 */
566 static int testLongCompare(long minus, long alsoMinus, long plus,
567 long alsoPlus) {
568 int res = 2222;
569
570 if (minus > plus)
571 return 2;
572 if (plus < minus)
573 return 3;
574 if (plus == minus)
575 return 4;
576
577 if (plus >= plus+1)
578 return 5;
579 if (minus >= minus+1)
580 return 6;
581
582 /* try a branch-taken */
583 if (plus != minus) {
584 res = res;
585 } else {
586 return 7;
587 }
588
589 /* compare when high words are equal but low words differ */
590 if (plus > alsoPlus)
591 return 8;
592 if (alsoPlus < plus)
593 return 9;
594 if (alsoPlus == plus)
595 return 10;
596
597 /* high words are equal, low words have apparently different signs */
598 if (minus < alsoMinus) // bug!
599 return 11;
600 if (alsoMinus > minus)
601 return 12;
602 if (alsoMinus == minus)
603 return 13;
604
605 return res;
606 }
607
608 /*
609 * Test cmpl-float and cmpg-float.
610 */
611 static int testFloatCompare(float minus, float plus, float plus2,
612 float nan) {
613
614 int res = 3333;
615 if (minus > plus)
616 res = 1;
617 if (plus < minus)
618 res = 2;
619 if (plus == minus)
620 res = 3;
621 if (plus != plus2)
622 res = 4;
623
624 if (plus <= nan)
625 res = 5;
626 if (plus >= nan)
627 res = 6;
628 if (minus <= nan)
629 res = 7;
630 if (minus >= nan)
631 res = 8;
632 if (nan >= plus)
633 res = 9;
634 if (nan <= plus)
635 res = 10;
636
637 if (nan == nan)
638 res = 1212;
639
640 return res;
641 }
642
643 static int testDoubleCompare(double minus, double plus, double plus2,
644 double nan) {
645
646 int res = 4444;
647
648 if (minus > plus)
649 return 1;
650 if (plus < minus)
651 return 2;
652 if (plus == minus)
653 return 3;
654 if (plus != plus2)
655 return 4;
656
657 if (plus <= nan)
658 return 5;
659 if (plus >= nan)
660 return 6;
661 if (minus <= nan)
662 return 7;
663 if (minus >= nan)
664 return 8;
665 if (nan >= plus)
666 return 9;
667 if (nan <= plus)
668 return 10;
669
670 if (nan == nan)
671 return 11;
672 return res;
673 }
674
675 static int fibonacci(int n) {
676 if (n == 0) {
677 return 0;
678 } else if (n == 1) {
679 return 1;
680 } else {
681 return fibonacci(n - 1) + fibonacci(n - 2);
682 }
683 }
684
buzbeee9a72f62011-09-04 17:59:07 -0700685 static int throwAndCatch() {
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700686 try {
buzbeee9a72f62011-09-04 17:59:07 -0700687 throwNullPointerException();
688 return 1;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700689 } catch (NullPointerException npe) {
buzbeee9a72f62011-09-04 17:59:07 -0700690 return 0;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700691 }
buzbeee9a72f62011-09-04 17:59:07 -0700692 }
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700693
694 static int manyArgs(int a0, long a1, int a2, long a3, int a4, long a5,
695 int a6, int a7, double a8, float a9, double a10, short a11, int a12,
696 char a13, int a14, int a15, byte a16, boolean a17, int a18, int a19,
697 long a20, long a21, int a22, int a23, int a24, int a25, int a26)
698 {
699 if (a0 != 0) return 0;
700 if (a1 != 1L) return 1;
701 if (a2 != 2) return 2;
702 if (a3 != 3L) return 3;
703 if (a4 != 4) return 4;
704 if (a5 != 5L) return 5;
705 if (a6 != 6) return 6;
706 if (a7 != 7) return 7;
707 if (a8 != 8.0) return 8;
708 if (a9 != 9.0f) return 9;
709 if (a10 != 10.0) return 10;
710 if (a11 != (short)11) return 11;
711 if (a12 != 12) return 12;
712 if (a13 != (char)13) return 13;
713 if (a14 != 14) return 14;
714 if (a15 != 15) return 15;
715 if (a16 != (byte)-16) return 16;
716 if (a17 != true) return 17;
717 if (a18 != 18) return 18;
718 if (a19 != 19) return 19;
719 if (a20 != 20L) return 20;
720 if (a21 != 21L) return 21;
721 if (a22 != 22) return 22;
722 if (a23 != 23) return 23;
723 if (a24 != 24) return 24;
724 if (a25 != 25) return 25;
725 if (a26 != 26) return 26;
726 return -1;
727 }
728
729 int virtualCall(int a)
730 {
731 return a * 2;
732 }
733
734 void setFoo(int a)
735 {
736 foo_ = a;
737 }
738
739 int getFoo()
740 {
741 return foo_;
742 }
743
744 static int staticCall(int a)
745 {
746 IntMath foo = new IntMath();
747 return foo.virtualCall(a);
748 }
749
750 static int testIGetPut(int a)
751 {
752 IntMath foo = new IntMath(99);
753 IntMath foo123 = new IntMath();
754 int z = foo.getFoo();
755 z += a;
756 z += foo123.getFoo();
757 foo.setFoo(z);
758 return foo.getFoo();
759 }
760
761 public static void main(String[] args) {
buzbeef0cde542011-09-13 14:55:02 -0700762 int res;
763 long lres;
764
765 lres = divideLongByBillion(123000000000L);
766 if (lres == 123) {
767 System.out.println("divideLongByBillion PASSED");
768 } else {
769 System.out.println("divideLongByBillion FAILED: " + lres);
770 }
771 res = unopTest(38);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700772 if (res == 37) {
buzbee1da522d2011-09-04 11:22:20 -0700773 System.out.println("unopTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700774 } else {
buzbee1da522d2011-09-04 11:22:20 -0700775 System.out.println("unopTest FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700776 }
777 res = shiftTest1();
778 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700779 System.out.println("shiftTest1 PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700780 } else {
buzbee1da522d2011-09-04 11:22:20 -0700781 System.out.println("shiftTest1 FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700782 }
783 res = shiftTest2();
784 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700785 System.out.println("shiftTest2 PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700786 } else {
buzbee1da522d2011-09-04 11:22:20 -0700787 System.out.println("shiftTest2 FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700788 }
789 res = unsignedShiftTest();
790 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700791 System.out.println("unsignedShiftTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700792 } else {
buzbee1da522d2011-09-04 11:22:20 -0700793 System.out.println("unsignedShiftTest FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700794 }
795 res = convTest();
796 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700797 System.out.println("convTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700798 } else {
buzbee1da522d2011-09-04 11:22:20 -0700799 System.out.println("convTest FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700800 }
801 res = charSubTest();
802 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700803 System.out.println("charSubTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700804 } else {
buzbee1da522d2011-09-04 11:22:20 -0700805 System.out.println("charSubTest FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700806 }
807 res = intOperTest(70000, -3);
808 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700809 System.out.println("intOperTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700810 } else {
buzbee1da522d2011-09-04 11:22:20 -0700811 System.out.println("intOperTest FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700812 }
813 res = longOperTest(70000000000L, -3L);
814 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700815 System.out.println("longOperTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700816 } else {
buzbee1da522d2011-09-04 11:22:20 -0700817 System.out.println("longOperTest FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700818 }
buzbeef0cde542011-09-13 14:55:02 -0700819 lres = longShiftTest(0xd5aa96deff00aa01L, 16);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700820 if (lres == 0x96deff00aa010000L) {
buzbee1da522d2011-09-04 11:22:20 -0700821 System.out.println("longShiftTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700822 } else {
buzbee1da522d2011-09-04 11:22:20 -0700823 System.out.println("longShiftTest FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700824 }
825
826 res = switchTest(1);
827 if (res == 1234) {
buzbee1da522d2011-09-04 11:22:20 -0700828 System.out.println("switchTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700829 } else {
buzbee1da522d2011-09-04 11:22:20 -0700830 System.out.println("switchTest FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700831 }
832
833 res = testIntCompare(-5, 4, 4, 0);
834 if (res == 1111) {
buzbee1da522d2011-09-04 11:22:20 -0700835 System.out.println("testIntCompare PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700836 } else {
buzbee1da522d2011-09-04 11:22:20 -0700837 System.out.println("testIntCompare FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700838 }
839
840 res = testLongCompare(-5L, -4294967287L, 4L, 8L);
841 if (res == 2222) {
buzbee1da522d2011-09-04 11:22:20 -0700842 System.out.println("testLongCompare PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700843 } else {
buzbee1da522d2011-09-04 11:22:20 -0700844 System.out.println("testLongCompare FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700845 }
846
847 res = testFloatCompare(-5.0f, 4.0f, 4.0f, (1.0f/0.0f) / (1.0f/0.0f));
848 if (res == 3333) {
buzbee1da522d2011-09-04 11:22:20 -0700849 System.out.println("testFloatCompare PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700850 } else {
buzbee1da522d2011-09-04 11:22:20 -0700851 System.out.println("testFloatCompare FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700852 }
853
854 res = testDoubleCompare(-5.0, 4.0, 4.0, (1.0/0.0) / (1.0/0.0));
855 if (res == 4444) {
buzbee1da522d2011-09-04 11:22:20 -0700856 System.out.println("testDoubleCompare PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700857 } else {
buzbee1da522d2011-09-04 11:22:20 -0700858 System.out.println("testDoubleCompare FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700859 }
860
861 res = fibonacci(10);
862 if (res == 55) {
buzbee1da522d2011-09-04 11:22:20 -0700863 System.out.println("fibonacci PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700864 } else {
buzbee1da522d2011-09-04 11:22:20 -0700865 System.out.println("fibonacci FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700866 }
867
buzbeee9a72f62011-09-04 17:59:07 -0700868 res = throwAndCatch();
869 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700870 System.out.println("throwAndCatch PASSED");
buzbeee9a72f62011-09-04 17:59:07 -0700871 } else {
buzbee1da522d2011-09-04 11:22:20 -0700872 System.out.println("throwAndCatch FAILED: " + res);
buzbeee9a72f62011-09-04 17:59:07 -0700873 }
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700874
875 res = manyArgs(0, 1L, 2, 3L, 4, 5L, 6, 7, 8.0, 9.0f, 10.0,
876 (short)11, 12, (char)13, 14, 15, (byte)-16, true, 18,
877 19, 20L, 21L, 22, 23, 24, 25, 26);
878 if (res == -1) {
buzbee1da522d2011-09-04 11:22:20 -0700879 System.out.println("manyArgs PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700880 } else {
buzbee1da522d2011-09-04 11:22:20 -0700881 System.out.println("manyArgs FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700882 }
883
884 res = staticCall(3);
885 if (res == 6) {
buzbee1da522d2011-09-04 11:22:20 -0700886 System.out.println("virtualCall PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700887 } else {
buzbee1da522d2011-09-04 11:22:20 -0700888 System.out.println("virtualCall FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700889 }
890
891 res = testIGetPut(111);
892 if (res == 333) {
buzbee1da522d2011-09-04 11:22:20 -0700893 System.out.println("testGetPut PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700894 } else {
buzbee1da522d2011-09-04 11:22:20 -0700895 System.out.println("testGetPut FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700896 }
897
898 res = staticFieldTest(404);
899 if (res == 1404) {
buzbee1da522d2011-09-04 11:22:20 -0700900 System.out.println("staticFieldTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700901 } else {
buzbee1da522d2011-09-04 11:22:20 -0700902 System.out.println("staticFieldTest FAILED: " + res);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700903 }
buzbee1b4c8592011-08-31 10:43:51 -0700904
905 res = catchBlock(1000);
906 if (res == 1579) {
buzbee1da522d2011-09-04 11:22:20 -0700907 System.out.println("catchBlock PASSED");
buzbee1b4c8592011-08-31 10:43:51 -0700908 } else {
buzbee1da522d2011-09-04 11:22:20 -0700909 System.out.println("catchBlock FAILED: " + res);
buzbee1b4c8592011-08-31 10:43:51 -0700910 }
buzbee4a3164f2011-09-03 11:25:10 -0700911
buzbeee9a72f62011-09-04 17:59:07 -0700912 res = catchBlockNoThrow(1000);
913 if (res == 1123) {
914 System.out.println("catchBlockNoThrow PASSED");
915 } else {
916 System.out.println("catchBlockNoThrow FAILED: " + res);
917 }
918
buzbee4a3164f2011-09-03 11:25:10 -0700919 res = superTest(4141);
920 if (res == 4175) {
buzbee1da522d2011-09-04 11:22:20 -0700921 System.out.println("superTest PASSED");
buzbee4a3164f2011-09-03 11:25:10 -0700922 } else {
buzbee1da522d2011-09-04 11:22:20 -0700923 System.out.println("superTest FAILED: " + res);
buzbee4a3164f2011-09-03 11:25:10 -0700924 }
buzbee2a475e72011-09-07 17:19:17 -0700925
926 res = constStringTest(10);
927 if (res == 22) {
928 System.out.println("stringTest PASSED");
929 } else {
930 System.out.println("stringTest FAILED: " + res);
931 }
932
933 res = instanceTest(10);
934 if (res == 1352) {
935 System.out.println("instanceTest PASSED");
936 } else {
937 System.out.println("instanceTest FAILED: " + res);
938 }
buzbee4a3164f2011-09-03 11:25:10 -0700939 }
940}
941
942class IntMathBase {
943 IntMathBase() {
944 }
945
946 int tryThing() {
947 return 7;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700948 }
949}