use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class KotlinEvaluatorTest method executePlot.
@Test
public void executePlot() throws Exception {
// given
String code = "" + "import com.twosigma.beakerx.chart.xychart.*\n" + "val plot = Plot()";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = evaluator.evaluate(seo, code);
// then
assertThat(evaluate.result()).isNull();
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class ScalaCodeRunner method call.
@Override
public TryResult call() throws Exception {
TryResult either;
try {
theOutput.setOutputHandler();
InternalVariable.setValue(theOutput);
either = scalaEvaluator.getShell().evaluate(theOutput, theCode);
} catch (Throwable e) {
if (e instanceof InterruptedException || e instanceof InvocationTargetException || e instanceof ThreadDeath) {
either = TryResult.createError(INTERUPTED_MSG);
} else {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
either = TryResult.createError(sw.toString());
}
} finally {
theOutput.clrOutputHandler();
}
return either;
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class ScalaWorkerThread method call.
@Override
public TryResult call() throws Exception {
NamespaceClient nc = null;
TryResult either;
try {
j.outputObject.started();
nc = NamespaceClient.getBeaker(scalaEvaluator.getSessionId());
nc.setOutputObj(j.outputObject);
either = scalaEvaluator.executeTask(new ScalaCodeRunner(scalaEvaluator, j.codeToBeExecuted, j.outputObject));
if (nc != null) {
nc.setOutputObj(null);
nc = null;
}
} catch (Throwable e) {
e.printStackTrace();
either = TryResult.createError(e.getMessage());
} finally {
if (nc != null) {
nc.setOutputObj(null);
nc = null;
}
}
return either;
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class SQLEvaluatorTest method insertsShouldReturnOutputCellHIDDEN.
@Test
public void insertsShouldReturnOutputCellHIDDEN() throws Exception {
// given
SimpleEvaluationObject seo = new SimpleEvaluationObject(SQLForColorTable.CREATE);
// when
TryResult evaluate = sqlEvaluator.evaluate(seo, seo.getExpression());
// then
verifyInsertResult(evaluate);
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class EvaluatorBaseTest method shouldCreateErrorResultWithArithmeticExceptionWhenDivisionByZero.
@Test
public void shouldCreateErrorResultWithArithmeticExceptionWhenDivisionByZero() throws Exception {
// given
String code = codeForDivisionByZero();
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult either = evaluator().evaluate(seo, code);
// then
assertThat(either.error()).contains(textAssertionForDivisionByZero());
}
Aggregations