Add extra unittests for inner while loops
@@ -682,4 +682,71 @@ public class TestLoops extends TornadoTestBase {
}
}
}
+
+ public static void whileLoop(int[] a, int size) {
+ for (@Parallel int i = 0; i < size; i++) {
+ int y = 0;
+ while (y < size) {
+ a[i * size + y] = 10;
+ y++;
+ }
+ }
+ }
+
+ @Test
+ public void testInnerWhileLoop() {
+ final int size = 100;
+
+ int[] a = new int[size * size];
+ Arrays.fill(a, 1);
+
+ //@formatter:off
+ new TaskSchedule("s0")
+ .task("t0", TestLoops::whileLoop, a, size)
+ .streamOut(a)
+ .execute();
+ //@formatter:on
+
+ for (int i = 0; i < size; i++) {
+ int y = 0;
+ while (y < size) {
+ assertEquals(10, a[i * size + y]);
+ y++;
+ }
+ }
+ }
+
+ public static void dowWhileLoop(int[] a, int size) {
+ for (@Parallel int i = 0; i < size; i++) {
+ int y = 1;
+ do {
+ a[i * size + y] = 10;
+ y++;
+ } while (y < size);
+ }
+ }
+
+ @Test
+ public void testInnerDoWhileLoop() {
+ final int size = 100;
+
+ int[] a = new int[size * size];
+ Arrays.fill(a, 1);
+
+ //@formatter:off
+ new TaskSchedule("s0")
+ .task("t0", TestLoops::whileLoop, a, size)
+ .streamOut(a)
+ .execute();
+ //@formatter:on
+
+ for (int i = 0; i < size; i++) {
+ int y = 0;
+ while (y < size) {
+ assertEquals(10, a[i * size + y]);
+ y++;
+ }
+ }
+
+ }
}
