summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-04-01 15:47:17 -0700
committerElliott Hughes <enh@google.com>2013-04-01 15:47:17 -0700
commit4c6aad2bbe24e5a1a95fc4d08a4b6bb4d1609669 (patch)
treeb3ea161c520ae8c7be58f1d4c45001d6fbecae10 /test
parent1fd3346740dfb7f47be9922312b68a4227fada96 (diff)
downloadart-4c6aad2bbe24e5a1a95fc4d08a4b6bb4d1609669.zip
art-4c6aad2bbe24e5a1a95fc4d08a4b6bb4d1609669.tar.gz
art-4c6aad2bbe24e5a1a95fc4d08a4b6bb4d1609669.tar.bz2
Add test 302-float-conversion from dalvik.
Change-Id: Id742af562cc4506ee72be6d36b4ef3299b6266dd
Diffstat (limited to 'test')
-rw-r--r--test/302-float-conversion/expected.txt1
-rw-r--r--test/302-float-conversion/info.txt4
-rw-r--r--test/302-float-conversion/src/Main.java43
3 files changed, 48 insertions, 0 deletions
diff --git a/test/302-float-conversion/expected.txt b/test/302-float-conversion/expected.txt
new file mode 100644
index 0000000..6939a5c
--- /dev/null
+++ b/test/302-float-conversion/expected.txt
@@ -0,0 +1 @@
+Result is as expected
diff --git a/test/302-float-conversion/info.txt b/test/302-float-conversion/info.txt
new file mode 100644
index 0000000..2b8bc21
--- /dev/null
+++ b/test/302-float-conversion/info.txt
@@ -0,0 +1,4 @@
+Tests whether constant conversions of double values to long values are
+properly handled by the VM. For example, x86 systems using the x87 stack
+ should not overflow under constant conversions.
+
diff --git a/test/302-float-conversion/src/Main.java b/test/302-float-conversion/src/Main.java
new file mode 100644
index 0000000..dc512c5
--- /dev/null
+++ b/test/302-float-conversion/src/Main.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Main {
+ static final long NUM_ITERATIONS = 50000;
+ static volatile double negInfinity = Double.NEGATIVE_INFINITY;
+
+ public static void main(String args[]) {
+
+ long sumInf = 0;
+ long sumRes = 0;
+
+ for (long i = 0 ; i < NUM_ITERATIONS ; i++) {
+ //Every second iteration, sumInf becomes 0
+ sumInf += (long) negInfinity;
+
+ //Some extra work for compilers to make this
+ //loop seem important
+ if (sumInf == Long.MIN_VALUE) {
+ sumRes++;
+ }
+ }
+
+ if (sumRes == NUM_ITERATIONS / 2) {
+ System.out.println("Result is as expected");
+ } else {
+ System.out.println("Conversions failed over " + NUM_ITERATIONS + " iterations");
+ }
+ }
+}