Search in sources :

Example 26 with SimpleEvaluationObject

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

the class EvaluatorBaseTest method returnHelloString.

@Test
public void returnHelloString() throws Exception {
    // given
    String code = codeForHello();
    SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
    // when
    TryResult result = evaluator().evaluate(seo, code);
    // then
    assertThat((String) result.result()).contains("Hello");
}
Also used : TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test)

Example 27 with SimpleEvaluationObject

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

the class EvaluatorBaseTest method returnPrintln.

@Test
public void returnPrintln() throws Exception {
    // given
    String code = codeForPrintln();
    SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
    // when
    TryResult result = evaluator().evaluate(seo, code);
    // then
    assertThat((String) result.result()).isNull();
}
Also used : TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test)

Example 28 with SimpleEvaluationObject

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

the class SQLAutocompleteTest method givenColorTable.

private void givenColorTable() {
    SimpleEvaluationObject seo = new SimpleEvaluationObject(SQLForColorTable.CREATE_AND_SELECT_ALL);
    sqlEvaluator.evaluate(seo, SQLForColorTable.CREATE_AND_SELECT_ALL);
}
Also used : SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)

Example 29 with SimpleEvaluationObject

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

the class SQLCodeRunner method call.

@Override
public TryResult call() throws Exception {
    TryResult either;
    try {
        InternalVariable.setValue(simpleEvaluationObject);
        Object r = sqlEvaluator.executeQuery(simpleEvaluationObject.getExpression(), namespaceClient, sqlEvaluator.defaultConnectionString, sqlEvaluator.namedConnectionString);
        either = TryResult.createResult(r);
    } catch (SQLException e) {
        either = TryResult.createError(e.toString());
    } catch (ThreadDeath e) {
        either = TryResult.createError(INTERUPTED_MSG);
    } catch (ReadVariableException e) {
        either = TryResult.createError(e.getMessage());
    } catch (Throwable e) {
        logger.error(e.getMessage());
        either = TryResult.createError(e.toString());
    }
    return either;
}
Also used : SQLException(java.sql.SQLException) TryResult(com.twosigma.beakerx.TryResult) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) ReadVariableException(com.twosigma.beakerx.sql.ReadVariableException)

Example 30 with SimpleEvaluationObject

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

the class KotlinEvaluatorTest method handleErrors.

@Test
public void handleErrors() throws Exception {
    // given
    String code = "val plot = UndefinedPlot()";
    SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
    // when
    TryResult evaluate = evaluator.evaluate(seo, code);
    // then
    assertThat(evaluate.error()).contains("unresolved reference: UndefinedPlot");
}
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