Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1 | // Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
| 5 | // This code is not run directly. It needs to be compiled to dex code. |
| 6 | // 'constants.dex' is what is run. |
| 7 | package constants; |
| 8 | |
| 9 | class Constants { |
| 10 | |
| 11 | public static void printInt(int x) { |
| 12 | System.out.print(x); |
| 13 | } |
| 14 | |
| 15 | public static void printLong(long x) { |
| 16 | System.out.print(x); |
| 17 | } |
| 18 | |
| 19 | public static void testConst4() { |
| 20 | printInt(-8); |
| 21 | printInt(-1); |
| 22 | printInt(0); |
| 23 | printInt(1); |
| 24 | printInt(7); |
| 25 | } |
| 26 | |
| 27 | public static void testConst16() { |
| 28 | printInt(Short.MIN_VALUE); |
| 29 | printInt(-9); |
| 30 | printInt(8); |
| 31 | printInt(Short.MAX_VALUE); |
| 32 | } |
| 33 | |
| 34 | public static void testConstHigh16() { |
| 35 | printInt(0xffff0000); |
| 36 | printInt(0xf0000000); |
| 37 | printInt(0x0f000000); |
| 38 | printInt(0x00f00000); |
| 39 | printInt(0x000f0000); |
| 40 | printInt(0x80000000); |
| 41 | printInt(0x00010000); |
| 42 | } |
| 43 | |
| 44 | public static void testConst() { |
| 45 | printInt(Short.MIN_VALUE - 1); |
| 46 | printInt(Short.MAX_VALUE + 1); |
| 47 | |
| 48 | printInt(0xffff0001); |
| 49 | printInt(0xf0000001); |
| 50 | printInt(0x0f000001); |
| 51 | printInt(0x00f00001); |
| 52 | printInt(0x000f0001); |
| 53 | printInt(0x80000001); |
| 54 | printInt(0x00010001); |
| 55 | } |
| 56 | |
| 57 | public static void testConstWide16() { |
| 58 | printLong((long) Short.MIN_VALUE); |
| 59 | printLong(-1L); |
| 60 | printLong(0L); |
| 61 | printLong(1L); |
| 62 | printLong((long) Short.MAX_VALUE); |
| 63 | } |
| 64 | |
| 65 | public static void testConstWide32() { |
| 66 | printLong((long) Short.MIN_VALUE - 1); |
| 67 | printLong((long) Integer.MIN_VALUE); |
| 68 | printLong((long) Integer.MAX_VALUE); |
| 69 | printLong((long) Short.MAX_VALUE + 1); |
| 70 | } |
| 71 | |
| 72 | public static void testConstWideHigh16() { |
| 73 | printLong(0xffff000000000000L); |
| 74 | printLong(0xf000000000000000L); |
| 75 | printLong(0x0f00000000000000L); |
| 76 | printLong(0x00f0000000000000L); |
| 77 | printLong(0x000f000000000000L); |
| 78 | printLong(0x8000000000000000L); |
| 79 | printLong(0x0001000000000000L); |
| 80 | printLong(0x7fff000000000000L); |
| 81 | } |
| 82 | |
| 83 | public static void testConstWide() { |
| 84 | printLong((long) Integer.MIN_VALUE - 1); |
| 85 | printLong((long) Integer.MAX_VALUE + 1); |
| 86 | |
| 87 | printLong(0xffff7fffffffffffL); |
| 88 | printLong(0xffff000000000001L); |
| 89 | printLong(0xf000000000000001L); |
| 90 | printLong(0x0f00000000000001L); |
| 91 | printLong(0x00f0000000000001L); |
| 92 | printLong(0x000f000000000001L); |
| 93 | printLong(0x8000000000000001L); |
| 94 | printLong(0x0001000000000001L); |
| 95 | printLong(0x7fffffffffffffffL); |
| 96 | printLong(0x7fff000000000001L); |
| 97 | } |
| 98 | |
| 99 | public static void main(String[] args) { |
| 100 | testConst4(); |
| 101 | testConst16(); |
| 102 | testConstHigh16(); |
| 103 | testConst(); |
| 104 | |
| 105 | testConstWide16(); |
| 106 | testConstWide32(); |
| 107 | testConstWideHigh16(); |
| 108 | testConstWide(); |
| 109 | } |
| 110 | } |