From b74013c0b5802f903a94aea9d20b1b6d7a5c70d7 Mon Sep 17 00:00:00 2001
From: Snigdha Saha <snigdhas2572@gmail.com>
Date: Thu, 23 Feb 2023 14:20:04 -0800
Subject: [PATCH] more thorough program testing

---
 tests/edu/caltech/cs2/project06/ProgramTests.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tests/edu/caltech/cs2/project06/ProgramTests.java b/tests/edu/caltech/cs2/project06/ProgramTests.java
index 3ace3fd..02f27d1 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));
         }
     }
 }
-- 
GitLab