Search in sources :

Example 26 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method shouldReturnClass.

@Test
public void shouldReturnClass() throws Exception {
    String code = "cla";
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches().get(0)).isEqualTo("class");
    assertThat(autocomplete.getStartIndex()).isEqualTo(0);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 27 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method shouldReturnPrintlnForSecondLine.

@Test
public void shouldReturnPrintlnForSecondLine() throws Exception {
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete("System.out.printl\n" + "System.out.print\n" + "System.out.prin\n" + "System.out.pri\n", 34);
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(29);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 28 with AutocompleteResult

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

the class JavaEvaluatorAutocompleteTest method shouldReturnClass.

@Test
public void shouldReturnClass() throws Exception {
    String code = "cla";
    // when
    AutocompleteResult autocomplete = evaluator().autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches().size()).isGreaterThan(0);
    assertThat(autocomplete.getMatches().stream().filter(x -> x.contains("class")).collect(Collectors.toList())).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(0);
}
Also used : JavaEvaluator(com.twosigma.beakerx.javash.evaluator.JavaEvaluator) AfterClass(org.junit.AfterClass) BaseEvaluator(com.twosigma.beakerx.evaluator.BaseEvaluator) EvaluatorTest.getTestTempFolderFactory(com.twosigma.beakerx.evaluator.EvaluatorTest.getTestTempFolderFactory) BeforeClass(org.junit.BeforeClass) Ignore(org.junit.Ignore) KERNEL_PARAMETERS(com.twosigma.beakerx.evaluator.EvaluatorTest.KERNEL_PARAMETERS) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TestBeakerCellExecutor.cellExecutor(com.twosigma.beakerx.evaluator.TestBeakerCellExecutor.cellExecutor) Test(org.junit.Test) Collectors(java.util.stream.Collectors) AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 29 with AutocompleteResult

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

the class JavaEvaluatorAutocompleteTest method autocompleteShouldNotMatchForEmptyString.

@Test
public void autocompleteShouldNotMatchForEmptyString() throws Exception {
    String code = "";
    // when
    AutocompleteResult autocomplete = evaluator().autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(0);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 30 with AutocompleteResult

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

the class JavaEvaluatorAutocompleteTest method shouldAutocompleteWithAsterisk.

@Test
public void shouldAutocompleteWithAsterisk() throws Exception {
    String code = "import java.awt.*;\n" + "System.out.println( Color.B";
    // when
    AutocompleteResult autocomplete = evaluator().autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(code.length() - 1);
}
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