Search in sources :

Example 31 with SimpleEvaluationObject

use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject 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();
}
Also used : TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test)

Example 32 with SimpleEvaluationObject

use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject 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);
}
Also used : TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 33 with SimpleEvaluationObject

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

the class BeakerStdOutErrHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    BeakerStdOutErrHandler.init();
    stdout = new SimpleOutputHandlerTest();
    stderr = new SimpleErrHandlerTest();
    seo = new SimpleEvaluationObject("code", stdout, stderr);
    seo.setOutputHandler();
}
Also used : SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Before(org.junit.Before)

Example 34 with SimpleEvaluationObject

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

the class EvaluatorManagerTest method executeCode_callEvaluatorToEvaluate.

@Test
public void executeCode_callEvaluatorToEvaluate() {
    String code = "test code";
    SimpleEvaluationObject seo = PlainCode.createSimpleEvaluationObject(code, kernel, new Message(), 5);
    // when
    evaluatorManager.executeCode(code, seo);
    // then
    Assertions.assertThat(evaluator.getCode()).isEqualTo(code);
}
Also used : Message(com.twosigma.beakerx.message.Message) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 35 with SimpleEvaluationObject

use of com.twosigma.beakerx.jvm.object.SimpleEvaluationObject 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());
}
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