package acceptance.fixture; import static table.FunctionTable.resetFunctionTable; import java.io.*; import interpreter.*; import table.ExecutionContext; public class LispInterpreterFixture { private static ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); private static LispInterpreter interpreter = null; static { LispInterpreterBuilder builder = LispInterpreterBuilderImpl.getInstance(); builder.setOutput(new PrintStream(outputStream)); builder.setErrorOutput(new PrintStream(outputStream)); builder.setNotInteractive(); builder.setTerminationFunction(() -> {}); builder.setErrorTerminationFunction(() -> {}); interpreter = builder.build(); } public void reset() { resetFunctionTable(); ExecutionContext.getInstance().clearContext(); } public String evaluate(String input) throws IOException { interpreter.setInput(new ByteArrayInputStream(input.getBytes()), "fitnesse"); interpreter.interpret(); String output = outputStream.toString(); outputStream.reset(); return output.trim(); } }