diff options
author | Roland Levillain <rpl@google.com> | 2014-11-06 12:24:42 +0000 |
---|---|---|
committer | Roland Levillain <rpl@google.com> | 2014-11-06 12:24:42 +0000 |
commit | fc8b5f263c340ef20265c5a540e151fee2f6f8d0 (patch) | |
tree | 3e66fc6020aa8113dbc1a4a3fa50a84968b81a8c /test/422-type-conversion | |
parent | a88b7b93e28ea86969dd3ec6a6bf6929d697fc31 (diff) | |
download | art-fc8b5f263c340ef20265c5a540e151fee2f6f8d0.zip art-fc8b5f263c340ef20265c5a540e151fee2f6f8d0.tar.gz art-fc8b5f263c340ef20265c5a540e151fee2f6f8d0.tar.bz2 |
Add more int-to-long tests for the optimizing compiler.
Exercise Java byte- and short-to-long conversions producing
int-to-long Dex instructions.
Change-Id: I371af3f1dfcfe5b8b1ef3b16747987da93ff133c
Diffstat (limited to 'test/422-type-conversion')
-rw-r--r-- | test/422-type-conversion/src/Main.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/test/422-type-conversion/src/Main.java b/test/422-type-conversion/src/Main.java index 9974919..d2ffc5b 100644 --- a/test/422-type-conversion/src/Main.java +++ b/test/422-type-conversion/src/Main.java @@ -25,9 +25,33 @@ public class Main { } public static void main(String[] args) { + byteToLong(); + shortToLong(); intToLong(); } + private static void byteToLong() { + assertEquals(1L, $opt$ByteToLong((byte)1)); + assertEquals(0L, $opt$ByteToLong((byte)0)); + assertEquals(-1L, $opt$ByteToLong((byte)-1)); + assertEquals(51L, $opt$ByteToLong((byte)51)); + assertEquals(-51L, $opt$ByteToLong((byte)-51)); + assertEquals(127L, $opt$ByteToLong((byte)127)); // (2^7) - 1 + assertEquals(-127L, $opt$ByteToLong((byte)-127)); // -(2^7) - 1 + assertEquals(-128L, $opt$ByteToLong((byte)-128)); // -(2^7) + } + + private static void shortToLong() { + assertEquals(1L, $opt$ShortToLong((short)1)); + assertEquals(0L, $opt$ShortToLong((short)0)); + assertEquals(-1L, $opt$ShortToLong((short)-1)); + assertEquals(51L, $opt$ShortToLong((short)51)); + assertEquals(-51L, $opt$ShortToLong((short)-51)); + assertEquals(32767L, $opt$ShortToLong((short)32767)); // (2^15) - 1 + assertEquals(-32767L, $opt$ShortToLong((short)-32767)); // -(2^15) - 1 + assertEquals(-32768L, $opt$ShortToLong((short)-32768)); // -(2^15) + } + private static void intToLong() { assertEquals(1L, $opt$IntToLong(1)); assertEquals(0L, $opt$IntToLong(0)); @@ -39,7 +63,18 @@ public class Main { assertEquals(-2147483648L, $opt$IntToLong(-2147483648)); // -(2^31) } - static long $opt$IntToLong(int a){ + static long $opt$ByteToLong(byte a) { + // Translates to an int-to-long Dex instruction. + return a; + } + + static long $opt$ShortToLong(short a) { + // Translates to an int-to-long Dex instruction. + return a; + } + + static long $opt$IntToLong(int a) { + // Translates to an int-to-long Dex instruction. return a; } } |