diff --git a/tests/edu/caltech/cs2/project06/ProgramTests.java b/tests/edu/caltech/cs2/project06/ProgramTests.java index 3ace3fde17c08edc69436a2ee9168a7e4f3e0fd3..02f27d163092347018a8824b70fd9fc0358ab709 100644 --- a/tests/edu/caltech/cs2/project06/ProgramTests.java +++ b/tests/edu/caltech/cs2/project06/ProgramTests.java @@ -84,14 +84,14 @@ public class ProgramTests { return new Program(program); } - private void testProgram(Program program, int maxColors) { + private void testProgram(Program program, Program controlProgram, int maxColors) { NodeGraph interference = program.constructInterferenceGraph(); DSatur.color(interference); Program modified = program.color(interference.getColoring()); assertTrue(modified.variables().size() <= maxColors, "Interference graph coloring uses more colors than expected " + "(ie: more variables were connected by edges than expected)."); - assertIterableEquals(interpret(program), interpret(modified), "Interference graph does not validly " + assertIterableEquals(interpret(controlProgram), interpret(modified), "Interference graph does not validly " + " reflect interferences (ie: the resulting program overwrites its own variables)."); } @@ -99,14 +99,14 @@ public class ProgramTests { @Tag("A") @DisplayName("Test on 8-instruction program") public void testProgram1() { - testProgram(program1(), 3); + testProgram(program1(), program1(),3); } @Test @Tag("A") @DisplayName("Test on 10-instruction program") public void testProgram2(){ - testProgram(program2(), 3); + testProgram(program2(), program2(),3); } @Test @@ -116,7 +116,8 @@ public class ProgramTests { List<Integer> answers = List.of(2, 5, 2, 3, 3, 3, 2, 1, 4, 3, 2, 3, 3, 4, 2, 2, 4, 2, 3, 2, 2, 4, 2, 2, 3, 3, 3, 2, 4, 3, 4, 3, 2, 1, 4, 2, 2, 4, 3, 4, 2, 5, 3, 2, 3, 3, 3, 3, 3, 1, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 2, 2, 2, 2, 2, 3, 2, 2, 3, 3, 3, 2, 2, 3, 2, 2, 4, 2, 4, 3, 3, 2, 3, 4, 1, 2, 3, 2, 3, 1, 3, 3, 3, 2, 2, 2, 3, 2, 3, 4, 2, 4, 4, 4, 3, 5, 3, 5, 2, 3, 2, 2, 3, 2, 4, 2, 4, 2, 2, 3, 4, 2, 3, 3, 3, 4, 3, 3, 3, 4, 3, 2, 3, 2, 3, 4, 3, 3, 3, 4, 3, 3, 3, 2, 2, 3, 2); for (int seed = 1; seed < 150; seed++) { Program p = programGen(15, seed); - testProgram(p, answers.get(seed - 1)); + Program cP = programGen(15, seed); + testProgram(p, cP, answers.get(seed - 1)); } } }