Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 3 | class IntMath extends IntMathBase { |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 4 | |
| 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) { |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 19 | super(); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 20 | foo_ = stuff; |
| 21 | } |
| 22 | |
| 23 | public IntMath() { |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 24 | super(); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 25 | foo_ = 123; |
| 26 | } |
| 27 | |
buzbee | f0cde54 | 2011-09-13 14:55:02 -0700 | [diff] [blame] | 28 | /* 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 | |
buzbee | 2a475e7 | 2011-09-07 17:19:17 -0700 | [diff] [blame] | 53 | 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 | |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 75 | 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 | |
buzbee | 561227c | 2011-09-02 15:28:19 -0700 | [diff] [blame] | 88 | 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 | |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 97 | static int constStringTest(int x) { |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 98 | String str = "Hello World!"; |
buzbee | 2a475e7 | 2011-09-07 17:19:17 -0700 | [diff] [blame] | 99 | return x + str.length(); |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | static void throwNullPointerException() { |
| 103 | throw new NullPointerException(); |
| 104 | } |
| 105 | |
Ian Rogers | 93dd966 | 2011-09-17 23:21:22 -0700 | [diff] [blame^] | 106 | static void throwImplicitNullPointerException() { |
| 107 | throw null; |
| 108 | } |
| 109 | |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 110 | static int catchBlock(int x) { |
| 111 | try { |
Ian Rogers | 93dd966 | 2011-09-17 23:21:22 -0700 | [diff] [blame^] | 112 | if (x == 1000) { |
| 113 | x += 123; |
| 114 | throwNullPointerException(); |
| 115 | } else { |
| 116 | x += 321; |
| 117 | throwImplicitNullPointerException(); |
| 118 | } |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 119 | } catch (NullPointerException npe) { |
| 120 | x += 456; |
| 121 | } |
| 122 | return x; |
| 123 | } |
| 124 | |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 125 | static int catchBlockNoThrow(int x) { |
| 126 | try { |
| 127 | x += 123; |
| 128 | } catch (NullPointerException npe) { |
| 129 | x += 456; |
| 130 | } |
| 131 | return x; |
| 132 | } |
| 133 | |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 134 | static int staticFieldTest(int x) { |
| 135 | mBoolean1 = true; |
| 136 | mBoolean2 = false; |
| 137 | mByte1 = 127; |
| 138 | mByte2 = -128; |
| 139 | mChar1 = 32767; |
| 140 | mChar2 = 65535; |
| 141 | mShort1 = 32767; |
| 142 | mShort2 = -32768; |
| 143 | mInt1 = 65537; |
| 144 | mInt2 = -65537; |
| 145 | mFloat1 = 3.1415f; |
| 146 | mFloat2 = -1.0f / 0.0f; // -inf |
| 147 | mLong1 = 1234605616436508552L; // 0x1122334455667788 |
| 148 | mLong2 = -1234605616436508552L; |
| 149 | mDouble1 = 3.1415926535; |
| 150 | mDouble2 = 1.0 / 0.0; // +inf |
| 151 | mVolatileLong1 = mLong1 - 1; |
| 152 | mVolatileLong2 = mLong2 + 1; |
| 153 | |
| 154 | if (!mBoolean1) { return 10; } |
| 155 | if (mBoolean2) { return 11; } |
| 156 | if (mByte1 != 127) { return 12; } |
| 157 | if (mByte2 != -128) { return 13; } |
| 158 | if (mChar1 != 32767) { return 14; } |
| 159 | if (mChar2 != 65535) { return 15; } |
| 160 | if (mShort1 != 32767) { return 16; } |
| 161 | if (mShort2 != -32768) { return 17; } |
| 162 | if (mInt1 != 65537) { return 18; } |
| 163 | if (mInt2 != -65537) { return 19; } |
| 164 | if (!(mFloat1 > 3.141f && mFloat1 < 3.142f)) { return 20; } |
| 165 | if (mFloat2 >= mFloat1) { return 21; } |
| 166 | if (mLong1 != 1234605616436508552L) { return 22; } |
| 167 | if (mLong2 != -1234605616436508552L) { return 23; } |
| 168 | if (!(mDouble1 > 3.141592653 && mDouble1 < 3.141592654)) { return 24; } |
| 169 | if (mDouble2 <= mDouble1) { return 25; } |
| 170 | if (mVolatileLong1 != 1234605616436508551L) { return 26; } |
| 171 | if (mVolatileLong2 != -1234605616436508551L) { return 27; } |
| 172 | |
| 173 | return 1000 + x; |
| 174 | } |
| 175 | |
| 176 | /* |
| 177 | * Try to cause some unary operations. |
| 178 | */ |
| 179 | static int unopTest(int x) { |
| 180 | x = -x; |
| 181 | x ^= 0xffffffff; |
| 182 | return x; |
| 183 | } |
| 184 | |
| 185 | static int shiftTest1() { |
| 186 | final int[] mBytes = { |
| 187 | 0x11, 0x22, 0x33, 0x44, 0x88, 0x99, 0xaa, 0xbb |
| 188 | }; |
| 189 | long l; |
| 190 | int i1, i2; |
| 191 | |
| 192 | if (mBytes[0] != 0x11) return 20; |
| 193 | if (mBytes[1] != 0x22) return 21; |
| 194 | if (mBytes[2] != 0x33) return 22; |
| 195 | if (mBytes[3] != 0x44) return 23; |
| 196 | if (mBytes[4] != 0x88) return 24; |
| 197 | if (mBytes[5] != 0x99) return 25; |
| 198 | if (mBytes[6] != 0xaa) return 26; |
| 199 | if (mBytes[7] != 0xbb) return 27; |
| 200 | |
| 201 | i1 = mBytes[0] | mBytes[1] << 8 | mBytes[2] << 16 | mBytes[3] << 24; |
| 202 | i2 = mBytes[4] | mBytes[5] << 8 | mBytes[6] << 16 | mBytes[7] << 24; |
| 203 | l = i1 | ((long)i2 << 32); |
| 204 | |
| 205 | if (i1 != 0x44332211) { return 0x80000000 | i1; } |
| 206 | if (i2 != 0xbbaa9988) { return 2; } |
| 207 | if (l != 0xbbaa998844332211L) { return 3; } |
| 208 | |
| 209 | l = (long)mBytes[0] |
| 210 | | (long)mBytes[1] << 8 |
| 211 | | (long)mBytes[2] << 16 |
| 212 | | (long)mBytes[3] << 24 |
| 213 | | (long)mBytes[4] << 32 |
| 214 | | (long)mBytes[5] << 40 |
| 215 | | (long)mBytes[6] << 48 |
| 216 | | (long)mBytes[7] << 56; |
| 217 | |
| 218 | if (l != 0xbbaa998844332211L) { return 4; } |
| 219 | return 0; |
| 220 | } |
| 221 | |
| 222 | static int shiftTest2() { |
| 223 | |
| 224 | long a = 0x11; |
| 225 | long b = 0x22; |
| 226 | long c = 0x33; |
| 227 | long d = 0x44; |
| 228 | long e = 0x55; |
| 229 | long f = 0x66; |
| 230 | long g = 0x77; |
| 231 | long h = 0x88; |
| 232 | |
| 233 | long result = ((a << 56) | (b << 48) | (c << 40) | (d << 32) | |
| 234 | (e << 24) | (f << 16) | (g << 8) | h); |
| 235 | |
| 236 | if (result != 0x1122334455667788L) { return 1; } |
| 237 | return 0; |
| 238 | } |
| 239 | |
| 240 | static int unsignedShiftTest() { |
| 241 | byte b = -4; |
| 242 | short s = -4; |
| 243 | char c = 0xfffc; |
| 244 | int i = -4; |
| 245 | |
| 246 | b >>>= 4; |
| 247 | s >>>= 4; |
| 248 | c >>>= 4; |
| 249 | i >>>= 4; |
| 250 | |
| 251 | if ((int) b != -1) { return 1; } |
| 252 | if ((int) s != -1) { return 2; } |
| 253 | if ((int) c != 0x0fff) { return 3; } |
| 254 | if (i != 268435455) { return 4; } |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | static int convTest() { |
| 259 | |
| 260 | float f; |
| 261 | double d; |
| 262 | int i; |
| 263 | long l; |
| 264 | |
| 265 | /* int --> long */ |
| 266 | i = 7654; |
| 267 | l = (long) i; |
| 268 | if (l != 7654L) { return 1; } |
| 269 | |
| 270 | i = -7654; |
| 271 | l = (long) i; |
| 272 | if (l != -7654L) { return 2; } |
| 273 | |
| 274 | /* long --> int (with truncation) */ |
| 275 | l = 5678956789L; |
| 276 | i = (int) l; |
| 277 | if (i != 1383989493) { return 3; } |
| 278 | |
| 279 | l = -5678956789L; |
| 280 | i = (int) l; |
| 281 | if (i != -1383989493) { return 4; } |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | static int charSubTest() { |
| 286 | |
| 287 | char char1 = 0x00e9; |
| 288 | char char2 = 0xffff; |
| 289 | int i; |
| 290 | |
| 291 | /* chars are unsigned-expanded to ints before subtraction */ |
| 292 | i = char1 - char2; |
| 293 | if (i != 0xffff00ea) { return 1; } |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | /* |
| 298 | * We pass in the arguments and return the results so the compiler |
| 299 | * doesn't do the math for us. (x=70000, y=-3) |
| 300 | */ |
| 301 | static int intOperTest(int x, int y) { |
| 302 | int[] results = new int[10]; |
| 303 | |
| 304 | /* this seems to generate "op-int" instructions */ |
| 305 | results[0] = x + y; |
| 306 | results[1] = x - y; |
| 307 | results[2] = x * y; |
| 308 | results[3] = x * x; |
| 309 | results[4] = x / y; |
| 310 | results[5] = x % -y; |
| 311 | results[6] = x & y; |
| 312 | results[7] = x | y; |
| 313 | results[8] = x ^ y; |
| 314 | |
| 315 | /* this seems to generate "op-int/2addr" instructions */ |
| 316 | results[9] = x + ((((((((x + y) - y) * y) / y) % y) & y) | y) ^ y); |
| 317 | |
| 318 | /* check this edge case while we're here (div-int/2addr) */ |
| 319 | int minInt = -2147483648; |
| 320 | int negOne = -results[5]; |
| 321 | int plusOne = 1; |
| 322 | int result = (((minInt + plusOne) - plusOne) / negOne) / negOne; |
| 323 | |
| 324 | if (result != minInt) { return 1;}; |
| 325 | if (results[0] != 69997) { return 2;}; |
| 326 | if (results[1] != 70003) { return 3;}; |
| 327 | if (results[2] != -210000) { return 4;}; |
| 328 | if (results[3] != 605032704) { return 5;}; |
| 329 | if (results[4] != -23333) { return 6;}; |
| 330 | if (results[5] != 1) { return 7;}; |
| 331 | if (results[6] != 70000) { return 8;}; |
| 332 | if (results[7] != -3) { return 9;}; |
| 333 | if (results[8] != -70003) { return 10;}; |
| 334 | if (results[9] != 70000) { return 11;}; |
| 335 | |
| 336 | return 0; |
| 337 | } |
| 338 | |
| 339 | /* |
| 340 | * More operations, this time with 16-bit constants. (x=77777) |
| 341 | */ |
| 342 | static int lit16Test(int x) { |
| 343 | |
| 344 | int[] results = new int[8]; |
| 345 | |
| 346 | /* try to generate op-int/lit16" instructions */ |
| 347 | results[0] = x + 1000; |
| 348 | results[1] = 1000 - x; |
| 349 | results[2] = x * 1000; |
| 350 | results[3] = x / 1000; |
| 351 | results[4] = x % 1000; |
| 352 | results[5] = x & 1000; |
| 353 | results[6] = x | -1000; |
| 354 | results[7] = x ^ -1000; |
| 355 | |
| 356 | if (results[0] != 78777) { return 1; } |
| 357 | if (results[1] != -76777) { return 2; } |
| 358 | if (results[2] != 77777000) { return 3; } |
| 359 | if (results[3] != 77) { return 4; } |
| 360 | if (results[4] != 777) { return 5; } |
| 361 | if (results[5] != 960) { return 6; } |
| 362 | if (results[6] != -39) { return 7; } |
| 363 | if (results[7] != -76855) { return 8; } |
| 364 | return 0; |
| 365 | } |
| 366 | |
| 367 | /* |
| 368 | * More operations, this time with 8-bit constants. (x=-55555) |
| 369 | */ |
| 370 | static int lit8Test(int x) { |
| 371 | |
| 372 | int[] results = new int[8]; |
| 373 | |
| 374 | /* try to generate op-int/lit8" instructions */ |
| 375 | results[0] = x + 10; |
| 376 | results[1] = 10 - x; |
| 377 | results[2] = x * 10; |
| 378 | results[3] = x / 10; |
| 379 | results[4] = x % 10; |
| 380 | results[5] = x & 10; |
| 381 | results[6] = x | -10; |
| 382 | results[7] = x ^ -10; |
| 383 | int minInt = -2147483648; |
| 384 | int result = minInt / -1; |
| 385 | if (result != minInt) {return 1; } |
| 386 | if (results[0] != -55545) {return 2; } |
| 387 | if (results[1] != 55565) {return 3; } |
| 388 | if (results[2] != -555550) {return 4; } |
| 389 | if (results[3] != -5555) {return 5; } |
| 390 | if (results[4] != -5) {return 6; } |
| 391 | if (results[5] != 8) {return 7; } |
| 392 | if (results[6] != -1) {return 8; } |
| 393 | if (results[7] != 55563) {return 9; } |
| 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | |
| 398 | /* |
| 399 | * Shift some data. (value=0xff00aa01, dist=8) |
| 400 | */ |
| 401 | static int intShiftTest(int value, int dist) { |
| 402 | int results[] = new int[4]; |
| 403 | results[0] = value << dist; |
| 404 | results[1] = value >> dist; |
| 405 | results[2] = value >>> dist; |
| 406 | results[3] = (((value << dist) >> dist) >>> dist) << dist; |
| 407 | if (results[0] != 0x00aa0100) {return 1; } |
| 408 | if (results[1] != 0xffff00aa) {return 2; } |
| 409 | if (results[2] != 0x00ff00aa) {return 3; } |
| 410 | if (results[3] != 0xaa00) {return 4; } |
| 411 | return 0; |
| 412 | } |
| 413 | |
| 414 | /* |
| 415 | * We pass in the arguments and return the results so the compiler |
| 416 | * doesn't do the math for us. (x=70000000000, y=-3) |
| 417 | */ |
| 418 | static int longOperTest(long x, long y) { |
| 419 | long[] results = new long[10]; |
| 420 | |
| 421 | /* this seems to generate "op-long" instructions */ |
| 422 | results[0] = x + y; |
| 423 | results[1] = x - y; |
| 424 | results[2] = x * y; |
| 425 | results[3] = x * x; |
| 426 | results[4] = x / y; |
| 427 | results[5] = x % -y; |
| 428 | results[6] = x & y; |
| 429 | results[7] = x | y; |
| 430 | results[8] = x ^ y; |
| 431 | /* this seems to generate "op-long/2addr" instructions */ |
| 432 | results[9] = x + ((((((((x + y) - y) * y) / y) % y) & y) | y) ^ y); |
| 433 | /* check this edge case while we're here (div-long/2addr) */ |
| 434 | long minLong = -9223372036854775808L; |
| 435 | long negOne = -results[5]; |
| 436 | long plusOne = 1; |
| 437 | long result = (((minLong + plusOne) - plusOne) / negOne) / negOne; |
| 438 | if (result != minLong) { return 1; } |
| 439 | if (results[0] != 69999999997L) { return 2; } |
| 440 | if (results[1] != 70000000003L) { return 3; } |
| 441 | if (results[2] != -210000000000L) { return 4; } |
| 442 | if (results[3] != -6833923606740729856L) { return 5; } // overflow |
| 443 | if (results[4] != -23333333333L) { return 6; } |
| 444 | if (results[5] != 1) { return 7; } |
| 445 | if (results[6] != 70000000000L) { return 8; } |
| 446 | if (results[7] != -3) { return 9; } |
| 447 | if (results[8] != -70000000003L) { return 10; } |
| 448 | if (results[9] != 70000000000L) { return 11; } |
| 449 | if (results.length != 10) { return 12; } |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | /* |
| 454 | * Shift some data. (value=0xd5aa96deff00aa01, dist=16) |
| 455 | */ |
| 456 | static long longShiftTest(long value, int dist) { |
| 457 | long results[] = new long[4]; |
| 458 | results[0] = value << dist; |
| 459 | results[1] = value >> dist; |
| 460 | results[2] = value >>> dist; |
| 461 | results[3] = (((value << dist) >> dist) >>> dist) << dist; |
| 462 | if (results[0] != 0x96deff00aa010000L) { return results[0]; } |
| 463 | if (results[1] != 0xffffd5aa96deff00L) { return results[1]; } |
| 464 | if (results[2] != 0x0000d5aa96deff00L) { return results[2]; } |
| 465 | if (results[3] != 0xffff96deff000000L) { return results[3]; } |
| 466 | if (results.length != 4) { return 5; } |
| 467 | |
| 468 | return results[0]; // test return-long |
| 469 | } |
| 470 | |
| 471 | static int switchTest(int a) { |
| 472 | int res = 1234; |
| 473 | |
| 474 | switch (a) { |
| 475 | case -1: res = 1; return res; |
| 476 | case 0: res = 2; return res; |
| 477 | case 1: /*correct*/ break; |
| 478 | case 2: res = 3; return res; |
| 479 | case 3: res = 4; return res; |
| 480 | case 4: res = 5; return res; |
| 481 | default: res = 6; return res; |
| 482 | } |
| 483 | switch (a) { |
| 484 | case 3: res = 7; return res; |
| 485 | case 4: res = 8; return res; |
| 486 | default: /*correct*/ break; |
| 487 | } |
| 488 | |
| 489 | a = 0x12345678; |
| 490 | |
| 491 | switch (a) { |
| 492 | case 0x12345678: /*correct*/ break; |
| 493 | case 0x12345679: res = 9; return res; |
| 494 | default: res = 1; return res; |
| 495 | } |
| 496 | switch (a) { |
| 497 | case 57: res = 10; return res; |
| 498 | case -6: res = 11; return res; |
| 499 | case 0x12345678: /*correct*/ break; |
| 500 | case 22: res = 12; return res; |
| 501 | case 3: res = 13; return res; |
| 502 | default: res = 14; return res; |
| 503 | } |
| 504 | switch (a) { |
| 505 | case -6: res = 15; return res; |
| 506 | case 3: res = 16; return res; |
| 507 | default: /*correct*/ break; |
| 508 | } |
| 509 | |
| 510 | a = -5; |
| 511 | switch (a) { |
| 512 | case 12: res = 17; return res; |
| 513 | case -5: /*correct*/ break; |
| 514 | case 0: res = 18; return res; |
| 515 | default: res = 19; return res; |
| 516 | } |
| 517 | |
| 518 | switch (a) { |
| 519 | default: /*correct*/ break; |
| 520 | } |
| 521 | return res; |
| 522 | } |
| 523 | /* |
| 524 | * Test the integer comparisons in various ways. |
| 525 | */ |
| 526 | static int testIntCompare(int minus, int plus, int plus2, int zero) { |
| 527 | int res = 1111; |
| 528 | |
| 529 | if (minus > plus) |
| 530 | return 1; |
| 531 | if (minus >= plus) |
| 532 | return 2; |
| 533 | if (plus < minus) |
| 534 | return 3; |
| 535 | if (plus <= minus) |
| 536 | return 4; |
| 537 | if (plus == minus) |
| 538 | return 5; |
| 539 | if (plus != plus2) |
| 540 | return 6; |
| 541 | |
| 542 | /* try a branch-taken */ |
| 543 | if (plus != minus) { |
| 544 | res = res; |
| 545 | } else { |
| 546 | return 7; |
| 547 | } |
| 548 | |
| 549 | if (minus > 0) |
| 550 | return 8; |
| 551 | if (minus >= 0) |
| 552 | return 9; |
| 553 | if (plus < 0) |
| 554 | return 10; |
| 555 | if (plus <= 0) |
| 556 | return 11; |
| 557 | if (plus == 0) |
| 558 | return 12; |
| 559 | if (zero != 0) |
| 560 | return 13; |
| 561 | |
| 562 | if (zero == 0) { |
| 563 | res = res; |
| 564 | } else { |
| 565 | return 14; |
| 566 | } |
| 567 | return res; |
| 568 | } |
| 569 | |
| 570 | /* |
| 571 | * Test cmp-long. |
| 572 | * |
| 573 | * minus=-5, alsoMinus=0xFFFFFFFF00000009, plus=4, alsoPlus=8 |
| 574 | */ |
| 575 | static int testLongCompare(long minus, long alsoMinus, long plus, |
| 576 | long alsoPlus) { |
| 577 | int res = 2222; |
| 578 | |
| 579 | if (minus > plus) |
| 580 | return 2; |
| 581 | if (plus < minus) |
| 582 | return 3; |
| 583 | if (plus == minus) |
| 584 | return 4; |
| 585 | |
| 586 | if (plus >= plus+1) |
| 587 | return 5; |
| 588 | if (minus >= minus+1) |
| 589 | return 6; |
| 590 | |
| 591 | /* try a branch-taken */ |
| 592 | if (plus != minus) { |
| 593 | res = res; |
| 594 | } else { |
| 595 | return 7; |
| 596 | } |
| 597 | |
| 598 | /* compare when high words are equal but low words differ */ |
| 599 | if (plus > alsoPlus) |
| 600 | return 8; |
| 601 | if (alsoPlus < plus) |
| 602 | return 9; |
| 603 | if (alsoPlus == plus) |
| 604 | return 10; |
| 605 | |
| 606 | /* high words are equal, low words have apparently different signs */ |
| 607 | if (minus < alsoMinus) // bug! |
| 608 | return 11; |
| 609 | if (alsoMinus > minus) |
| 610 | return 12; |
| 611 | if (alsoMinus == minus) |
| 612 | return 13; |
| 613 | |
| 614 | return res; |
| 615 | } |
| 616 | |
| 617 | /* |
| 618 | * Test cmpl-float and cmpg-float. |
| 619 | */ |
| 620 | static int testFloatCompare(float minus, float plus, float plus2, |
| 621 | float nan) { |
| 622 | |
| 623 | int res = 3333; |
| 624 | if (minus > plus) |
| 625 | res = 1; |
| 626 | if (plus < minus) |
| 627 | res = 2; |
| 628 | if (plus == minus) |
| 629 | res = 3; |
| 630 | if (plus != plus2) |
| 631 | res = 4; |
| 632 | |
| 633 | if (plus <= nan) |
| 634 | res = 5; |
| 635 | if (plus >= nan) |
| 636 | res = 6; |
| 637 | if (minus <= nan) |
| 638 | res = 7; |
| 639 | if (minus >= nan) |
| 640 | res = 8; |
| 641 | if (nan >= plus) |
| 642 | res = 9; |
| 643 | if (nan <= plus) |
| 644 | res = 10; |
| 645 | |
| 646 | if (nan == nan) |
| 647 | res = 1212; |
| 648 | |
| 649 | return res; |
| 650 | } |
| 651 | |
| 652 | static int testDoubleCompare(double minus, double plus, double plus2, |
| 653 | double nan) { |
| 654 | |
| 655 | int res = 4444; |
| 656 | |
| 657 | if (minus > plus) |
| 658 | return 1; |
| 659 | if (plus < minus) |
| 660 | return 2; |
| 661 | if (plus == minus) |
| 662 | return 3; |
| 663 | if (plus != plus2) |
| 664 | return 4; |
| 665 | |
| 666 | if (plus <= nan) |
| 667 | return 5; |
| 668 | if (plus >= nan) |
| 669 | return 6; |
| 670 | if (minus <= nan) |
| 671 | return 7; |
| 672 | if (minus >= nan) |
| 673 | return 8; |
| 674 | if (nan >= plus) |
| 675 | return 9; |
| 676 | if (nan <= plus) |
| 677 | return 10; |
| 678 | |
| 679 | if (nan == nan) |
| 680 | return 11; |
| 681 | return res; |
| 682 | } |
| 683 | |
| 684 | static int fibonacci(int n) { |
| 685 | if (n == 0) { |
| 686 | return 0; |
| 687 | } else if (n == 1) { |
| 688 | return 1; |
| 689 | } else { |
| 690 | return fibonacci(n - 1) + fibonacci(n - 2); |
| 691 | } |
| 692 | } |
| 693 | |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 694 | static int throwAndCatch() { |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 695 | try { |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 696 | throwNullPointerException(); |
| 697 | return 1; |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 698 | } catch (NullPointerException npe) { |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 699 | return 0; |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 700 | } |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 701 | } |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 702 | |
| 703 | static int manyArgs(int a0, long a1, int a2, long a3, int a4, long a5, |
| 704 | int a6, int a7, double a8, float a9, double a10, short a11, int a12, |
| 705 | char a13, int a14, int a15, byte a16, boolean a17, int a18, int a19, |
| 706 | long a20, long a21, int a22, int a23, int a24, int a25, int a26) |
| 707 | { |
| 708 | if (a0 != 0) return 0; |
| 709 | if (a1 != 1L) return 1; |
| 710 | if (a2 != 2) return 2; |
| 711 | if (a3 != 3L) return 3; |
| 712 | if (a4 != 4) return 4; |
| 713 | if (a5 != 5L) return 5; |
| 714 | if (a6 != 6) return 6; |
| 715 | if (a7 != 7) return 7; |
| 716 | if (a8 != 8.0) return 8; |
| 717 | if (a9 != 9.0f) return 9; |
| 718 | if (a10 != 10.0) return 10; |
| 719 | if (a11 != (short)11) return 11; |
| 720 | if (a12 != 12) return 12; |
| 721 | if (a13 != (char)13) return 13; |
| 722 | if (a14 != 14) return 14; |
| 723 | if (a15 != 15) return 15; |
| 724 | if (a16 != (byte)-16) return 16; |
| 725 | if (a17 != true) return 17; |
| 726 | if (a18 != 18) return 18; |
| 727 | if (a19 != 19) return 19; |
| 728 | if (a20 != 20L) return 20; |
| 729 | if (a21 != 21L) return 21; |
| 730 | if (a22 != 22) return 22; |
| 731 | if (a23 != 23) return 23; |
| 732 | if (a24 != 24) return 24; |
| 733 | if (a25 != 25) return 25; |
| 734 | if (a26 != 26) return 26; |
| 735 | return -1; |
| 736 | } |
| 737 | |
| 738 | int virtualCall(int a) |
| 739 | { |
| 740 | return a * 2; |
| 741 | } |
| 742 | |
| 743 | void setFoo(int a) |
| 744 | { |
| 745 | foo_ = a; |
| 746 | } |
| 747 | |
| 748 | int getFoo() |
| 749 | { |
| 750 | return foo_; |
| 751 | } |
| 752 | |
| 753 | static int staticCall(int a) |
| 754 | { |
| 755 | IntMath foo = new IntMath(); |
| 756 | return foo.virtualCall(a); |
| 757 | } |
| 758 | |
| 759 | static int testIGetPut(int a) |
| 760 | { |
| 761 | IntMath foo = new IntMath(99); |
| 762 | IntMath foo123 = new IntMath(); |
| 763 | int z = foo.getFoo(); |
| 764 | z += a; |
| 765 | z += foo123.getFoo(); |
| 766 | foo.setFoo(z); |
| 767 | return foo.getFoo(); |
| 768 | } |
| 769 | |
| 770 | public static void main(String[] args) { |
buzbee | f0cde54 | 2011-09-13 14:55:02 -0700 | [diff] [blame] | 771 | int res; |
| 772 | long lres; |
| 773 | |
| 774 | lres = divideLongByBillion(123000000000L); |
| 775 | if (lres == 123) { |
| 776 | System.out.println("divideLongByBillion PASSED"); |
| 777 | } else { |
| 778 | System.out.println("divideLongByBillion FAILED: " + lres); |
| 779 | } |
| 780 | res = unopTest(38); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 781 | if (res == 37) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 782 | System.out.println("unopTest PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 783 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 784 | System.out.println("unopTest FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 785 | } |
| 786 | res = shiftTest1(); |
| 787 | if (res == 0) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 788 | System.out.println("shiftTest1 PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 789 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 790 | System.out.println("shiftTest1 FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 791 | } |
| 792 | res = shiftTest2(); |
| 793 | if (res == 0) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 794 | System.out.println("shiftTest2 PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 795 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 796 | System.out.println("shiftTest2 FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 797 | } |
| 798 | res = unsignedShiftTest(); |
| 799 | if (res == 0) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 800 | System.out.println("unsignedShiftTest PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 801 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 802 | System.out.println("unsignedShiftTest FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 803 | } |
| 804 | res = convTest(); |
| 805 | if (res == 0) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 806 | System.out.println("convTest PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 807 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 808 | System.out.println("convTest FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 809 | } |
| 810 | res = charSubTest(); |
| 811 | if (res == 0) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 812 | System.out.println("charSubTest PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 813 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 814 | System.out.println("charSubTest FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 815 | } |
| 816 | res = intOperTest(70000, -3); |
| 817 | if (res == 0) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 818 | System.out.println("intOperTest PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 819 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 820 | System.out.println("intOperTest FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 821 | } |
| 822 | res = longOperTest(70000000000L, -3L); |
| 823 | if (res == 0) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 824 | System.out.println("longOperTest PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 825 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 826 | System.out.println("longOperTest FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 827 | } |
buzbee | f0cde54 | 2011-09-13 14:55:02 -0700 | [diff] [blame] | 828 | lres = longShiftTest(0xd5aa96deff00aa01L, 16); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 829 | if (lres == 0x96deff00aa010000L) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 830 | System.out.println("longShiftTest PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 831 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 832 | System.out.println("longShiftTest FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | res = switchTest(1); |
| 836 | if (res == 1234) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 837 | System.out.println("switchTest PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 838 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 839 | System.out.println("switchTest FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 840 | } |
| 841 | |
| 842 | res = testIntCompare(-5, 4, 4, 0); |
| 843 | if (res == 1111) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 844 | System.out.println("testIntCompare PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 845 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 846 | System.out.println("testIntCompare FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | res = testLongCompare(-5L, -4294967287L, 4L, 8L); |
| 850 | if (res == 2222) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 851 | System.out.println("testLongCompare PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 852 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 853 | System.out.println("testLongCompare FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | res = testFloatCompare(-5.0f, 4.0f, 4.0f, (1.0f/0.0f) / (1.0f/0.0f)); |
| 857 | if (res == 3333) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 858 | System.out.println("testFloatCompare PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 859 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 860 | System.out.println("testFloatCompare FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 861 | } |
| 862 | |
| 863 | res = testDoubleCompare(-5.0, 4.0, 4.0, (1.0/0.0) / (1.0/0.0)); |
| 864 | if (res == 4444) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 865 | System.out.println("testDoubleCompare PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 866 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 867 | System.out.println("testDoubleCompare FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 868 | } |
| 869 | |
| 870 | res = fibonacci(10); |
| 871 | if (res == 55) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 872 | System.out.println("fibonacci PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 873 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 874 | System.out.println("fibonacci FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 875 | } |
| 876 | |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 877 | res = throwAndCatch(); |
| 878 | if (res == 0) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 879 | System.out.println("throwAndCatch PASSED"); |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 880 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 881 | System.out.println("throwAndCatch FAILED: " + res); |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 882 | } |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 883 | |
| 884 | res = manyArgs(0, 1L, 2, 3L, 4, 5L, 6, 7, 8.0, 9.0f, 10.0, |
| 885 | (short)11, 12, (char)13, 14, 15, (byte)-16, true, 18, |
| 886 | 19, 20L, 21L, 22, 23, 24, 25, 26); |
| 887 | if (res == -1) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 888 | System.out.println("manyArgs PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 889 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 890 | System.out.println("manyArgs FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | res = staticCall(3); |
| 894 | if (res == 6) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 895 | System.out.println("virtualCall PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 896 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 897 | System.out.println("virtualCall FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | res = testIGetPut(111); |
| 901 | if (res == 333) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 902 | System.out.println("testGetPut PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 903 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 904 | System.out.println("testGetPut FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 905 | } |
| 906 | |
| 907 | res = staticFieldTest(404); |
| 908 | if (res == 1404) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 909 | System.out.println("staticFieldTest PASSED"); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 910 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 911 | System.out.println("staticFieldTest FAILED: " + res); |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 912 | } |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 913 | |
| 914 | res = catchBlock(1000); |
| 915 | if (res == 1579) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 916 | System.out.println("catchBlock PASSED"); |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 917 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 918 | System.out.println("catchBlock FAILED: " + res); |
buzbee | 1b4c859 | 2011-08-31 10:43:51 -0700 | [diff] [blame] | 919 | } |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 920 | |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 921 | res = catchBlockNoThrow(1000); |
| 922 | if (res == 1123) { |
| 923 | System.out.println("catchBlockNoThrow PASSED"); |
| 924 | } else { |
| 925 | System.out.println("catchBlockNoThrow FAILED: " + res); |
| 926 | } |
| 927 | |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 928 | res = superTest(4141); |
| 929 | if (res == 4175) { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 930 | System.out.println("superTest PASSED"); |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 931 | } else { |
buzbee | 1da522d | 2011-09-04 11:22:20 -0700 | [diff] [blame] | 932 | System.out.println("superTest FAILED: " + res); |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 933 | } |
buzbee | 2a475e7 | 2011-09-07 17:19:17 -0700 | [diff] [blame] | 934 | |
| 935 | res = constStringTest(10); |
| 936 | if (res == 22) { |
| 937 | System.out.println("stringTest PASSED"); |
| 938 | } else { |
| 939 | System.out.println("stringTest FAILED: " + res); |
| 940 | } |
| 941 | |
| 942 | res = instanceTest(10); |
| 943 | if (res == 1352) { |
| 944 | System.out.println("instanceTest PASSED"); |
| 945 | } else { |
| 946 | System.out.println("instanceTest FAILED: " + res); |
| 947 | } |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 948 | } |
| 949 | } |
| 950 | |
| 951 | class IntMathBase { |
| 952 | IntMathBase() { |
| 953 | } |
| 954 | |
| 955 | int tryThing() { |
| 956 | return 7; |
Brian Carlstrom | 9f30b38 | 2011-08-28 22:41:38 -0700 | [diff] [blame] | 957 | } |
| 958 | } |