1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import java.lang.reflect.Method; 18 19 public class Main { 20 21 public static boolean doThrow = false; 22 23 /// CHECK-START: void Main.$opt$noinline$testReplaceInputWithItself(int) intrinsics_recognition (after) 24 /// CHECK-DAG: <<ArgX:i\d+>> ParameterValue 25 /// CHECK-DAG: <<Method:[ij]\d+>> CurrentMethod 26 /// CHECK-DAG: <<Zero:i\d+>> IntConstant 0 27 /// CHECK-DAG: <<Cmp:i\d+>> InvokeStaticOrDirect [<<ArgX>>,<<Zero>>,<<Method>>] intrinsic:IntegerCompare 28 /// CHECK-DAG: GreaterThanOrEqual [<<Cmp>>,<<Zero>>] 29 30 /// CHECK-START: void Main.$opt$noinline$testReplaceInputWithItself(int) instruction_simplifier (after) 31 /// CHECK-DAG: <<ArgX:i\d+>> ParameterValue 32 /// CHECK-DAG: <<Zero:i\d+>> IntConstant 0 33 /// CHECK-DAG: GreaterThanOrEqual [<<ArgX>>,<<Zero>>] 34 35 public static void $opt$noinline$testReplaceInputWithItself(int x) { 36 if (doThrow) { throw new Error(); } 37 38 // The instruction simplifier first replaces Integer.compare(x, 0) with Compare HIR 39 // and then merges the Compare into the GreaterThanOrEqual. This is a regression 40 // test that to check that it is allowed to replace the second input of the 41 // GreaterThanOrEqual, i.e. <<Zero>>, with the very same instruction. 42 if (Integer.compare(x, 0) < 0) { 43 System.out.println("OOOPS"); 44 } 45 } 46 47 /// CHECK-START: int Main.compareBooleans(boolean, boolean) select_generator (after) 48 /// CHECK-NOT: Phi 49 50 /// CHECK-START: int Main.compareBooleans(boolean, boolean) instruction_simplifier$after_bce (after) 51 /// CHECK: <<ArgX:z\d+>> ParameterValue 52 /// CHECK: <<ArgY:z\d+>> ParameterValue 53 /// CHECK-DAG: <<Result:i\d+>> Compare [<<ArgX>>,<<ArgY>>] 54 /// CHECK-DAG: Return [<<Result>>] 55 56 /// CHECK-START: int Main.compareBooleans(boolean, boolean) instruction_simplifier$after_bce (after) 57 /// CHECK-NOT: Select 58 59 private static int compareBooleans(boolean x, boolean y) { 60 return Integer.compare((x ? 1 : 0), (y ? 1 : 0)); 61 } 62 63 private static int compareBooleansSmali(boolean x, boolean y) throws Exception { 64 Class<?> c = Class.forName("Smali"); 65 Method m = c.getMethod("compareBooleans", boolean.class, boolean.class); 66 return (Integer) m.invoke(null, x, y); 67 } 68 69 /// CHECK-START: int Main.compareBytes(byte, byte) intrinsics_recognition (after) 70 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 71 /// CHECK-DAG: Return [<<Result>>] 72 73 /// CHECK-START: int Main.compareBytes(byte, byte) instruction_simplifier (after) 74 /// CHECK-DAG: <<Result:i\d+>> Compare 75 /// CHECK-DAG: Return [<<Result>>] 76 77 /// CHECK-START: int Main.compareBytes(byte, byte) instruction_simplifier (after) 78 /// CHECK-NOT: InvokeStaticOrDirect 79 80 private static int compareBytes(byte x, byte y) { 81 return Integer.compare(x, y); 82 } 83 84 /// CHECK-START: int Main.compareShorts(short, short) intrinsics_recognition (after) 85 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 86 /// CHECK-DAG: Return [<<Result>>] 87 88 /// CHECK-START: int Main.compareShorts(short, short) instruction_simplifier (after) 89 /// CHECK-DAG: <<Result:i\d+>> Compare 90 /// CHECK-DAG: Return [<<Result>>] 91 92 /// CHECK-START: int Main.compareShorts(short, short) instruction_simplifier (after) 93 /// CHECK-NOT: InvokeStaticOrDirect 94 95 private static int compareShorts(short x, short y) { 96 return Integer.compare(x, y); 97 } 98 99 /// CHECK-START: int Main.compareChars(char, char) intrinsics_recognition (after) 100 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 101 /// CHECK-DAG: Return [<<Result>>] 102 103 /// CHECK-START: int Main.compareChars(char, char) instruction_simplifier (after) 104 /// CHECK-DAG: <<Result:i\d+>> Compare 105 /// CHECK-DAG: Return [<<Result>>] 106 107 /// CHECK-START: int Main.compareChars(char, char) instruction_simplifier (after) 108 /// CHECK-NOT: InvokeStaticOrDirect 109 110 private static int compareChars(char x, char y) { 111 return Integer.compare(x, y); 112 } 113 114 /// CHECK-START: int Main.compareInts(int, int) intrinsics_recognition (after) 115 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 116 /// CHECK-DAG: Return [<<Result>>] 117 118 /// CHECK-START: int Main.compareInts(int, int) instruction_simplifier (after) 119 /// CHECK-DAG: <<Result:i\d+>> Compare 120 /// CHECK-DAG: Return [<<Result>>] 121 122 /// CHECK-START: int Main.compareInts(int, int) instruction_simplifier (after) 123 /// CHECK-NOT: InvokeStaticOrDirect 124 125 private static int compareInts(int x, int y) { 126 return Integer.compare(x, y); 127 } 128 129 /// CHECK-START: int Main.compareLongs(long, long) intrinsics_recognition (after) 130 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:LongCompare 131 /// CHECK-DAG: Return [<<Result>>] 132 133 /// CHECK-START: int Main.compareLongs(long, long) instruction_simplifier (after) 134 /// CHECK-DAG: <<Result:i\d+>> Compare 135 /// CHECK-DAG: Return [<<Result>>] 136 137 /// CHECK-START: int Main.compareLongs(long, long) instruction_simplifier (after) 138 /// CHECK-NOT: InvokeStaticOrDirect 139 140 private static int compareLongs(long x, long y) { 141 return Long.compare(x, y); 142 } 143 144 145 /// CHECK-START: int Main.compareByteShort(byte, short) intrinsics_recognition (after) 146 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 147 /// CHECK-DAG: Return [<<Result>>] 148 149 /// CHECK-START: int Main.compareByteShort(byte, short) instruction_simplifier (after) 150 /// CHECK-DAG: <<Result:i\d+>> Compare 151 /// CHECK-DAG: Return [<<Result>>] 152 153 /// CHECK-START: int Main.compareByteShort(byte, short) instruction_simplifier (after) 154 /// CHECK-NOT: InvokeStaticOrDirect 155 156 public static int compareByteShort(byte x, short y) { 157 return Integer.compare(x, y); 158 } 159 160 /// CHECK-START: int Main.compareByteChar(byte, char) intrinsics_recognition (after) 161 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 162 /// CHECK-DAG: Return [<<Result>>] 163 164 /// CHECK-START: int Main.compareByteChar(byte, char) instruction_simplifier (after) 165 /// CHECK-DAG: <<Result:i\d+>> Compare 166 /// CHECK-DAG: Return [<<Result>>] 167 168 /// CHECK-START: int Main.compareByteChar(byte, char) instruction_simplifier (after) 169 /// CHECK-NOT: InvokeStaticOrDirect 170 171 public static int compareByteChar(byte x, char y) { 172 return Integer.compare(x, y); 173 } 174 175 /// CHECK-START: int Main.compareByteInt(byte, int) intrinsics_recognition (after) 176 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 177 /// CHECK-DAG: Return [<<Result>>] 178 179 /// CHECK-START: int Main.compareByteInt(byte, int) instruction_simplifier (after) 180 /// CHECK-DAG: <<Result:i\d+>> Compare 181 /// CHECK-DAG: Return [<<Result>>] 182 183 /// CHECK-START: int Main.compareByteInt(byte, int) instruction_simplifier (after) 184 /// CHECK-NOT: InvokeStaticOrDirect 185 186 public static int compareByteInt(byte x, int y) { 187 return Integer.compare(x, y); 188 } 189 190 191 /// CHECK-START: int Main.compareShortByte(short, byte) intrinsics_recognition (after) 192 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 193 /// CHECK-DAG: Return [<<Result>>] 194 195 /// CHECK-START: int Main.compareShortByte(short, byte) instruction_simplifier (after) 196 /// CHECK-DAG: <<Result:i\d+>> Compare 197 /// CHECK-DAG: Return [<<Result>>] 198 199 /// CHECK-START: int Main.compareShortByte(short, byte) instruction_simplifier (after) 200 /// CHECK-NOT: InvokeStaticOrDirect 201 202 public static int compareShortByte(short x, byte y) { 203 return Integer.compare(x, y); 204 } 205 206 /// CHECK-START: int Main.compareShortChar(short, char) intrinsics_recognition (after) 207 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 208 /// CHECK-DAG: Return [<<Result>>] 209 210 /// CHECK-START: int Main.compareShortChar(short, char) instruction_simplifier (after) 211 /// CHECK-DAG: <<Result:i\d+>> Compare 212 /// CHECK-DAG: Return [<<Result>>] 213 214 /// CHECK-START: int Main.compareShortChar(short, char) instruction_simplifier (after) 215 /// CHECK-NOT: InvokeStaticOrDirect 216 217 public static int compareShortChar(short x, char y) { 218 return Integer.compare(x, y); 219 } 220 221 /// CHECK-START: int Main.compareShortInt(short, int) intrinsics_recognition (after) 222 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 223 /// CHECK-DAG: Return [<<Result>>] 224 225 /// CHECK-START: int Main.compareShortInt(short, int) instruction_simplifier (after) 226 /// CHECK-DAG: <<Result:i\d+>> Compare 227 /// CHECK-DAG: Return [<<Result>>] 228 229 /// CHECK-START: int Main.compareShortInt(short, int) instruction_simplifier (after) 230 /// CHECK-NOT: InvokeStaticOrDirect 231 232 public static int compareShortInt(short x, int y) { 233 return Integer.compare(x, y); 234 } 235 236 237 /// CHECK-START: int Main.compareCharByte(char, byte) intrinsics_recognition (after) 238 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 239 /// CHECK-DAG: Return [<<Result>>] 240 241 /// CHECK-START: int Main.compareCharByte(char, byte) instruction_simplifier (after) 242 /// CHECK-DAG: <<Result:i\d+>> Compare 243 /// CHECK-DAG: Return [<<Result>>] 244 245 /// CHECK-START: int Main.compareCharByte(char, byte) instruction_simplifier (after) 246 /// CHECK-NOT: InvokeStaticOrDirect 247 248 public static int compareCharByte(char x, byte y) { 249 return Integer.compare(x, y); 250 } 251 252 /// CHECK-START: int Main.compareCharShort(char, short) intrinsics_recognition (after) 253 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 254 /// CHECK-DAG: Return [<<Result>>] 255 256 /// CHECK-START: int Main.compareCharShort(char, short) instruction_simplifier (after) 257 /// CHECK-DAG: <<Result:i\d+>> Compare 258 /// CHECK-DAG: Return [<<Result>>] 259 260 /// CHECK-START: int Main.compareCharShort(char, short) instruction_simplifier (after) 261 /// CHECK-NOT: InvokeStaticOrDirect 262 263 public static int compareCharShort(char x, short y) { 264 return Integer.compare(x, y); 265 } 266 267 /// CHECK-START: int Main.compareCharInt(char, int) intrinsics_recognition (after) 268 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 269 /// CHECK-DAG: Return [<<Result>>] 270 271 /// CHECK-START: int Main.compareCharInt(char, int) instruction_simplifier (after) 272 /// CHECK-DAG: <<Result:i\d+>> Compare 273 /// CHECK-DAG: Return [<<Result>>] 274 275 /// CHECK-START: int Main.compareCharInt(char, int) instruction_simplifier (after) 276 /// CHECK-NOT: InvokeStaticOrDirect 277 278 public static int compareCharInt(char x, int y) { 279 return Integer.compare(x, y); 280 } 281 282 283 /// CHECK-START: int Main.compareIntByte(int, byte) intrinsics_recognition (after) 284 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 285 /// CHECK-DAG: Return [<<Result>>] 286 287 /// CHECK-START: int Main.compareIntByte(int, byte) instruction_simplifier (after) 288 /// CHECK-DAG: <<Result:i\d+>> Compare 289 /// CHECK-DAG: Return [<<Result>>] 290 291 /// CHECK-START: int Main.compareIntByte(int, byte) instruction_simplifier (after) 292 /// CHECK-NOT: InvokeStaticOrDirect 293 294 public static int compareIntByte(int x, byte y) { 295 return Integer.compare(x, y); 296 } 297 298 /// CHECK-START: int Main.compareIntShort(int, short) intrinsics_recognition (after) 299 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 300 /// CHECK-DAG: Return [<<Result>>] 301 302 /// CHECK-START: int Main.compareIntShort(int, short) instruction_simplifier (after) 303 /// CHECK-DAG: <<Result:i\d+>> Compare 304 /// CHECK-DAG: Return [<<Result>>] 305 306 /// CHECK-START: int Main.compareIntShort(int, short) instruction_simplifier (after) 307 /// CHECK-NOT: InvokeStaticOrDirect 308 309 public static int compareIntShort(int x, short y) { 310 return Integer.compare(x, y); 311 } 312 313 /// CHECK-START: int Main.compareIntChar(int, char) intrinsics_recognition (after) 314 /// CHECK-DAG: <<Result:i\d+>> InvokeStaticOrDirect intrinsic:IntegerCompare 315 /// CHECK-DAG: Return [<<Result>>] 316 317 /// CHECK-START: int Main.compareIntChar(int, char) instruction_simplifier (after) 318 /// CHECK-DAG: <<Result:i\d+>> Compare 319 /// CHECK-DAG: Return [<<Result>>] 320 321 /// CHECK-START: int Main.compareIntChar(int, char) instruction_simplifier (after) 322 /// CHECK-NOT: InvokeStaticOrDirect 323 324 public static int compareIntChar(int x, char y) { 325 return Integer.compare(x, y); 326 } 327 328 329 public static void testCompareBooleans() throws Exception { 330 expectEquals(-1, compareBooleans(false, true)); 331 expectEquals(-1, compareBooleansSmali(false, true)); 332 333 expectEquals(0, compareBooleans(false, false)); 334 expectEquals(0, compareBooleans(true, true)); 335 expectEquals(0, compareBooleansSmali(false, false)); 336 expectEquals(0, compareBooleansSmali(true, true)); 337 338 expectEquals(1, compareBooleans(true, false)); 339 expectEquals(1, compareBooleansSmali(true, false)); 340 } 341 342 public static void testCompareBytes() { 343 expectEquals(-1, compareBytes(Byte.MIN_VALUE, (byte)(Byte.MIN_VALUE + 1))); 344 expectEquals(-1, compareBytes(Byte.MIN_VALUE, (byte)-1)); 345 expectEquals(-1, compareBytes(Byte.MIN_VALUE, (byte)0)); 346 expectEquals(-1, compareBytes(Byte.MIN_VALUE, (byte)1)); 347 expectEquals(-1, compareBytes(Byte.MIN_VALUE, Byte.MAX_VALUE)); 348 expectEquals(-1, compareBytes((byte)-1, (byte)0)); 349 expectEquals(-1, compareBytes((byte)-1, (byte)1)); 350 expectEquals(-1, compareBytes((byte)0, (byte)1)); 351 352 expectEquals(0, compareBytes(Byte.MIN_VALUE, Byte.MIN_VALUE)); 353 expectEquals(0, compareBytes((byte)-1, (byte)-1)); 354 expectEquals(0, compareBytes((byte)0, (byte)0)); 355 expectEquals(0, compareBytes((byte)1, (byte)1)); 356 expectEquals(0, compareBytes(Byte.MAX_VALUE, Byte.MAX_VALUE)); 357 358 expectEquals(1, compareBytes((byte)0, (byte)-1)); 359 expectEquals(1, compareBytes((byte)1, (byte)-1)); 360 expectEquals(1, compareBytes((byte)1, (byte)0)); 361 expectEquals(1, compareBytes(Byte.MAX_VALUE, Byte.MIN_VALUE)); 362 expectEquals(1, compareBytes(Byte.MAX_VALUE, (byte)-1)); 363 expectEquals(1, compareBytes(Byte.MAX_VALUE, (byte)0)); 364 expectEquals(1, compareBytes(Byte.MAX_VALUE, (byte)1)); 365 expectEquals(1, compareBytes(Byte.MAX_VALUE, (byte)(Byte.MAX_VALUE - 1))); 366 367 for (byte i = -11; i <= 11; i++) { 368 for (byte j = -11; j <= 11; j++) { 369 int expected = 0; 370 if (i < j) expected = -1; 371 else if (i > j) expected = 1; 372 expectEquals(expected, compareBytes(i, j)); 373 } 374 } 375 } 376 377 public static void testCompareShorts() { 378 expectEquals(-1, compareShorts(Short.MIN_VALUE, (short)(Short.MIN_VALUE + 1))); 379 expectEquals(-1, compareShorts(Short.MIN_VALUE, (short)-1)); 380 expectEquals(-1, compareShorts(Short.MIN_VALUE, (short)0)); 381 expectEquals(-1, compareShorts(Short.MIN_VALUE, (short)1)); 382 expectEquals(-1, compareShorts(Short.MIN_VALUE, (short)Short.MAX_VALUE)); 383 expectEquals(-1, compareShorts((short)-1, (short)0)); 384 expectEquals(-1, compareShorts((short)-1, (short)1)); 385 expectEquals(-1, compareShorts((short)0, (short)1)); 386 387 expectEquals(0, compareShorts(Short.MIN_VALUE, Short.MIN_VALUE)); 388 expectEquals(0, compareShorts((short)-1, (short)-1)); 389 expectEquals(0, compareShorts((short)0, (short)0)); 390 expectEquals(0, compareShorts((short)1, (short)1)); 391 expectEquals(0, compareShorts(Short.MAX_VALUE, Short.MAX_VALUE)); 392 393 expectEquals(1, compareShorts((short)0, (short)-1)); 394 expectEquals(1, compareShorts((short)1, (short)-1)); 395 expectEquals(1, compareShorts((short)1, (short)0)); 396 expectEquals(1, compareShorts(Short.MAX_VALUE, Short.MIN_VALUE)); 397 expectEquals(1, compareShorts(Short.MAX_VALUE, (short)-1)); 398 expectEquals(1, compareShorts(Short.MAX_VALUE, (short)0)); 399 expectEquals(1, compareShorts(Short.MAX_VALUE, (short)1)); 400 expectEquals(1, compareShorts(Short.MAX_VALUE, (short)(Short.MAX_VALUE - 1))); 401 402 for (short i = -11; i <= 11; i++) { 403 for (short j = -11; j <= 11; j++) { 404 int expected = 0; 405 if (i < j) expected = -1; 406 else if (i > j) expected = 1; 407 expectEquals(expected, compareShorts(i, j)); 408 } 409 } 410 } 411 412 public static void testCompareChars() { 413 expectEquals(-1, compareChars((char)0, Character.MAX_VALUE)); 414 expectEquals(-1, compareChars((char)0, (char)1)); 415 416 expectEquals(0, compareChars((char)0, (char)0)); 417 expectEquals(0, compareChars((char)1, (char)1)); 418 expectEquals(0, compareChars(Character.MAX_VALUE, Character.MAX_VALUE)); 419 420 expectEquals(1, compareChars((char)1, (char)0)); 421 expectEquals(1, compareChars(Character.MAX_VALUE, (char)0)); 422 expectEquals(1, compareChars(Character.MAX_VALUE, (char)1)); 423 expectEquals(1, compareChars(Character.MAX_VALUE, (char)(Character.MAX_VALUE - 1))); 424 425 for (char i = 0; i <= 11; i++) { 426 for (char j = 0; j <= 11; j++) { 427 int expected = 0; 428 if (i < j) expected = -1; 429 else if (i > j) expected = 1; 430 expectEquals(expected, compareChars(i, j)); 431 } 432 } 433 } 434 435 public static void testCompareInts() { 436 expectEquals(-1, compareInts(Integer.MIN_VALUE, Integer.MIN_VALUE + 1)); 437 expectEquals(-1, compareInts(Integer.MIN_VALUE, -1)); 438 expectEquals(-1, compareInts(Integer.MIN_VALUE, 0)); 439 expectEquals(-1, compareInts(Integer.MIN_VALUE, 1)); 440 expectEquals(-1, compareInts(Integer.MIN_VALUE, Integer.MAX_VALUE)); 441 expectEquals(-1, compareInts(-1, 0)); 442 expectEquals(-1, compareInts(-1, 1)); 443 expectEquals(-1, compareInts(0, 1)); 444 445 expectEquals(0, compareInts(Integer.MIN_VALUE, Integer.MIN_VALUE)); 446 expectEquals(0, compareInts(-1, -1)); 447 expectEquals(0, compareInts(0, 0)); 448 expectEquals(0, compareInts(1, 1)); 449 expectEquals(0, compareInts(Integer.MAX_VALUE, Integer.MAX_VALUE)); 450 451 expectEquals(1, compareInts(0, -1)); 452 expectEquals(1, compareInts(1, -1)); 453 expectEquals(1, compareInts(1, 0)); 454 expectEquals(1, compareInts(Integer.MAX_VALUE, Integer.MIN_VALUE)); 455 expectEquals(1, compareInts(Integer.MAX_VALUE, -1)); 456 expectEquals(1, compareInts(Integer.MAX_VALUE, 0)); 457 expectEquals(1, compareInts(Integer.MAX_VALUE, 1)); 458 expectEquals(1, compareInts(Integer.MAX_VALUE, Integer.MAX_VALUE - 1)); 459 460 for (int i = -11; i <= 11; i++) { 461 for (int j = -11; j <= 11; j++) { 462 int expected = 0; 463 if (i < j) expected = -1; 464 else if (i > j) expected = 1; 465 expectEquals(expected, compareInts(i, j)); 466 } 467 } 468 } 469 470 public static void testCompareLongs() { 471 expectEquals(-1, compareLongs(Long.MIN_VALUE, Long.MIN_VALUE + 1L)); 472 expectEquals(-1, compareLongs(Long.MIN_VALUE, -1L)); 473 expectEquals(-1, compareLongs(Long.MIN_VALUE, 0L)); 474 expectEquals(-1, compareLongs(Long.MIN_VALUE, 1L)); 475 expectEquals(-1, compareLongs(Long.MIN_VALUE, Long.MAX_VALUE)); 476 expectEquals(-1, compareLongs(-1L, 0L)); 477 expectEquals(-1, compareLongs(-1L, 1L)); 478 expectEquals(-1, compareLongs(0L, 1L)); 479 480 expectEquals(0, compareLongs(Long.MIN_VALUE, Long.MIN_VALUE)); 481 expectEquals(0, compareLongs(-1L, -1L)); 482 expectEquals(0, compareLongs(0L, 0L)); 483 expectEquals(0, compareLongs(1L, 1L)); 484 expectEquals(0, compareLongs(Long.MAX_VALUE, Long.MAX_VALUE)); 485 486 expectEquals(1, compareLongs(0L, -1L)); 487 expectEquals(1, compareLongs(1L, -1L)); 488 expectEquals(1, compareLongs(1L, 0L)); 489 expectEquals(1, compareLongs(Long.MAX_VALUE, Long.MIN_VALUE)); 490 expectEquals(1, compareLongs(Long.MAX_VALUE, -1L)); 491 expectEquals(1, compareLongs(Long.MAX_VALUE, 0L)); 492 expectEquals(1, compareLongs(Long.MAX_VALUE, 1L)); 493 expectEquals(1, compareLongs(Long.MAX_VALUE, Long.MAX_VALUE - 1L)); 494 495 expectEquals(-1, compareLongs(0x111111117FFFFFFFL, 0x11111111FFFFFFFFL)); 496 expectEquals(0, compareLongs(0x111111117FFFFFFFL, 0x111111117FFFFFFFL)); 497 expectEquals(1, compareLongs(0x11111111FFFFFFFFL, 0x111111117FFFFFFFL)); 498 499 for (long i = -11L; i <= 11L; i++) { 500 for (long j = -11L; j <= 11L; j++) { 501 int expected = 0; 502 if (i < j) expected = -1; 503 else if (i > j) expected = 1; 504 expectEquals(expected, compareLongs(i, j)); 505 } 506 } 507 508 for (long i = Long.MIN_VALUE; i <= Long.MIN_VALUE + 11L; i++) { 509 expectEquals(-1, compareLongs(i, 0)); 510 } 511 512 for (long i = Long.MAX_VALUE; i >= Long.MAX_VALUE - 11L; i--) { 513 expectEquals(1, compareLongs(i, 0)); 514 } 515 } 516 517 518 public static void testCompareByteShort() { 519 expectEquals(-1, compareByteShort(Byte.MIN_VALUE, (short)-1)); 520 expectEquals(-1, compareByteShort(Byte.MIN_VALUE, (short)0)); 521 expectEquals(-1, compareByteShort(Byte.MIN_VALUE, (short)1)); 522 expectEquals(-1, compareByteShort(Byte.MIN_VALUE, Short.MAX_VALUE)); 523 expectEquals(-1, compareByteShort((byte)-1, (short)0)); 524 expectEquals(-1, compareByteShort((byte)-1, (short)1)); 525 expectEquals(-1, compareByteShort((byte)0, (short)1)); 526 expectEquals(-1, compareByteShort(Byte.MAX_VALUE, (short)(Short.MAX_VALUE - 1))); 527 expectEquals(-1, compareByteShort(Byte.MAX_VALUE, Short.MAX_VALUE)); 528 529 expectEquals(0, compareByteShort((byte)-1, (short)-1)); 530 expectEquals(0, compareByteShort((byte)0, (short)0)); 531 expectEquals(0, compareByteShort((byte)1, (short)1)); 532 533 expectEquals(1, compareByteShort(Byte.MIN_VALUE, Short.MIN_VALUE)); 534 expectEquals(1, compareByteShort(Byte.MIN_VALUE, (short)(Short.MIN_VALUE + 1))); 535 expectEquals(1, compareByteShort((byte)0, (short)-1)); 536 expectEquals(1, compareByteShort((byte)1, (short)-1)); 537 expectEquals(1, compareByteShort((byte)1, (short)0)); 538 expectEquals(1, compareByteShort(Byte.MAX_VALUE, Short.MIN_VALUE)); 539 expectEquals(1, compareByteShort(Byte.MAX_VALUE, (short)-1)); 540 expectEquals(1, compareByteShort(Byte.MAX_VALUE, (short)0)); 541 expectEquals(1, compareByteShort(Byte.MAX_VALUE, (short)1)); 542 543 for (byte i = -11; i <= 11; i++) { 544 for (short j = -11; j <= 11; j++) { 545 int expected = 0; 546 if (i < j) expected = -1; 547 else if (i > j) expected = 1; 548 expectEquals(expected, compareByteShort(i, j)); 549 } 550 } 551 } 552 553 public static void testCompareByteChar() { 554 expectEquals(-1, compareByteChar(Byte.MIN_VALUE, (char)0)); 555 expectEquals(-1, compareByteChar(Byte.MIN_VALUE, (char)1)); 556 expectEquals(-1, compareByteChar(Byte.MIN_VALUE, Character.MAX_VALUE)); 557 expectEquals(-1, compareByteChar((byte)-1, (char)0)); 558 expectEquals(-1, compareByteChar((byte)-1, (char)1)); 559 expectEquals(-1, compareByteChar((byte)0, (char)1)); 560 expectEquals(-1, compareByteChar(Byte.MAX_VALUE, (char)(Character.MAX_VALUE - 1))); 561 expectEquals(-1, compareByteChar(Byte.MAX_VALUE, Character.MAX_VALUE)); 562 563 expectEquals(0, compareByteChar((byte)0, (char)0)); 564 expectEquals(0, compareByteChar((byte)1, (char)1)); 565 566 expectEquals(1, compareByteChar((byte)1, (char)0)); 567 expectEquals(1, compareByteChar(Byte.MAX_VALUE, (char)0)); 568 expectEquals(1, compareByteChar(Byte.MAX_VALUE, (char)1)); 569 570 for (byte i = -11; i <= 11; i++) { 571 for (char j = 0; j <= 11; j++) { 572 int expected = 0; 573 if (i < j) expected = -1; 574 else if (i > j) expected = 1; 575 expectEquals(expected, compareByteChar(i, j)); 576 } 577 } 578 } 579 580 public static void testCompareByteInt() { 581 expectEquals(-1, compareByteInt(Byte.MIN_VALUE, -1)); 582 expectEquals(-1, compareByteInt(Byte.MIN_VALUE, 0)); 583 expectEquals(-1, compareByteInt(Byte.MIN_VALUE, 1)); 584 expectEquals(-1, compareByteInt(Byte.MIN_VALUE, Integer.MAX_VALUE)); 585 expectEquals(-1, compareByteInt((byte)-1, 0)); 586 expectEquals(-1, compareByteInt((byte)-1, 1)); 587 expectEquals(-1, compareByteInt((byte)0, 1)); 588 expectEquals(-1, compareByteInt(Byte.MAX_VALUE, Integer.MAX_VALUE - 1)); 589 expectEquals(-1, compareByteInt(Byte.MAX_VALUE, Integer.MAX_VALUE)); 590 591 expectEquals(0, compareByteInt((byte)-1, -1)); 592 expectEquals(0, compareByteInt((byte)0, 0)); 593 expectEquals(0, compareByteInt((byte)1, 1)); 594 595 expectEquals(1, compareByteInt(Byte.MIN_VALUE, Integer.MIN_VALUE)); 596 expectEquals(1, compareByteInt(Byte.MIN_VALUE, Integer.MIN_VALUE + 1)); 597 expectEquals(1, compareByteInt((byte)0, -1)); 598 expectEquals(1, compareByteInt((byte)1, -1)); 599 expectEquals(1, compareByteInt((byte)1, 0)); 600 expectEquals(1, compareByteInt(Byte.MAX_VALUE, Integer.MIN_VALUE)); 601 expectEquals(1, compareByteInt(Byte.MAX_VALUE, -1)); 602 expectEquals(1, compareByteInt(Byte.MAX_VALUE, 0)); 603 expectEquals(1, compareByteInt(Byte.MAX_VALUE, 1)); 604 605 for (byte i = -11; i <= 11; i++) { 606 for (int j = -11; j <= 11; j++) { 607 int expected = 0; 608 if (i < j) expected = -1; 609 else if (i > j) expected = 1; 610 expectEquals(expected, compareByteInt(i, j)); 611 } 612 } 613 } 614 615 616 public static void testCompareShortByte() { 617 expectEquals(-1, compareShortByte(Short.MIN_VALUE, Byte.MIN_VALUE)); 618 expectEquals(-1, compareShortByte(Short.MIN_VALUE, (byte)(Byte.MIN_VALUE + 1))); 619 expectEquals(-1, compareShortByte(Short.MIN_VALUE, (byte)-1)); 620 expectEquals(-1, compareShortByte(Short.MIN_VALUE, (byte)0)); 621 expectEquals(-1, compareShortByte(Short.MIN_VALUE, (byte)1)); 622 expectEquals(-1, compareShortByte(Short.MIN_VALUE, Byte.MAX_VALUE)); 623 expectEquals(-1, compareShortByte((short)-1, (byte)0)); 624 expectEquals(-1, compareShortByte((short)-1, (byte)1)); 625 expectEquals(-1, compareShortByte((short)0, (byte)1)); 626 627 expectEquals(0, compareShortByte((short)-1, (byte)-1)); 628 expectEquals(0, compareShortByte((short)0, (byte)0)); 629 expectEquals(0, compareShortByte((short)1, (byte)1)); 630 631 expectEquals(1, compareShortByte((short)0, (byte)-1)); 632 expectEquals(1, compareShortByte((short)1, (byte)-1)); 633 expectEquals(1, compareShortByte((short)1, (byte)0)); 634 expectEquals(1, compareShortByte(Short.MAX_VALUE, Byte.MIN_VALUE)); 635 expectEquals(1, compareShortByte(Short.MAX_VALUE, (byte)-1)); 636 expectEquals(1, compareShortByte(Short.MAX_VALUE, (byte)0)); 637 expectEquals(1, compareShortByte(Short.MAX_VALUE, (byte)1)); 638 expectEquals(1, compareShortByte(Short.MAX_VALUE, (byte)(Byte.MAX_VALUE - 1))); 639 expectEquals(1, compareShortByte(Short.MAX_VALUE, Byte.MAX_VALUE)); 640 641 for (short i = -11; i <= 11; i++) { 642 for (byte j = -11; j <= 11; j++) { 643 int expected = 0; 644 if (i < j) expected = -1; 645 else if (i > j) expected = 1; 646 expectEquals(expected, compareShortByte(i, j)); 647 } 648 } 649 } 650 651 public static void testCompareShortChar() { 652 expectEquals(-1, compareShortChar(Short.MIN_VALUE, (char)0)); 653 expectEquals(-1, compareShortChar(Short.MIN_VALUE, (char)1)); 654 expectEquals(-1, compareShortChar(Short.MIN_VALUE, Character.MAX_VALUE)); 655 expectEquals(-1, compareShortChar((short)-1, (char)0)); 656 expectEquals(-1, compareShortChar((short)-1, (char)1)); 657 expectEquals(-1, compareShortChar((short)0, (char)1)); 658 expectEquals(-1, compareShortChar(Short.MAX_VALUE, (char)(Character.MAX_VALUE - 1))); 659 expectEquals(-1, compareShortChar(Short.MAX_VALUE, Character.MAX_VALUE)); 660 661 expectEquals(0, compareShortChar((short)0, (char)0)); 662 expectEquals(0, compareShortChar((short)1, (char)1)); 663 664 expectEquals(1, compareShortChar((short)1, (char)0)); 665 expectEquals(1, compareShortChar(Short.MAX_VALUE, (char)0)); 666 expectEquals(1, compareShortChar(Short.MAX_VALUE, (char)1)); 667 668 for (short i = -11; i <= 11; i++) { 669 for (char j = 0; j <= 11; j++) { 670 int expected = 0; 671 if (i < j) expected = -1; 672 else if (i > j) expected = 1; 673 expectEquals(expected, compareShortChar(i, j)); 674 } 675 } 676 } 677 678 public static void testCompareShortInt() { 679 expectEquals(-1, compareShortInt(Short.MIN_VALUE, -1)); 680 expectEquals(-1, compareShortInt(Short.MIN_VALUE, 0)); 681 expectEquals(-1, compareShortInt(Short.MIN_VALUE, 1)); 682 expectEquals(-1, compareShortInt(Short.MIN_VALUE, Integer.MAX_VALUE)); 683 expectEquals(-1, compareShortInt((short)-1, 0)); 684 expectEquals(-1, compareShortInt((short)-1, 1)); 685 expectEquals(-1, compareShortInt((short)0, 1)); 686 expectEquals(-1, compareShortInt(Short.MAX_VALUE, Integer.MAX_VALUE - 1)); 687 expectEquals(-1, compareShortInt(Short.MAX_VALUE, Integer.MAX_VALUE)); 688 689 expectEquals(0, compareShortInt((short)-1, -1)); 690 expectEquals(0, compareShortInt((short)0, 0)); 691 expectEquals(0, compareShortInt((short)1, 1)); 692 693 expectEquals(1, compareShortInt(Short.MIN_VALUE, Integer.MIN_VALUE)); 694 expectEquals(1, compareShortInt(Short.MIN_VALUE, Integer.MIN_VALUE + 1)); 695 expectEquals(1, compareShortInt((short)0, -1)); 696 expectEquals(1, compareShortInt((short)1, -1)); 697 expectEquals(1, compareShortInt((short)1, 0)); 698 expectEquals(1, compareShortInt(Short.MAX_VALUE, Integer.MIN_VALUE)); 699 expectEquals(1, compareShortInt(Short.MAX_VALUE, -1)); 700 expectEquals(1, compareShortInt(Short.MAX_VALUE, 0)); 701 expectEquals(1, compareShortInt(Short.MAX_VALUE, 1)); 702 703 for (short i = -11; i <= 11; i++) { 704 for (int j = -11; j <= 11; j++) { 705 int expected = 0; 706 if (i < j) expected = -1; 707 else if (i > j) expected = 1; 708 expectEquals(expected, compareShortInt(i, j)); 709 } 710 } 711 } 712 713 714 public static void testCompareCharByte() { 715 expectEquals(-1, compareCharByte((char)0, (byte)1)); 716 expectEquals(-1, compareCharByte((char)0, Byte.MAX_VALUE)); 717 718 expectEquals(0, compareCharByte((char)0, (byte)0)); 719 expectEquals(0, compareCharByte((char)1, (byte)1)); 720 721 expectEquals(1, compareCharByte((char)0, Byte.MIN_VALUE)); 722 expectEquals(1, compareCharByte((char)0, (byte)(Byte.MIN_VALUE + 1))); 723 expectEquals(1, compareCharByte((char)0, (byte)-1)); 724 expectEquals(1, compareCharByte((char)1, (byte)-1)); 725 expectEquals(1, compareCharByte((char)1, (byte)0)); 726 expectEquals(1, compareCharByte(Character.MAX_VALUE, Byte.MIN_VALUE)); 727 expectEquals(1, compareCharByte(Character.MAX_VALUE, (byte)-1)); 728 expectEquals(1, compareCharByte(Character.MAX_VALUE, (byte)0)); 729 expectEquals(1, compareCharByte(Character.MAX_VALUE, (byte)1)); 730 expectEquals(1, compareCharByte(Character.MAX_VALUE, (byte)(Byte.MAX_VALUE - 1))); 731 expectEquals(1, compareCharByte(Character.MAX_VALUE, Byte.MAX_VALUE)); 732 733 for (char i = 0; i <= 11; i++) { 734 for (byte j = -11; j <= 11; j++) { 735 int expected = 0; 736 if (i < j) expected = -1; 737 else if (i > j) expected = 1; 738 expectEquals(expected, compareCharByte(i, j)); 739 } 740 } 741 } 742 743 public static void testCompareCharShort() { 744 expectEquals(-1, compareCharShort((char)0, (short)1)); 745 expectEquals(-1, compareCharShort((char)0, Short.MAX_VALUE)); 746 747 expectEquals(0, compareCharShort((char)0, (short)0)); 748 expectEquals(0, compareCharShort((char)1, (short)1)); 749 750 expectEquals(1, compareCharShort((char)0, Short.MIN_VALUE)); 751 expectEquals(1, compareCharShort((char)0, (short)(Short.MIN_VALUE + 1))); 752 expectEquals(1, compareCharShort((char)0, (short)-1)); 753 expectEquals(1, compareCharShort((char)1, (short)-1)); 754 expectEquals(1, compareCharShort((char)1, (short)0)); 755 expectEquals(1, compareCharShort(Character.MAX_VALUE, Short.MIN_VALUE)); 756 expectEquals(1, compareCharShort(Character.MAX_VALUE, (short)-1)); 757 expectEquals(1, compareCharShort(Character.MAX_VALUE, (short)0)); 758 expectEquals(1, compareCharShort(Character.MAX_VALUE, (short)1)); 759 expectEquals(1, compareCharShort(Character.MAX_VALUE, (short)(Short.MAX_VALUE - 1))); 760 expectEquals(1, compareCharShort(Character.MAX_VALUE, Short.MAX_VALUE)); 761 762 for (char i = 0; i <= 11; i++) { 763 for (short j = -11; j <= 11; j++) { 764 int expected = 0; 765 if (i < j) expected = -1; 766 else if (i > j) expected = 1; 767 expectEquals(expected, compareCharShort(i, j)); 768 } 769 } 770 } 771 772 public static void testCompareCharInt() { 773 expectEquals(-1, compareCharInt((char)0, 1)); 774 expectEquals(-1, compareCharInt((char)0, Integer.MAX_VALUE)); 775 expectEquals(-1, compareCharInt(Character.MAX_VALUE, Integer.MAX_VALUE - 1)); 776 expectEquals(-1, compareCharInt(Character.MAX_VALUE, Integer.MAX_VALUE)); 777 778 expectEquals(0, compareCharInt((char)0, 0)); 779 expectEquals(0, compareCharInt((char)1, 1)); 780 781 expectEquals(1, compareCharInt((char)0, Integer.MIN_VALUE)); 782 expectEquals(1, compareCharInt((char)0, Integer.MIN_VALUE + 1)); 783 expectEquals(1, compareCharInt((char)0, -1)); 784 expectEquals(1, compareCharInt((char)1, -1)); 785 expectEquals(1, compareCharInt((char)1, 0)); 786 expectEquals(1, compareCharInt(Character.MAX_VALUE, Integer.MIN_VALUE)); 787 expectEquals(1, compareCharInt(Character.MAX_VALUE, -1)); 788 expectEquals(1, compareCharInt(Character.MAX_VALUE, 0)); 789 expectEquals(1, compareCharInt(Character.MAX_VALUE, 1)); 790 791 for (char i = 0; i <= 11; i++) { 792 for (int j = -11; j <= 11; j++) { 793 int expected = 0; 794 if (i < j) expected = -1; 795 else if (i > j) expected = 1; 796 expectEquals(expected, compareCharInt(i, j)); 797 } 798 } 799 } 800 801 802 public static void testCompareIntByte() { 803 expectEquals(-1, compareIntByte(Integer.MIN_VALUE, Byte.MIN_VALUE)); 804 expectEquals(-1, compareIntByte(Integer.MIN_VALUE, (byte)(Byte.MIN_VALUE + 1))); 805 expectEquals(-1, compareIntByte(Integer.MIN_VALUE, (byte)-1)); 806 expectEquals(-1, compareIntByte(Integer.MIN_VALUE, (byte)0)); 807 expectEquals(-1, compareIntByte(Integer.MIN_VALUE, (byte)1)); 808 expectEquals(-1, compareIntByte(Integer.MIN_VALUE, Byte.MAX_VALUE)); 809 expectEquals(-1, compareIntByte(-1, (byte)0)); 810 expectEquals(-1, compareIntByte(-1, (byte)1)); 811 expectEquals(-1, compareIntByte(0, (byte)1)); 812 813 expectEquals(0, compareIntByte(-1, (byte)-1)); 814 expectEquals(0, compareIntByte(0, (byte)0)); 815 expectEquals(0, compareIntByte(1, (byte)1)); 816 817 expectEquals(1, compareIntByte(0, (byte)-1)); 818 expectEquals(1, compareIntByte(1, (byte)-1)); 819 expectEquals(1, compareIntByte(1, (byte)0)); 820 expectEquals(1, compareIntByte(Integer.MAX_VALUE, Byte.MIN_VALUE)); 821 expectEquals(1, compareIntByte(Integer.MAX_VALUE, (byte)-1)); 822 expectEquals(1, compareIntByte(Integer.MAX_VALUE, (byte)0)); 823 expectEquals(1, compareIntByte(Integer.MAX_VALUE, (byte)1)); 824 expectEquals(1, compareIntByte(Integer.MAX_VALUE, (byte)(Byte.MAX_VALUE - 1))); 825 expectEquals(1, compareIntByte(Integer.MAX_VALUE, Byte.MAX_VALUE)); 826 827 for (int i = -11; i <= 11; i++) { 828 for (byte j = -11; j <= 11; j++) { 829 int expected = 0; 830 if (i < j) expected = -1; 831 else if (i > j) expected = 1; 832 expectEquals(expected, compareIntByte(i, j)); 833 } 834 } 835 } 836 837 public static void testCompareIntShort() { 838 expectEquals(-1, compareIntShort(Integer.MIN_VALUE, Short.MIN_VALUE)); 839 expectEquals(-1, compareIntShort(Integer.MIN_VALUE, (short)(Short.MIN_VALUE + 1))); 840 expectEquals(-1, compareIntShort(Integer.MIN_VALUE, (short)-1)); 841 expectEquals(-1, compareIntShort(Integer.MIN_VALUE, (short)0)); 842 expectEquals(-1, compareIntShort(Integer.MIN_VALUE, (short)1)); 843 expectEquals(-1, compareIntShort(Integer.MIN_VALUE, Short.MAX_VALUE)); 844 expectEquals(-1, compareIntShort(-1, (short)0)); 845 expectEquals(-1, compareIntShort(-1, (short)1)); 846 expectEquals(-1, compareIntShort(0, (short)1)); 847 848 expectEquals(0, compareIntShort(-1, (short)-1)); 849 expectEquals(0, compareIntShort(0, (short)0)); 850 expectEquals(0, compareIntShort(1, (short)1)); 851 852 expectEquals(1, compareIntShort(0, (short)-1)); 853 expectEquals(1, compareIntShort(1, (short)-1)); 854 expectEquals(1, compareIntShort(1, (short)0)); 855 expectEquals(1, compareIntShort(Integer.MAX_VALUE, Short.MIN_VALUE)); 856 expectEquals(1, compareIntShort(Integer.MAX_VALUE, (short)-1)); 857 expectEquals(1, compareIntShort(Integer.MAX_VALUE, (short)0)); 858 expectEquals(1, compareIntShort(Integer.MAX_VALUE, (short)1)); 859 expectEquals(1, compareIntShort(Integer.MAX_VALUE, (short)(Short.MAX_VALUE - 1))); 860 expectEquals(1, compareIntShort(Integer.MAX_VALUE, Short.MAX_VALUE)); 861 862 for (int i = -11; i <= 11; i++) { 863 for (short j = -11; j <= 11; j++) { 864 int expected = 0; 865 if (i < j) expected = -1; 866 else if (i > j) expected = 1; 867 expectEquals(expected, compareIntShort(i, j)); 868 } 869 } 870 } 871 872 public static void testCompareIntChar() { 873 expectEquals(-1, compareIntChar(Integer.MIN_VALUE, (char)0)); 874 expectEquals(-1, compareIntChar(Integer.MIN_VALUE, (char)1)); 875 expectEquals(-1, compareIntChar(Integer.MIN_VALUE, Character.MAX_VALUE)); 876 expectEquals(-1, compareIntChar(-1, (char)0)); 877 expectEquals(-1, compareIntChar(-1, (char)1)); 878 expectEquals(-1, compareIntChar(0, (char)1)); 879 880 expectEquals(0, compareIntChar(0, (char)0)); 881 expectEquals(0, compareIntChar(1, (char)1)); 882 883 expectEquals(1, compareIntChar(1, (char)0)); 884 expectEquals(1, compareIntChar(Integer.MAX_VALUE, (char)0)); 885 expectEquals(1, compareIntChar(Integer.MAX_VALUE, (char)1)); 886 expectEquals(1, compareIntChar(Integer.MAX_VALUE, (char)(Character.MAX_VALUE - 1))); 887 expectEquals(1, compareIntChar(Integer.MAX_VALUE, Character.MAX_VALUE)); 888 889 for (int i = -11; i <= 11; i++) { 890 for (char j = 0; j <= 11; j++) { 891 int expected = 0; 892 if (i < j) expected = -1; 893 else if (i > j) expected = 1; 894 expectEquals(expected, compareIntChar(i, j)); 895 } 896 } 897 } 898 899 900 public static void main(String args[]) throws Exception { 901 $opt$noinline$testReplaceInputWithItself(42); 902 903 testCompareBooleans(); 904 testCompareBytes(); 905 testCompareShorts(); 906 testCompareChars(); 907 testCompareInts(); 908 testCompareLongs(); 909 910 testCompareByteShort(); 911 testCompareByteChar(); 912 testCompareByteInt(); 913 914 testCompareShortByte(); 915 testCompareShortChar(); 916 testCompareShortInt(); 917 918 testCompareCharByte(); 919 testCompareCharShort(); 920 testCompareCharInt(); 921 922 testCompareIntByte(); 923 testCompareIntShort(); 924 testCompareIntChar(); 925 926 System.out.println("passed"); 927 } 928 929 private static void expectEquals(int expected, int result) { 930 if (expected != result) { 931 throw new Error("Expected: " + expected + ", found: " + result); 932 } 933 } 934 } 935