ForLoop { public static ForLoop execute(int[] sizes, Body body) { final ForLoop forLoop = new ForLoop(sizes); forLoop.execute(body); return forLoop; } ForLoop(int[] sizes); static ForLoop execute(int[] sizes, Body body); ForLoop execute(Body body);  }
@Test public void test0D() throws Exception { final TestBody body = new TestBody(); ForLoop.execute(new int[]{}, body); assertEquals(0, body.indexesList.size()); }
@Test public void test1D() throws Exception { final TestBody body = new TestBody(); ForLoop.execute(new int[]{3}, body); assertEquals(3, body.indexesList.size()); assertArrayEquals(new int[]{0}, body.indexesList.get(0)); assertArrayEquals(new int[]{1}, body.indexesList.get(1)); assertArrayEquals(new int[]{2}, body.indexesList.get(2)); }
@Test public void test2D() throws Exception { final TestBody body = new TestBody(); ForLoop.execute(new int[]{2, 3}, body); assertEquals(2 * 3, body.indexesList.size()); assertArrayEquals(new int[]{0, 0}, body.indexesList.get(0)); assertArrayEquals(new int[]{0, 1}, body.indexesList.get(1)); assertArrayEquals(new int[]{0, 2}, body.indexesList.get(2)); assertArrayEquals(new int[]{1, 0}, body.indexesList.get(3)); assertArrayEquals(new int[]{1, 1}, body.indexesList.get(4)); assertArrayEquals(new int[]{1, 2}, body.indexesList.get(5)); }
@Test public void test3D() throws Exception { final TestBody body = new TestBody(); ForLoop.execute(new int[]{2, 2, 3}, body); assertEquals(2 * 2 * 3, body.indexesList.size()); assertArrayEquals(new int[]{0, 0, 0}, body.indexesList.get(0)); assertArrayEquals(new int[]{0, 0, 1}, body.indexesList.get(1)); assertArrayEquals(new int[]{0, 0, 2}, body.indexesList.get(2)); assertArrayEquals(new int[]{0, 1, 0}, body.indexesList.get(3)); assertArrayEquals(new int[]{0, 1, 1}, body.indexesList.get(4)); assertArrayEquals(new int[]{0, 1, 2}, body.indexesList.get(5)); assertArrayEquals(new int[]{1, 0, 0}, body.indexesList.get(6)); assertArrayEquals(new int[]{1, 0, 1}, body.indexesList.get(7)); assertArrayEquals(new int[]{1, 0, 2}, body.indexesList.get(8)); assertArrayEquals(new int[]{1, 1, 0}, body.indexesList.get(9)); assertArrayEquals(new int[]{1, 1, 1}, body.indexesList.get(10)); assertArrayEquals(new int[]{1, 1, 2}, body.indexesList.get(11)); }
@Test public void test6D() throws Exception { final TestBody body = new TestBody(); ForLoop.execute(new int[]{3, 2, 4, 2, 2, 3}, body); assertEquals(3 * 2 * 4 * 2 * 2 * 3, body.indexesList.size()); }