use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class KotlinEvaluatorTest method returnFromFunction.
@Test
public void returnFromFunction() throws Exception {
// given
String code = "" + "val a = 2.2\n" + "val b = 14\n" + "\n" + "val f = {x: Double -> a*x + b}\n" + "\n" + "println(f(2.0))\n" + "f(2.0)";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = evaluator.evaluate(seo, code);
// then
assertThat((Double) evaluate.result()).isEqualTo(18.4);
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class KotlinEvaluatorTest method javaImports_shouldBeAdjustedForKotlin.
@Test
public void javaImports_shouldBeAdjustedForKotlin() throws Exception {
// given
Map<String, Object> paramMap = new HashMap<>();
// This import tests both "static" removal and "object" escaping.
List<String> imports = asList("import static com.twosigma.beakerx.kotlin.evaluator.object.ImportTestHelper.staticMethod");
paramMap.put(IMPORTS, imports);
EvaluatorParameters kernelParameters = new EvaluatorParameters(paramMap);
// when
evaluator.setShellOptions(kernelParameters);
String code = "val x = staticMethod()";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
TryResult evaluate = evaluator.evaluate(seo, code);
// then
assertThat(evaluate.result()).isNull();
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class SQLEvaluatorTest method evaluateSql.
@Test
public void evaluateSql() throws Exception {
// given
SimpleEvaluationObject seo = new SimpleEvaluationObject(SQLForColorTable.CREATE_AND_SELECT_ALL);
// when
TryResult evaluate = sqlEvaluator.evaluate(seo, seo.getExpression());
// then
verifyResult(evaluate);
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class JavaEvaluatorTest method onlyPackage.
@Test
public void onlyPackage() throws Exception {
// given
String code = "package beaker.test;";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = javaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.result()).isNull();
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class JavaEvaluatorTest method noCode.
@Test
public void noCode() throws Exception {
// given
String code = "";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = javaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate).isNotNull();
}
Aggregations