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
diff --git a/test/618-checker-induction/src/Main.java b/test/618-checker-induction/src/Main.java
index 2d9daf1..0080ffa 100644
--- a/test/618-checker-induction/src/Main.java
+++ b/test/618-checker-induction/src/Main.java
@@ -468,6 +468,19 @@
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 @@
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));