summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aart Bik <ajcbik@google.com> 2017-05-05 11:07:34 -0700
committer Aart Bik <ajcbik@google.com> 2017-05-08 08:39:25 -0700
commit89112da43c9f178c0582d9f3b13107796a7a6d79 (patch)
tree7f022b349775dcc0b7aca1c7ffb30427a5ea1d6a
parent59cd177687681ff9a1bd4b005e77f2a15e290641 (diff)
Extra test on coupled induction.
Rationale: I had this test lying around to make sure a coupled induction is never optimized incorrectly. Not really targeted to anything in particular, but good to have in our suite. Test: test-art-host Change-Id: I0d50c476c0012f4509a10ed56598dc33572a0e2e
-rw-r--r--test/618-checker-induction/src/Main.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/618-checker-induction/src/Main.java b/test/618-checker-induction/src/Main.java
index 2d9daf1d43..0080ffa464 100644
--- a/test/618-checker-induction/src/Main.java
+++ b/test/618-checker-induction/src/Main.java
@@ -468,6 +468,19 @@ public class Main {
return sum;
}
+ // Ensure double induction does not "overshoot" the subscript range.
+ private static int getIncr2(int[] arr) {
+ for (int i = 0; i < 12; ) {
+ arr[i++] = 30;
+ arr[i++] = 29;
+ }
+ int sum = 0;
+ for (int i = 0; i < 12; i++) {
+ sum += arr[i];
+ }
+ return sum;
+ }
+
// TODO: handle as closed/empty eventually?
static int mainIndexReturnedN(int n) {
int i;
@@ -869,6 +882,7 @@ public class Main {
expectEquals(1, periodicReturned9());
expectEquals(0, periodicReturned10());
expectEquals(21, getSum21());
+ expectEquals(354, getIncr2(new int[12]));
for (int n = -4; n < 4; n++) {
int tc = (n <= 0) ? 0 : n;
expectEquals(tc, mainIndexReturnedN(n));