use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class EvaluatorBaseTest method shouldDivide16By2.
@Test
public void shouldDivide16By2() throws Exception {
// given
String code = codeForDivide16By2();
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult result = evaluator().evaluate(seo, code);
// then
assertThat(result.result().toString()).isEqualTo("8");
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class ScalaAutocompleteTest method autocomplete_interpretedResultsVisible.
@Test
public void autocomplete_interpretedResultsVisible() {
// This test needs a fresh ScalaEvaluator to modify without disturbing other tests
final ScalaEvaluator localEvaluator = new ScalaEvaluator("id", "sid", null, cellExecutor(), new NoBeakerxObjectTestFactory(), getTestTempFolderFactory(), EvaluatorTest.KERNEL_PARAMETERS);
try {
// when
localEvaluator.evaluate(new SimpleEvaluationObject(""), "val xyzzy = 32");
AutocompleteResult autocomplete = localEvaluator.autocomplete("xyz", 3);
// then
Assertions.assertThat(autocomplete.getMatches()).isNotEmpty();
} finally {
localEvaluator.exit();
}
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class ScalaEvaluatorTest method javaImports_shouldBeAdjustedForScala.
@Test
public void javaImports_shouldBeAdjustedForScala() throws Exception {
// given
Map<String, Object> paramMap = new HashMap<>();
// This import tests both "static" removal and "object" escaping.
List<String> imports = Arrays.asList("import static com.twosigma.beakerx.scala.evaluator.object.ImportTestHelper.staticMethod");
paramMap.put(IMPORTS, imports);
EvaluatorParameters kernelParameters = new EvaluatorParameters(paramMap);
// when
scalaEvaluator.setShellOptions(kernelParameters);
String code = "val x = staticMethod()";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
TryResult evaluate = scalaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.result()).isNull();
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class ScalaEvaluatorTest method evaluatePlot_shouldCreatePlotObject.
@Test
public void evaluatePlot_shouldCreatePlotObject() throws Exception {
// given
String code = "import com.twosigma.beakerx.chart.xychart.Plot;\n" + "val plot = new Plot();\n" + "plot.setTitle(\"test title\");";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = scalaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.result() instanceof Plot).isTrue();
assertThat(((Plot) evaluate.result()).getTitle()).isEqualTo("test title");
}
use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.
the class KotlinEvaluatorTest method evaluatePlot_shouldCreatePlotObject.
@Test
public void evaluatePlot_shouldCreatePlotObject() throws Exception {
// given
Map<String, Object> paramMap = new HashMap<>();
paramMap.put(IMPORTS, asList("import com.twosigma.beakerx.chart.xychart.*"));
evaluator.setShellOptions(new EvaluatorParameters(paramMap));
String code = "val plot = Plot()\n" + "plot.setTitle(\"test title\");\n" + "plot.display();";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = evaluator.evaluate(seo, code);
// then
assertThat(evaluate.result()).isNull();
}
Aggregations