blob: 0c91d4438dddd7bc490067f2ccc62662cb66f40e [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 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 */
Brian Carlstrom9f30b382011-08-28 22:41:38 -070016
Ian Rogersdd7bf562013-01-11 18:02:45 -080017class Main extends IntMathBase {
Brian Carlstrom9f30b382011-08-28 22:41:38 -070018
19 public static boolean mBoolean1, mBoolean2;
20 public static byte mByte1, mByte2;
21 public static char mChar1, mChar2;
22 public static short mShort1, mShort2;
23 public static int mInt1, mInt2;
24 public static float mFloat1, mFloat2;
25 public static long mLong1, mLong2;
26 public static double mDouble1, mDouble2;
27 public static volatile long mVolatileLong1, mVolatileLong2;
28
29
30 private int foo_;
31
Ian Rogersdd7bf562013-01-11 18:02:45 -080032 public Main(int stuff) {
buzbee4a3164f2011-09-03 11:25:10 -070033 super();
Brian Carlstrom9f30b382011-08-28 22:41:38 -070034 foo_ = stuff;
35 }
36
Ian Rogersdd7bf562013-01-11 18:02:45 -080037 public Main() {
buzbee4a3164f2011-09-03 11:25:10 -070038 super();
Brian Carlstrom9f30b382011-08-28 22:41:38 -070039 foo_ = 123;
40 }
41
buzbeef0cde542011-09-13 14:55:02 -070042 /* Regression test: triggered an SSA renaming bug. */
43 static long divideLongByBillion(long a) {
44 long quot;
45 long rem;
46
47 if (a >= 0) {
48 long bLong = 1000000000L;
49 quot = (a / bLong);
50 rem = (a % bLong);
51 } else {
52 /*
53 * Make the dividend positive shifting it right by 1 bit then get
54 * the quotient an remainder and correct them properly
55 */
56 long aPos = a >>> 1;
57 long bPos = 1000000000L >>> 1;
58 quot = aPos / bPos;
59 rem = aPos % bPos;
60 // double the remainder and add 1 if 'a' is odd
61 rem = (rem << 1) + (a & 1);
62 }
63 return ((rem << 32) | (quot & 0xFFFFFFFFL));
64 }
65
66
buzbee2a475e72011-09-07 17:19:17 -070067 static int instanceTest(int x) {
68 IntMathBase a = new IntMathBase();
Ian Rogersdd7bf562013-01-11 18:02:45 -080069 Main b = new Main();
buzbee2a475e72011-09-07 17:19:17 -070070
Brian Carlstrom5d40f182011-09-26 22:29:18 -070071 if (!(null instanceof IntMathBase)) {
72 x = x + 42;
73 }
74
buzbee2a475e72011-09-07 17:19:17 -070075 if (a instanceof IntMathBase) {
76 x = x * 2;
77 }
78
Ian Rogersdd7bf562013-01-11 18:02:45 -080079 if (a instanceof Main) {
buzbee2a475e72011-09-07 17:19:17 -070080 x = x + 13;
81 }
82
83 if (b instanceof IntMathBase) {
84 x = x -1;
85 }
86
Ian Rogersdd7bf562013-01-11 18:02:45 -080087 if (b instanceof Main) {
buzbee2a475e72011-09-07 17:19:17 -070088 x = x + 1333;
89 }
90 return x;
91 }
92
buzbee4a3164f2011-09-03 11:25:10 -070093 int tryThing() {
94 int val = super.tryThing();
95 return val + 10;
96 }
97
98 static int superTest(int x) {
Ian Rogersdd7bf562013-01-11 18:02:45 -080099 Main instance = new Main();
100 Main base = instance;
buzbee4a3164f2011-09-03 11:25:10 -0700101 int val1 = instance.tryThing();
102 int val2 = base.tryThing();
103 return val1 + val2 + x;
104 }
105
buzbee561227c2011-09-02 15:28:19 -0700106 static int constClassTest(int x) {
107 Class c = String.class;
108 if (c != null) {
109 return x * 2;
110 } else {
111 return x;
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700112 }
buzbee561227c2011-09-02 15:28:19 -0700113 }
114
buzbee1b4c8592011-08-31 10:43:51 -0700115 static int constStringTest(int x) {
buzbee1b4c8592011-08-31 10:43:51 -0700116 String str = "Hello World!";
buzbee2a475e72011-09-07 17:19:17 -0700117 return x + str.length();
buzbee1b4c8592011-08-31 10:43:51 -0700118 }
119
120 static void throwNullPointerException() {
121 throw new NullPointerException();
122 }
123
Ian Rogers93dd9662011-09-17 23:21:22 -0700124 static void throwImplicitNullPointerException() {
125 throw null;
126 }
127
buzbee1b4c8592011-08-31 10:43:51 -0700128 static int catchBlock(int x) {
129 try {
Ian Rogers93dd9662011-09-17 23:21:22 -0700130 if (x == 1000) {
131 x += 123;
132 throwNullPointerException();
133 } else {
134 x += 321;
135 throwImplicitNullPointerException();
136 }
buzbee1b4c8592011-08-31 10:43:51 -0700137 } catch (NullPointerException npe) {
138 x += 456;
139 }
140 return x;
141 }
142
buzbeee9a72f62011-09-04 17:59:07 -0700143 static int catchBlockNoThrow(int x) {
144 try {
145 x += 123;
146 } catch (NullPointerException npe) {
147 x += 456;
148 }
149 return x;
150 }
151
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700152 static int staticFieldTest(int x) {
153 mBoolean1 = true;
154 mBoolean2 = false;
155 mByte1 = 127;
156 mByte2 = -128;
157 mChar1 = 32767;
158 mChar2 = 65535;
159 mShort1 = 32767;
160 mShort2 = -32768;
161 mInt1 = 65537;
162 mInt2 = -65537;
163 mFloat1 = 3.1415f;
164 mFloat2 = -1.0f / 0.0f; // -inf
165 mLong1 = 1234605616436508552L; // 0x1122334455667788
166 mLong2 = -1234605616436508552L;
167 mDouble1 = 3.1415926535;
168 mDouble2 = 1.0 / 0.0; // +inf
169 mVolatileLong1 = mLong1 - 1;
170 mVolatileLong2 = mLong2 + 1;
171
172 if (!mBoolean1) { return 10; }
173 if (mBoolean2) { return 11; }
174 if (mByte1 != 127) { return 12; }
175 if (mByte2 != -128) { return 13; }
176 if (mChar1 != 32767) { return 14; }
177 if (mChar2 != 65535) { return 15; }
178 if (mShort1 != 32767) { return 16; }
179 if (mShort2 != -32768) { return 17; }
180 if (mInt1 != 65537) { return 18; }
181 if (mInt2 != -65537) { return 19; }
182 if (!(mFloat1 > 3.141f && mFloat1 < 3.142f)) { return 20; }
183 if (mFloat2 >= mFloat1) { return 21; }
184 if (mLong1 != 1234605616436508552L) { return 22; }
185 if (mLong2 != -1234605616436508552L) { return 23; }
186 if (!(mDouble1 > 3.141592653 && mDouble1 < 3.141592654)) { return 24; }
187 if (mDouble2 <= mDouble1) { return 25; }
188 if (mVolatileLong1 != 1234605616436508551L) { return 26; }
189 if (mVolatileLong2 != -1234605616436508551L) { return 27; }
190
191 return 1000 + x;
192 }
193
194 /*
195 * Try to cause some unary operations.
196 */
197 static int unopTest(int x) {
198 x = -x;
199 x ^= 0xffffffff;
200 return x;
201 }
202
203 static int shiftTest1() {
204 final int[] mBytes = {
205 0x11, 0x22, 0x33, 0x44, 0x88, 0x99, 0xaa, 0xbb
206 };
207 long l;
208 int i1, i2;
209
210 if (mBytes[0] != 0x11) return 20;
211 if (mBytes[1] != 0x22) return 21;
212 if (mBytes[2] != 0x33) return 22;
213 if (mBytes[3] != 0x44) return 23;
214 if (mBytes[4] != 0x88) return 24;
215 if (mBytes[5] != 0x99) return 25;
216 if (mBytes[6] != 0xaa) return 26;
217 if (mBytes[7] != 0xbb) return 27;
218
219 i1 = mBytes[0] | mBytes[1] << 8 | mBytes[2] << 16 | mBytes[3] << 24;
220 i2 = mBytes[4] | mBytes[5] << 8 | mBytes[6] << 16 | mBytes[7] << 24;
221 l = i1 | ((long)i2 << 32);
222
223 if (i1 != 0x44332211) { return 0x80000000 | i1; }
224 if (i2 != 0xbbaa9988) { return 2; }
225 if (l != 0xbbaa998844332211L) { return 3; }
226
227 l = (long)mBytes[0]
228 | (long)mBytes[1] << 8
229 | (long)mBytes[2] << 16
230 | (long)mBytes[3] << 24
231 | (long)mBytes[4] << 32
232 | (long)mBytes[5] << 40
233 | (long)mBytes[6] << 48
234 | (long)mBytes[7] << 56;
235
236 if (l != 0xbbaa998844332211L) { return 4; }
237 return 0;
238 }
239
240 static int shiftTest2() {
241
242 long a = 0x11;
243 long b = 0x22;
244 long c = 0x33;
245 long d = 0x44;
246 long e = 0x55;
247 long f = 0x66;
248 long g = 0x77;
249 long h = 0x88;
250
251 long result = ((a << 56) | (b << 48) | (c << 40) | (d << 32) |
252 (e << 24) | (f << 16) | (g << 8) | h);
253
254 if (result != 0x1122334455667788L) { return 1; }
255 return 0;
256 }
257
258 static int unsignedShiftTest() {
259 byte b = -4;
260 short s = -4;
261 char c = 0xfffc;
262 int i = -4;
263
264 b >>>= 4;
265 s >>>= 4;
266 c >>>= 4;
267 i >>>= 4;
268
269 if ((int) b != -1) { return 1; }
270 if ((int) s != -1) { return 2; }
271 if ((int) c != 0x0fff) { return 3; }
272 if (i != 268435455) { return 4; }
273 return 0;
274 }
275
276 static int convTest() {
277
278 float f;
279 double d;
280 int i;
281 long l;
282
283 /* int --> long */
284 i = 7654;
285 l = (long) i;
286 if (l != 7654L) { return 1; }
287
288 i = -7654;
289 l = (long) i;
290 if (l != -7654L) { return 2; }
291
292 /* long --> int (with truncation) */
293 l = 5678956789L;
294 i = (int) l;
295 if (i != 1383989493) { return 3; }
296
297 l = -5678956789L;
298 i = (int) l;
299 if (i != -1383989493) { return 4; }
Ian Rogersef6a7762013-12-19 17:58:05 -0800300
301 /* long --> double */
302 l = 0x7FFFFFFFL;
303 d = (double) l;
304 if (Double.doubleToRawLongBits(d) != 0x41dfffffffc00000L) { return 5; }
305
306 l = 0xFFFFFFFFL;
307 d = (double) l;
308 if (Double.doubleToRawLongBits(d) != 0x41efffffffe00000L) { return 6; }
309
310 l = 0x7FFFFFFFFFFFFFFFL;
311 d = (double) l;
312 if (Double.doubleToRawLongBits(d) != 0x43e0000000000000L) { return 7; }
313
314 l = 0xFFFFFFFFFFFFFFFFL;
315 d = (double) l;
316 if (Double.doubleToRawLongBits(d) != 0xbff0000000000000L) { return 8; }
317
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700318 return 0;
319 }
320
321 static int charSubTest() {
322
323 char char1 = 0x00e9;
324 char char2 = 0xffff;
325 int i;
326
327 /* chars are unsigned-expanded to ints before subtraction */
328 i = char1 - char2;
329 if (i != 0xffff00ea) { return 1; }
330 return 0;
331 }
332
333 /*
334 * We pass in the arguments and return the results so the compiler
335 * doesn't do the math for us. (x=70000, y=-3)
336 */
337 static int intOperTest(int x, int y) {
338 int[] results = new int[10];
339
340 /* this seems to generate "op-int" instructions */
341 results[0] = x + y;
342 results[1] = x - y;
343 results[2] = x * y;
344 results[3] = x * x;
345 results[4] = x / y;
346 results[5] = x % -y;
347 results[6] = x & y;
348 results[7] = x | y;
349 results[8] = x ^ y;
350
351 /* this seems to generate "op-int/2addr" instructions */
352 results[9] = x + ((((((((x + y) - y) * y) / y) % y) & y) | y) ^ y);
353
354 /* check this edge case while we're here (div-int/2addr) */
355 int minInt = -2147483648;
356 int negOne = -results[5];
357 int plusOne = 1;
358 int result = (((minInt + plusOne) - plusOne) / negOne) / negOne;
TDYa127f8641ce2012-04-02 06:40:40 -0700359 int shouldBeZero = minInt % negOne;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700360
361 if (result != minInt) { return 1;};
362 if (results[0] != 69997) { return 2;};
363 if (results[1] != 70003) { return 3;};
364 if (results[2] != -210000) { return 4;};
365 if (results[3] != 605032704) { return 5;};
366 if (results[4] != -23333) { return 6;};
367 if (results[5] != 1) { return 7;};
368 if (results[6] != 70000) { return 8;};
369 if (results[7] != -3) { return 9;};
370 if (results[8] != -70003) { return 10;};
371 if (results[9] != 70000) { return 11;};
TDYa127f8641ce2012-04-02 06:40:40 -0700372 if (shouldBeZero != 0) { return 12;};
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700373
374 return 0;
375 }
376
377 /*
378 * More operations, this time with 16-bit constants. (x=77777)
379 */
380 static int lit16Test(int x) {
381
Douglas Leungf9a627f2015-04-08 15:53:58 -0700382 int[] results = new int[10];
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700383
384 /* try to generate op-int/lit16" instructions */
385 results[0] = x + 1000;
386 results[1] = 1000 - x;
387 results[2] = x * 1000;
388 results[3] = x / 1000;
389 results[4] = x % 1000;
390 results[5] = x & 1000;
391 results[6] = x | -1000;
392 results[7] = x ^ -1000;
Douglas Leungf9a627f2015-04-08 15:53:58 -0700393 /* use an 16-bit constant that has its MSB (bit-15) set */
394 results[8] = x / 32769;
395 results[9] = x / -32769;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700396
397 if (results[0] != 78777) { return 1; }
398 if (results[1] != -76777) { return 2; }
399 if (results[2] != 77777000) { return 3; }
400 if (results[3] != 77) { return 4; }
401 if (results[4] != 777) { return 5; }
402 if (results[5] != 960) { return 6; }
403 if (results[6] != -39) { return 7; }
404 if (results[7] != -76855) { return 8; }
Douglas Leungf9a627f2015-04-08 15:53:58 -0700405 if (results[8] != 2) { return 9; }
406 if (results[9] != -2) { return 10; }
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700407 return 0;
408 }
409
410 /*
411 * More operations, this time with 8-bit constants. (x=-55555)
412 */
413 static int lit8Test(int x) {
414
Andreas Gampe151ab8d2015-08-14 23:01:49 +0000415 int[] results = new int[9];
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700416
417 /* try to generate op-int/lit8" instructions */
418 results[0] = x + 10;
419 results[1] = 10 - x;
420 results[2] = x * 10;
421 results[3] = x / 10;
422 results[4] = x % 10;
423 results[5] = x & 10;
424 results[6] = x | -10;
425 results[7] = x ^ -10;
Andreas Gampe151ab8d2015-08-14 23:01:49 +0000426 results[8] = x * -256;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700427 int minInt = -2147483648;
428 int result = minInt / -1;
429 if (result != minInt) {return 1; }
430 if (results[0] != -55545) {return 2; }
431 if (results[1] != 55565) {return 3; }
432 if (results[2] != -555550) {return 4; }
433 if (results[3] != -5555) {return 5; }
434 if (results[4] != -5) {return 6; }
435 if (results[5] != 8) {return 7; }
436 if (results[6] != -1) {return 8; }
437 if (results[7] != 55563) {return 9; }
Andreas Gampe151ab8d2015-08-14 23:01:49 +0000438 if (results[8] != 14222080) {return 10; }
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700439 return 0;
440 }
441
442
443 /*
444 * Shift some data. (value=0xff00aa01, dist=8)
445 */
446 static int intShiftTest(int value, int dist) {
447 int results[] = new int[4];
448 results[0] = value << dist;
449 results[1] = value >> dist;
450 results[2] = value >>> dist;
451 results[3] = (((value << dist) >> dist) >>> dist) << dist;
452 if (results[0] != 0x00aa0100) {return 1; }
453 if (results[1] != 0xffff00aa) {return 2; }
454 if (results[2] != 0x00ff00aa) {return 3; }
455 if (results[3] != 0xaa00) {return 4; }
456 return 0;
457 }
458
459 /*
460 * We pass in the arguments and return the results so the compiler
461 * doesn't do the math for us. (x=70000000000, y=-3)
462 */
463 static int longOperTest(long x, long y) {
464 long[] results = new long[10];
465
466 /* this seems to generate "op-long" instructions */
467 results[0] = x + y;
468 results[1] = x - y;
469 results[2] = x * y;
470 results[3] = x * x;
471 results[4] = x / y;
472 results[5] = x % -y;
473 results[6] = x & y;
474 results[7] = x | y;
475 results[8] = x ^ y;
476 /* this seems to generate "op-long/2addr" instructions */
477 results[9] = x + ((((((((x + y) - y) * y) / y) % y) & y) | y) ^ y);
478 /* check this edge case while we're here (div-long/2addr) */
479 long minLong = -9223372036854775808L;
480 long negOne = -results[5];
481 long plusOne = 1;
482 long result = (((minLong + plusOne) - plusOne) / negOne) / negOne;
483 if (result != minLong) { return 1; }
484 if (results[0] != 69999999997L) { return 2; }
485 if (results[1] != 70000000003L) { return 3; }
486 if (results[2] != -210000000000L) { return 4; }
487 if (results[3] != -6833923606740729856L) { return 5; } // overflow
488 if (results[4] != -23333333333L) { return 6; }
489 if (results[5] != 1) { return 7; }
490 if (results[6] != 70000000000L) { return 8; }
491 if (results[7] != -3) { return 9; }
492 if (results[8] != -70000000003L) { return 10; }
493 if (results[9] != 70000000000L) { return 11; }
494 if (results.length != 10) { return 12; }
495 return 0;
496 }
497
498 /*
499 * Shift some data. (value=0xd5aa96deff00aa01, dist=16)
500 */
501 static long longShiftTest(long value, int dist) {
502 long results[] = new long[4];
503 results[0] = value << dist;
504 results[1] = value >> dist;
505 results[2] = value >>> dist;
506 results[3] = (((value << dist) >> dist) >>> dist) << dist;
507 if (results[0] != 0x96deff00aa010000L) { return results[0]; }
508 if (results[1] != 0xffffd5aa96deff00L) { return results[1]; }
509 if (results[2] != 0x0000d5aa96deff00L) { return results[2]; }
510 if (results[3] != 0xffff96deff000000L) { return results[3]; }
511 if (results.length != 4) { return 5; }
512
513 return results[0]; // test return-long
514 }
515
516 static int switchTest(int a) {
517 int res = 1234;
518
519 switch (a) {
520 case -1: res = 1; return res;
521 case 0: res = 2; return res;
522 case 1: /*correct*/ break;
523 case 2: res = 3; return res;
524 case 3: res = 4; return res;
525 case 4: res = 5; return res;
526 default: res = 6; return res;
527 }
528 switch (a) {
529 case 3: res = 7; return res;
530 case 4: res = 8; return res;
531 default: /*correct*/ break;
532 }
533
534 a = 0x12345678;
535
536 switch (a) {
537 case 0x12345678: /*correct*/ break;
538 case 0x12345679: res = 9; return res;
539 default: res = 1; return res;
540 }
541 switch (a) {
542 case 57: res = 10; return res;
543 case -6: res = 11; return res;
544 case 0x12345678: /*correct*/ break;
545 case 22: res = 12; return res;
546 case 3: res = 13; return res;
547 default: res = 14; return res;
548 }
549 switch (a) {
550 case -6: res = 15; return res;
551 case 3: res = 16; return res;
552 default: /*correct*/ break;
553 }
554
555 a = -5;
556 switch (a) {
557 case 12: res = 17; return res;
558 case -5: /*correct*/ break;
559 case 0: res = 18; return res;
560 default: res = 19; return res;
561 }
562
563 switch (a) {
564 default: /*correct*/ break;
565 }
566 return res;
567 }
568 /*
569 * Test the integer comparisons in various ways.
570 */
571 static int testIntCompare(int minus, int plus, int plus2, int zero) {
572 int res = 1111;
573
574 if (minus > plus)
575 return 1;
576 if (minus >= plus)
577 return 2;
578 if (plus < minus)
579 return 3;
580 if (plus <= minus)
581 return 4;
582 if (plus == minus)
583 return 5;
584 if (plus != plus2)
585 return 6;
586
587 /* try a branch-taken */
588 if (plus != minus) {
589 res = res;
590 } else {
591 return 7;
592 }
593
594 if (minus > 0)
595 return 8;
596 if (minus >= 0)
597 return 9;
598 if (plus < 0)
599 return 10;
600 if (plus <= 0)
601 return 11;
602 if (plus == 0)
603 return 12;
604 if (zero != 0)
605 return 13;
606
607 if (zero == 0) {
608 res = res;
609 } else {
610 return 14;
611 }
612 return res;
613 }
614
615 /*
616 * Test cmp-long.
617 *
618 * minus=-5, alsoMinus=0xFFFFFFFF00000009, plus=4, alsoPlus=8
619 */
620 static int testLongCompare(long minus, long alsoMinus, long plus,
621 long alsoPlus) {
622 int res = 2222;
623
624 if (minus > plus)
625 return 2;
626 if (plus < minus)
627 return 3;
628 if (plus == minus)
629 return 4;
630
631 if (plus >= plus+1)
632 return 5;
633 if (minus >= minus+1)
634 return 6;
635
636 /* try a branch-taken */
637 if (plus != minus) {
638 res = res;
639 } else {
640 return 7;
641 }
642
643 /* compare when high words are equal but low words differ */
644 if (plus > alsoPlus)
645 return 8;
646 if (alsoPlus < plus)
647 return 9;
648 if (alsoPlus == plus)
649 return 10;
650
651 /* high words are equal, low words have apparently different signs */
652 if (minus < alsoMinus) // bug!
653 return 11;
654 if (alsoMinus > minus)
655 return 12;
656 if (alsoMinus == minus)
657 return 13;
658
659 return res;
660 }
661
662 /*
663 * Test cmpl-float and cmpg-float.
664 */
665 static int testFloatCompare(float minus, float plus, float plus2,
666 float nan) {
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700667 if (minus > plus)
jeffhao644d5312012-05-03 19:04:49 -0700668 return 1;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700669 if (plus < minus)
jeffhao644d5312012-05-03 19:04:49 -0700670 return 2;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700671 if (plus == minus)
jeffhao644d5312012-05-03 19:04:49 -0700672 return 3;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700673 if (plus != plus2)
jeffhao644d5312012-05-03 19:04:49 -0700674 return 4;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700675
676 if (plus <= nan)
jeffhao644d5312012-05-03 19:04:49 -0700677 return 5;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700678 if (plus >= nan)
jeffhao644d5312012-05-03 19:04:49 -0700679 return 6;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700680 if (minus <= nan)
jeffhao644d5312012-05-03 19:04:49 -0700681 return 7;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700682 if (minus >= nan)
jeffhao644d5312012-05-03 19:04:49 -0700683 return 8;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700684 if (nan >= plus)
jeffhao644d5312012-05-03 19:04:49 -0700685 return 9;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700686 if (nan <= plus)
jeffhao644d5312012-05-03 19:04:49 -0700687 return 10;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700688
689 if (nan == nan)
jeffhao644d5312012-05-03 19:04:49 -0700690 return 11;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700691
jeffhao644d5312012-05-03 19:04:49 -0700692 return 3333;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700693 }
694
695 static int testDoubleCompare(double minus, double plus, double plus2,
696 double nan) {
697
698 int res = 4444;
699
700 if (minus > plus)
701 return 1;
702 if (plus < minus)
703 return 2;
704 if (plus == minus)
705 return 3;
706 if (plus != plus2)
707 return 4;
708
709 if (plus <= nan)
710 return 5;
711 if (plus >= nan)
712 return 6;
713 if (minus <= nan)
714 return 7;
715 if (minus >= nan)
716 return 8;
717 if (nan >= plus)
718 return 9;
719 if (nan <= plus)
720 return 10;
721
722 if (nan == nan)
723 return 11;
724 return res;
725 }
726
727 static int fibonacci(int n) {
728 if (n == 0) {
729 return 0;
730 } else if (n == 1) {
731 return 1;
732 } else {
733 return fibonacci(n - 1) + fibonacci(n - 2);
734 }
735 }
736
buzbeee9a72f62011-09-04 17:59:07 -0700737 static int throwAndCatch() {
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700738 try {
739 throwNullPointerException();
740 return 1;
741 } catch (NullPointerException npe) {
742 return 0;
743 }
buzbeee9a72f62011-09-04 17:59:07 -0700744 }
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700745
746 static int manyArgs(int a0, long a1, int a2, long a3, int a4, long a5,
747 int a6, int a7, double a8, float a9, double a10, short a11, int a12,
748 char a13, int a14, int a15, byte a16, boolean a17, int a18, int a19,
749 long a20, long a21, int a22, int a23, int a24, int a25, int a26)
750 {
751 if (a0 != 0) return 0;
752 if (a1 != 1L) return 1;
753 if (a2 != 2) return 2;
754 if (a3 != 3L) return 3;
755 if (a4 != 4) return 4;
756 if (a5 != 5L) return 5;
757 if (a6 != 6) return 6;
758 if (a7 != 7) return 7;
759 if (a8 != 8.0) return 8;
760 if (a9 != 9.0f) return 9;
761 if (a10 != 10.0) return 10;
762 if (a11 != (short)11) return 11;
763 if (a12 != 12) return 12;
764 if (a13 != (char)13) return 13;
765 if (a14 != 14) return 14;
766 if (a15 != 15) return 15;
767 if (a16 != (byte)-16) return 16;
768 if (a17 != true) return 17;
769 if (a18 != 18) return 18;
770 if (a19 != 19) return 19;
771 if (a20 != 20L) return 20;
772 if (a21 != 21L) return 21;
773 if (a22 != 22) return 22;
774 if (a23 != 23) return 23;
775 if (a24 != 24) return 24;
776 if (a25 != 25) return 25;
777 if (a26 != 26) return 26;
778 return -1;
779 }
780
781 int virtualCall(int a)
782 {
783 return a * 2;
784 }
785
786 void setFoo(int a)
787 {
788 foo_ = a;
789 }
790
791 int getFoo()
792 {
793 return foo_;
794 }
795
796 static int staticCall(int a)
797 {
Ian Rogersdd7bf562013-01-11 18:02:45 -0800798 Main foo = new Main();
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700799 return foo.virtualCall(a);
800 }
801
802 static int testIGetPut(int a)
803 {
Ian Rogersdd7bf562013-01-11 18:02:45 -0800804 Main foo = new Main(99);
805 Main foo123 = new Main();
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700806 int z = foo.getFoo();
807 z += a;
808 z += foo123.getFoo();
809 foo.setFoo(z);
810 return foo.getFoo();
811 }
812
Ian Rogersff1ed472011-09-20 13:46:24 -0700813 static int throwClassCast(Object o) {
814 return ((Integer)o).intValue();
815 }
816
817 static int testClassCast() {
818 int res = 0;
819 try {
820 res += throwClassCast(Integer.valueOf(123));
821 } catch(ClassCastException e) {
822 res += 456;
823 }
824 try {
825 res += throwClassCast(new Short((short)321));
826 } catch(ClassCastException e) {
827 res += 765;
828 }
829 return res;
830 }
831
Ian Rogerse51a5112011-09-23 14:16:35 -0700832 static void throwArrayStoreException(Object[] array, Object element) {
833 array[0] = element;
834 }
835
836 static int testArrayStoreException() {
837 int res=0;
838 Object[] array = new Number[2];
839 try {
840 throwArrayStoreException(array, null);
841 res += 1;
842 } catch(ArrayStoreException e) {
843 res += 2;
844 }
845 try {
846 throwArrayStoreException(array, Integer.valueOf(1));
847 res += 10;
848 } catch(ArrayStoreException e) {
849 res += 20;
850 }
851 try {
852 throwArrayStoreException(array, "hello MTV-44");
853 res += 100;
854 } catch(ArrayStoreException e) {
855 res += 200;
856 }
857 return res;
858 }
859
Ian Rogers932746a2011-09-22 18:57:50 -0700860 static long recursion_count_;
861 static void throwStackOverflow(long l) {
862 recursion_count_++;
863 throwStackOverflow(recursion_count_);
864 }
865
866 static long testStackOverflow() {
867 try {
868 throwStackOverflow(0);
869 if (recursion_count_ != 0) {
870 return recursion_count_;
871 } else {
872 return -1;
873 }
874 } catch(StackOverflowError soe) {
875 return 0;
876 }
877 }
878
Ian Rogersb886da82011-09-23 16:27:54 -0700879 static int testArrayAllocation() {
880 int res = 0;
881 try {
882 int[] x = new int[-1];
883 res += 1;
884 } catch (NegativeArraySizeException e) {
885 res += 2;
886 }
887 try {
888 int[] x = new int [1];
889 res += 10;
890 } catch (Throwable e) {
891 res += 20;
892 }
893 return res;
894 }
895
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700896 public static void main(String[] args) {
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700897 boolean failure = false;
buzbeef0cde542011-09-13 14:55:02 -0700898 int res;
899 long lres;
900
901 lres = divideLongByBillion(123000000000L);
902 if (lres == 123) {
903 System.out.println("divideLongByBillion PASSED");
904 } else {
905 System.out.println("divideLongByBillion FAILED: " + lres);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700906 failure = true;
buzbeef0cde542011-09-13 14:55:02 -0700907 }
908 res = unopTest(38);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700909 if (res == 37) {
buzbee1da522d2011-09-04 11:22:20 -0700910 System.out.println("unopTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700911 } else {
buzbee1da522d2011-09-04 11:22:20 -0700912 System.out.println("unopTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700913 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700914 }
915 res = shiftTest1();
916 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700917 System.out.println("shiftTest1 PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700918 } else {
buzbee1da522d2011-09-04 11:22:20 -0700919 System.out.println("shiftTest1 FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700920 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700921 }
922 res = shiftTest2();
923 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700924 System.out.println("shiftTest2 PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700925 } else {
buzbee1da522d2011-09-04 11:22:20 -0700926 System.out.println("shiftTest2 FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700927 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700928 }
929 res = unsignedShiftTest();
930 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700931 System.out.println("unsignedShiftTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700932 } else {
buzbee1da522d2011-09-04 11:22:20 -0700933 System.out.println("unsignedShiftTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700934 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700935 }
936 res = convTest();
937 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700938 System.out.println("convTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700939 } else {
buzbee1da522d2011-09-04 11:22:20 -0700940 System.out.println("convTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700941 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700942 }
943 res = charSubTest();
944 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700945 System.out.println("charSubTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700946 } else {
buzbee1da522d2011-09-04 11:22:20 -0700947 System.out.println("charSubTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700948 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700949 }
950 res = intOperTest(70000, -3);
951 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700952 System.out.println("intOperTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700953 } else {
buzbee1da522d2011-09-04 11:22:20 -0700954 System.out.println("intOperTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700955 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700956 }
Brian Carlstrom25c33252011-09-18 15:58:35 -0700957 res = lit16Test(77777);
958 if (res == 0) {
959 System.out.println("lit16Test PASSED");
960 } else {
961 System.out.println("lit16Test FAILED: " + res);
962 failure = true;
963 }
964 res = lit8Test(-55555);
965 if (res == 0) {
966 System.out.println("lit8Test PASSED");
967 } else {
968 System.out.println("lit8Test FAILED: " + res);
969 failure = true;
970 }
971 res = intShiftTest(0xff00aa01, 8);
972 if (res == 0) {
973 System.out.println("intShiftTest PASSED");
974 } else {
975 System.out.println("intShiftTest FAILED: " + res);
976 failure = true;
977 }
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700978 res = longOperTest(70000000000L, -3L);
979 if (res == 0) {
buzbee1da522d2011-09-04 11:22:20 -0700980 System.out.println("longOperTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700981 } else {
buzbee1da522d2011-09-04 11:22:20 -0700982 System.out.println("longOperTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700983 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700984 }
buzbeef0cde542011-09-13 14:55:02 -0700985 lres = longShiftTest(0xd5aa96deff00aa01L, 16);
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700986 if (lres == 0x96deff00aa010000L) {
buzbee1da522d2011-09-04 11:22:20 -0700987 System.out.println("longShiftTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700988 } else {
Dmitry Petrochenkof71f9502014-06-10 02:45:42 +0700989 System.out.println("longShiftTest FAILED: " + lres);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700990 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700991 }
992
993 res = switchTest(1);
994 if (res == 1234) {
buzbee1da522d2011-09-04 11:22:20 -0700995 System.out.println("switchTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700996 } else {
buzbee1da522d2011-09-04 11:22:20 -0700997 System.out.println("switchTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -0700998 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700999 }
1000
1001 res = testIntCompare(-5, 4, 4, 0);
1002 if (res == 1111) {
buzbee1da522d2011-09-04 11:22:20 -07001003 System.out.println("testIntCompare PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001004 } else {
buzbee1da522d2011-09-04 11:22:20 -07001005 System.out.println("testIntCompare FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001006 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001007 }
1008
1009 res = testLongCompare(-5L, -4294967287L, 4L, 8L);
1010 if (res == 2222) {
buzbee1da522d2011-09-04 11:22:20 -07001011 System.out.println("testLongCompare PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001012 } else {
buzbee1da522d2011-09-04 11:22:20 -07001013 System.out.println("testLongCompare FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001014 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001015 }
1016
1017 res = testFloatCompare(-5.0f, 4.0f, 4.0f, (1.0f/0.0f) / (1.0f/0.0f));
1018 if (res == 3333) {
buzbee1da522d2011-09-04 11:22:20 -07001019 System.out.println("testFloatCompare PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001020 } else {
buzbee1da522d2011-09-04 11:22:20 -07001021 System.out.println("testFloatCompare FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001022 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001023 }
1024
1025 res = testDoubleCompare(-5.0, 4.0, 4.0, (1.0/0.0) / (1.0/0.0));
1026 if (res == 4444) {
buzbee1da522d2011-09-04 11:22:20 -07001027 System.out.println("testDoubleCompare PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001028 } else {
buzbee1da522d2011-09-04 11:22:20 -07001029 System.out.println("testDoubleCompare FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001030 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001031 }
1032
1033 res = fibonacci(10);
1034 if (res == 55) {
buzbee1da522d2011-09-04 11:22:20 -07001035 System.out.println("fibonacci PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001036 } else {
buzbee1da522d2011-09-04 11:22:20 -07001037 System.out.println("fibonacci FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001038 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001039 }
1040
buzbeee9a72f62011-09-04 17:59:07 -07001041 res = throwAndCatch();
1042 if (res == 0) {
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001043 System.out.println("throwAndCatch PASSED");
buzbeee9a72f62011-09-04 17:59:07 -07001044 } else {
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001045 System.out.println("throwAndCatch FAILED: " + res);
1046 failure = true;
buzbeee9a72f62011-09-04 17:59:07 -07001047 }
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001048
Ian Rogersff1ed472011-09-20 13:46:24 -07001049 res = testClassCast();
1050 if (res == 888) {
1051 System.out.println("testClassCast PASSED");
1052 } else {
1053 System.out.println("testClassCast FAILED: " + res);
1054 failure = true;
1055 }
1056
Ian Rogerse51a5112011-09-23 14:16:35 -07001057 res = testArrayStoreException();
1058 if (res == 211) {
1059 System.out.println("testArrayStore PASSED");
1060 } else {
1061 System.out.println("testArrayStore FAILED: " + res);
1062 failure = true;
1063 }
1064
Ian Rogers932746a2011-09-22 18:57:50 -07001065 lres= testStackOverflow();
1066 if (lres == 0) {
1067 System.out.println("testStackOverflow PASSED");
1068 } else {
1069 System.out.println("testStackOverflow FAILED: " + lres);
1070 failure = true;
1071 }
1072
Ian Rogersb886da82011-09-23 16:27:54 -07001073 res = testArrayAllocation();
1074 if (res == 12) {
1075 System.out.println("testArrayAllocation PASSED");
1076 } else {
1077 System.out.println("testArrayAllocation FAILED: " + res);
1078 failure = true;
1079 }
1080
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001081 res = manyArgs(0, 1L, 2, 3L, 4, 5L, 6, 7, 8.0, 9.0f, 10.0,
1082 (short)11, 12, (char)13, 14, 15, (byte)-16, true, 18,
1083 19, 20L, 21L, 22, 23, 24, 25, 26);
1084 if (res == -1) {
buzbee1da522d2011-09-04 11:22:20 -07001085 System.out.println("manyArgs PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001086 } else {
buzbee1da522d2011-09-04 11:22:20 -07001087 System.out.println("manyArgs FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001088 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001089 }
1090
1091 res = staticCall(3);
1092 if (res == 6) {
buzbee1da522d2011-09-04 11:22:20 -07001093 System.out.println("virtualCall PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001094 } else {
buzbee1da522d2011-09-04 11:22:20 -07001095 System.out.println("virtualCall FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001096 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001097 }
1098
1099 res = testIGetPut(111);
1100 if (res == 333) {
buzbee1da522d2011-09-04 11:22:20 -07001101 System.out.println("testGetPut PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001102 } else {
buzbee1da522d2011-09-04 11:22:20 -07001103 System.out.println("testGetPut FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001104 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001105 }
1106
1107 res = staticFieldTest(404);
1108 if (res == 1404) {
buzbee1da522d2011-09-04 11:22:20 -07001109 System.out.println("staticFieldTest PASSED");
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001110 } else {
buzbee1da522d2011-09-04 11:22:20 -07001111 System.out.println("staticFieldTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001112 failure = true;
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001113 }
buzbee1b4c8592011-08-31 10:43:51 -07001114
1115 res = catchBlock(1000);
1116 if (res == 1579) {
Brian Carlstrom25c33252011-09-18 15:58:35 -07001117 System.out.println("catchBlock(1000) PASSED");
buzbee1b4c8592011-08-31 10:43:51 -07001118 } else {
Brian Carlstrom25c33252011-09-18 15:58:35 -07001119 System.out.println("catchBlock(1000) FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001120 failure = true;
buzbee1b4c8592011-08-31 10:43:51 -07001121 }
Brian Carlstrom25c33252011-09-18 15:58:35 -07001122 res = catchBlock(7000);
1123 if (res == 7777) {
1124 System.out.println("catchBlock(7000) PASSED");
1125 } else {
1126 System.out.println("catchBlock(7000) FAILED: " + res);
1127 failure = true;
1128 }
buzbeee9a72f62011-09-04 17:59:07 -07001129 res = catchBlockNoThrow(1000);
1130 if (res == 1123) {
1131 System.out.println("catchBlockNoThrow PASSED");
1132 } else {
1133 System.out.println("catchBlockNoThrow FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001134 failure = true;
buzbeee9a72f62011-09-04 17:59:07 -07001135 }
1136
buzbee4a3164f2011-09-03 11:25:10 -07001137 res = superTest(4141);
1138 if (res == 4175) {
buzbee1da522d2011-09-04 11:22:20 -07001139 System.out.println("superTest PASSED");
buzbee4a3164f2011-09-03 11:25:10 -07001140 } else {
buzbee1da522d2011-09-04 11:22:20 -07001141 System.out.println("superTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001142 failure = true;
buzbee4a3164f2011-09-03 11:25:10 -07001143 }
buzbee2a475e72011-09-07 17:19:17 -07001144
Brian Carlstrom25c33252011-09-18 15:58:35 -07001145 res = constClassTest(1111);
1146 if (res == 2222) {
1147 System.out.println("constClassTest PASSED");
1148 } else {
1149 System.out.println("constClassTest FAILED: " + res);
1150 failure = true;
1151 }
1152
buzbee2a475e72011-09-07 17:19:17 -07001153 res = constStringTest(10);
1154 if (res == 22) {
Brian Carlstrom25c33252011-09-18 15:58:35 -07001155 System.out.println("constStringTest PASSED");
buzbee2a475e72011-09-07 17:19:17 -07001156 } else {
Brian Carlstrom25c33252011-09-18 15:58:35 -07001157 System.out.println("constStringTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001158 failure = true;
buzbee2a475e72011-09-07 17:19:17 -07001159 }
1160
1161 res = instanceTest(10);
Brian Carlstrom5d40f182011-09-26 22:29:18 -07001162 if (res == 1436) {
buzbee2a475e72011-09-07 17:19:17 -07001163 System.out.println("instanceTest PASSED");
1164 } else {
1165 System.out.println("instanceTest FAILED: " + res);
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001166 failure = true;
buzbee2a475e72011-09-07 17:19:17 -07001167 }
Brian Carlstrombbf1e412011-09-18 14:14:51 -07001168
1169 System.exit(failure ? 1 : 0);
buzbee4a3164f2011-09-03 11:25:10 -07001170 }
1171}
1172
1173class IntMathBase {
1174 IntMathBase() {
1175 }
1176
1177 int tryThing() {
1178 return 7;
Brian Carlstrom9f30b382011-08-28 22:41:38 -07001179 }
1180}