use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class JavaEvaluatorTest method singleImport.
@Test
public void singleImport() throws Exception {
// given
String code = "import java.util.Date;";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = javaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.result()).isNull();
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class JavaEvaluatorTest method evaluateVoid.
@Test
public void evaluateVoid() throws Exception {
// given
String code = "System.out.println(\"Hello\");";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = javaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.result()).isNull();
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class ScalaEvaluatorTest method incompleteInput_shouldBeDetected.
@Test
public void incompleteInput_shouldBeDetected() throws Exception {
// given
String code = "1 to 10 map { i => i * 2";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = scalaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.error()).contains("incomplete");
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class ScalaEvaluatorTest method displayTable.
@Test
public void displayTable() throws Exception {
// given
String code = "val table = new TableDisplay(new CSV().readFile(\"src/test/resources/tableRowsTest.csv\"))\n" + "table";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = scalaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.result() instanceof DisplayableWidget).isTrue();
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class BaseEvaluator method evaluate.
protected TryResult evaluate(SimpleEvaluationObject seo, Callable<TryResult> callable) {
Future<TryResult> submit = executorService.submit(callable);
TryResult either = null;
try {
either = submit.get();
} catch (Exception e) {
either = TryResult.createError(e.getLocalizedMessage());
}
return either;
}
Aggregations