Bring over the new tests from https://android-review.googlesource.com/#/c/38771/.
(The bug itself had already been fixed in art's compiler, because we always
run compiled code. I've also removed the JIT warmup code.)
Change-Id: I9d1d2b68f99dd06887146fdd05cb2e4537b4d5fc
diff --git a/test/083-compiler-regressions/expected.txt b/test/083-compiler-regressions/expected.txt
index abfd60f..e2846dd 100644
--- a/test/083-compiler-regressions/expected.txt
+++ b/test/083-compiler-regressions/expected.txt
@@ -9,3 +9,5 @@
wideGetterSetterTest passes
wideIdentityTest passes
returnConstantTest passes
+longDivTest passes
+longModTest passes
diff --git a/test/083-compiler-regressions/src/Main.java b/test/083-compiler-regressions/src/Main.java
index f3e84cc..4d6aca3 100644
--- a/test/083-compiler-regressions/src/Main.java
+++ b/test/083-compiler-regressions/src/Main.java
@@ -40,6 +40,8 @@
wideGetterSetterTest();
wideIdentityTest();
returnConstantTest();
+ ZeroTests.longDivTest();
+ ZeroTests.longModTest();
}
public static void returnConstantTest() {
diff --git a/test/083-compiler-regressions/src/ZeroTests.java b/test/083-compiler-regressions/src/ZeroTests.java
new file mode 100644
index 0000000..bd1a281
--- /dev/null
+++ b/test/083-compiler-regressions/src/ZeroTests.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+/**
+ * Tests long division by zero for both / and %.
+ */
+public class ZeroTests {
+ public static void longDivTest() throws Exception {
+ longTest("longDivTest", true);
+ }
+
+ public static void longModTest() throws Exception {
+ longTest("longModTest", false);
+ }
+
+ private static void longTest(String name, boolean divide) throws Exception {
+ try {
+ if (divide) {
+ longDiv(1, 0);
+ } else {
+ longMod(1, 0);
+ }
+ throw new AssertionError(name + " failed to throw");
+ } catch (ArithmeticException expected) {
+ System.out.println(name + " passes");
+ }
+ }
+
+ private static long longDiv(long lhs, long rhs) {
+ return lhs / rhs;
+ }
+
+ private static long longMod(long lhs, long rhs) {
+ return lhs % rhs;
+ }
+}