Test case for verifier to handle floats that look like boolean.
Stores 0x0 and Float.MIN_VALUE (0x1) into the same register and makes
sure it can still be used as float.
(cherry picked from commit ffa7f34647015d97acbaa5e4b3c44ee764321aea)
Change-Id: Ia72f24f1233f7c0a8a794def8cbe94151b60b2af
diff --git a/luni/src/test/java/libcore/java/lang/FloatTest.java b/luni/src/test/java/libcore/java/lang/FloatTest.java
index 00e1597..92e7ae4 100644
--- a/luni/src/test/java/libcore/java/lang/FloatTest.java
+++ b/luni/src/test/java/libcore/java/lang/FloatTest.java
@@ -17,6 +17,9 @@
package libcore.java.lang;
public class FloatTest extends junit.framework.TestCase {
+ // Needed to prevent testVerifierTyping from statically resolving the if statement.
+ static boolean testVerifierTypingBool = false;
+
public void test_valueOf_String1() throws Exception {
// This threw OutOfMemoryException.
// http://code.google.com/p/android/issues/detail?id=4185
@@ -110,4 +113,12 @@
assertEquals(Float.POSITIVE_INFINITY, Float.parseFloat("320.0E+2147483647"));
assertEquals(-0.0f, Float.parseFloat("-1.4E-2147483314"));
}
+
+ public void testVerifierTyping() throws Exception {
+ float f1 = 0;
+ if (testVerifierTypingBool) {
+ f1 = Float.MIN_VALUE;
+ }
+ assertEquals(f1, 0f);
+ }
}