Search in sources :

Example 56 with SimpleEvaluationObject

use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.

the class GroovyEvaluatorPassingSimpleEvaluationObjectTest method shouldPassSimpleEvaluationObjectToShell.

@Test
public void shouldPassSimpleEvaluationObjectToShell() throws Exception {
    // given
    String code = "" + "import com.twosigma.beakerx.evaluator.InternalVariable\n" + "InternalVariable.getParentHeader()";
    SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
    Message message = new Message();
    seo.setJupyterMessage(message);
    // when
    TryResult evaluate = groovyEvaluator.evaluate(seo, code);
    // then
    assertThat(evaluate.result()).isEqualTo(message);
}
Also used : Message(com.twosigma.beakerx.message.Message) TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test)

Example 57 with SimpleEvaluationObject

use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject in project beakerx by twosigma.

the class GroovyEvaluatorStackTraceTest method arithmeticException.

@Test
public void arithmeticException() throws Exception {
    String code = "1/0";
    SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
    // when
    TryResult evaluate = groovyEvaluator.evaluate(seo, code);
    // then
    assertThat(evaluate.isError()).isTrue();
    assertThat(evaluate.error()).contains("at this cell line 1");
}
Also used : TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test)

Aggregations

SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)57 TryResult (com.twosigma.beakerx.TryResult)37 Test (org.junit.Test)33 Message (com.twosigma.beakerx.message.Message)9 KernelTest (com.twosigma.beakerx.KernelTest)7 PlainCode.createSimpleEvaluationObject (com.twosigma.beakerx.kernel.PlainCode.createSimpleEvaluationObject)5 HashMap (java.util.HashMap)4 EvaluatorParameters (com.twosigma.beakerx.kernel.EvaluatorParameters)3 MagicCommandOutput (com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutput)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ExecutionException (java.util.concurrent.ExecutionException)3 Plot (com.twosigma.beakerx.chart.xychart.Plot)2 MagicCommandOutcomeItem (com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutcomeItem)2 MessageHolder (com.twosigma.beakerx.kernel.msg.MessageHolder)2 ThreadMXBean (java.lang.management.ThreadMXBean)2 Before (org.junit.Before)2 AutocompleteResult (com.twosigma.beakerx.autocomplete.AutocompleteResult)1 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)1 Code (com.twosigma.beakerx.kernel.Code)1 KernelFunctionality (com.twosigma.beakerx.kernel.KernelFunctionality)1