diff options
author | Roland Levillain <rpl@google.com> | 2014-12-04 12:01:55 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-12-04 12:01:55 +0000 |
commit | 833e903b7a9063f37bea3c505cf134fc4a4e2084 (patch) | |
tree | 3e2fad98dc69bc1c993a1865141be39fb8fe372e /test/422-type-conversion | |
parent | 3947000d3c84e87558471fb703ed330f457804d7 (diff) | |
parent | 624279f3c70f9904cbaf428078981b05d3b324c0 (diff) | |
download | art-833e903b7a9063f37bea3c505cf134fc4a4e2084.zip art-833e903b7a9063f37bea3c505cf134fc4a4e2084.tar.gz art-833e903b7a9063f37bea3c505cf134fc4a4e2084.tar.bz2 |
Merge "Add support for float-to-long in the optimizing compiler."
Diffstat (limited to 'test/422-type-conversion')
-rw-r--r-- | test/422-type-conversion/src/Main.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/422-type-conversion/src/Main.java b/test/422-type-conversion/src/Main.java index e7dbe24..05cdf42 100644 --- a/test/422-type-conversion/src/Main.java +++ b/test/422-type-conversion/src/Main.java @@ -94,6 +94,9 @@ public class Main { // Generate, compile and check float-to-int Dex instructions. floatToInt(); + // Generate, compile and check float-to-long Dex instructions. + floatToLong(); + // Generate, compile and check int-to-byte Dex instructions. shortToByte(); intToByte(); @@ -342,6 +345,32 @@ public class Main { assertIntEquals(-2147483648, $opt$FloatToInt(Float.NEGATIVE_INFINITY)); } + private static void floatToLong() { + assertLongEquals(1L, $opt$FloatToLong(1F)); + assertLongEquals(0L, $opt$FloatToLong(0F)); + assertLongEquals(0L, $opt$FloatToLong(-0F)); + assertLongEquals(-1L, $opt$FloatToLong(-1F)); + assertLongEquals(51L, $opt$FloatToLong(51F)); + assertLongEquals(-51L, $opt$FloatToLong(-51F)); + assertLongEquals(0L, $opt$FloatToLong(0.5F)); + assertLongEquals(0L, $opt$FloatToLong(0.4999999F)); + assertLongEquals(0L, $opt$FloatToLong(-0.4999999F)); + assertLongEquals(0L, $opt$FloatToLong(-0.5F)); + assertLongEquals(42L, $opt$FloatToLong(42.199F)); + assertLongEquals(-42L, $opt$FloatToLong(-42.199F)); + assertLongEquals(2147483648L, $opt$FloatToLong(2147483647F)); // 2^31 - 1 + assertLongEquals(-2147483648L, $opt$FloatToLong(-2147483647F)); // -(2^31 - 1) + assertLongEquals(-2147483648L, $opt$FloatToLong(-2147483648F)); // -(2^31) + assertLongEquals(2147483648L, $opt$FloatToLong(2147483648F)); // (2^31) + assertLongEquals(-2147483648L, $opt$FloatToLong(-2147483649F)); // -(2^31 + 1) + assertLongEquals(9223372036854775807L, $opt$FloatToLong(9223372036854775807F)); // 2^63 - 1 + assertLongEquals(-9223372036854775808L, $opt$FloatToLong(-9223372036854775807F)); // -(2^63 - 1) + assertLongEquals(-9223372036854775808L, $opt$FloatToLong(-9223372036854775808F)); // -(2^63) + assertLongEquals(0L, $opt$FloatToLong(Float.NaN)); + assertLongEquals(9223372036854775807L, $opt$FloatToLong(Float.POSITIVE_INFINITY)); + assertLongEquals(-9223372036854775808L, $opt$FloatToLong(Float.NEGATIVE_INFINITY)); + } + private static void shortToByte() { assertByteEquals((byte)1, $opt$ShortToByte((short)1)); assertByteEquals((byte)0, $opt$ShortToByte((short)0)); @@ -500,6 +529,9 @@ public class Main { // This method produces a float-to-int Dex instruction. static int $opt$FloatToInt(float a){ return (int)a; } + // This method produces a float-to-long Dex instruction. + static long $opt$FloatToLong(float a){ return (long)a; } + // These methods produce int-to-byte Dex instructions. static byte $opt$ShortToByte(short a){ return (byte)a; } static byte $opt$IntToByte(int a){ return (byte)a; } |