Search in sources :

Example 81 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class ScalaAutocompleteTest method autocomplete_multiLineOffsetCorrect.

@Test
public void autocomplete_multiLineOffsetCorrect() throws Exception {
    // when
    AutocompleteResult autocomplete = scalaEvaluator.autocomplete("val x = 3\nval numbers = Li", 26);
    // then
    Assertions.assertThat(autocomplete.getMatches()).isNotEmpty();
    Assertions.assertThat(autocomplete.getStartIndex()).isEqualTo(24);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

Example 82 with AutocompleteResult

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

Example 83 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class ScalaAutocompleteTest method autocomplete_namespaceShouldNotBeModified.

@Test
public void autocomplete_namespaceShouldNotBeModified() {
    final String input1 = "val xyzzy = 32\nval xyz";
    // when
    AutocompleteResult autocomplete1 = scalaEvaluator.autocomplete(input1, input1.length());
    AutocompleteResult autocomplete2 = scalaEvaluator.autocomplete("xyz", 3);
    // then
    Assertions.assertThat(autocomplete2.getMatches()).isEmpty();
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

Example 84 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class ClojureAutocompleteTest method autocomplete_autocompleteResultNotEmpty.

@Test
public void autocomplete_autocompleteResultNotEmpty() throws Exception {
    // when
    AutocompleteResult autocomplete = clojureEvaluator.autocomplete("def", 3);
    // then
    Assertions.assertThat(autocomplete.getMatches()).isNotEmpty();
    Assertions.assertThat(autocomplete.getStartIndex()).isEqualTo(0);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) Test(org.junit.Test)

Example 85 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class JavaEvaluatorAutocompleteClassNameExpressionTest method autocompleteToClassWithPackage.

@Test
public void autocompleteToClassWithPackage() throws Exception {
    String code = "SimpleDateFor f = new java.text.SimpleDateFor";
    // when
    AutocompleteResult autocomplete = evaluator().autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(code.length() - 13);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Aggregations

AutocompleteResult (com.twosigma.beakerx.autocomplete.AutocompleteResult)107 Test (org.junit.Test)102 Ignore (org.junit.Ignore)20 BaseEvaluator (com.twosigma.beakerx.evaluator.BaseEvaluator)10 Collectors (java.util.stream.Collectors)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)10 AfterClass (org.junit.AfterClass)10 BeforeClass (org.junit.BeforeClass)10 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)6 KERNEL_PARAMETERS (com.twosigma.beakerx.evaluator.EvaluatorTest.KERNEL_PARAMETERS)6 EvaluatorTest.getTestTempFolderFactory (com.twosigma.beakerx.evaluator.EvaluatorTest.getTestTempFolderFactory)6 TestBeakerCellExecutor.cellExecutor (com.twosigma.beakerx.evaluator.TestBeakerCellExecutor.cellExecutor)6 JavaEvaluator (com.twosigma.beakerx.javash.evaluator.JavaEvaluator)6 KernelTest (com.twosigma.beakerx.KernelTest)4 AutocompleteCandidate (com.twosigma.beakerx.autocomplete.AutocompleteCandidate)4 TestGroovyEvaluator (com.twosigma.beakerx.groovy.TestGroovyEvaluator)4 ArrayList (java.util.ArrayList)4 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)2 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)2 Lexer (org.antlr.v4.runtime.Lexer)2