2017-02-22 14:11:40 -05:00
|
|
|
package fixture;
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
|
|
|
import interpreter.*;
|
|
|
|
|
|
|
|
public class LispInterpreterFixture {
|
|
|
|
|
2017-02-27 12:00:24 -05:00
|
|
|
private static ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
|
private static LispInterpreter interpreter = null;
|
2017-02-22 14:11:40 -05:00
|
|
|
|
2017-02-27 12:00:24 -05:00
|
|
|
static {
|
2017-02-22 14:11:40 -05:00
|
|
|
LispInterpreterBuilder builder = LispInterpreterBuilderImpl.getInstance();
|
|
|
|
builder.setOutput(new PrintStream(outputStream));
|
|
|
|
builder.setErrorOutput(new PrintStream(outputStream));
|
|
|
|
builder.setNotInteractive();
|
2017-02-27 12:00:24 -05:00
|
|
|
builder.setTerminationFunction(() -> {});
|
|
|
|
builder.setErrorTerminationFunction(() -> {});
|
2017-02-22 14:11:40 -05:00
|
|
|
|
2017-02-27 12:00:24 -05:00
|
|
|
interpreter = builder.build();
|
2017-02-22 14:11:40 -05:00
|
|
|
}
|
|
|
|
|
2017-02-24 11:07:06 -05:00
|
|
|
public String evaluate(String input) throws IOException {
|
2017-02-26 12:31:27 -05:00
|
|
|
interpreter.setInput(new ByteArrayInputStream(input.getBytes()), "fitnesse");
|
2017-02-22 14:11:40 -05:00
|
|
|
interpreter.interpret();
|
|
|
|
String output = outputStream.toString();
|
|
|
|
outputStream.reset();
|
2017-02-24 11:07:06 -05:00
|
|
|
|
|
|
|
return output.trim();
|
2017-02-22 14:11:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|