Search in sources :

Example 96 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method shouldReturnResultEqualToParamString.

@Test
public void shouldReturnResultEqualToParamString() throws Exception {
    String code = "def paramString = 'str'\n" + "println \"test ${par";
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches().get(0)).isEqualToIgnoringCase("paramString");
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 97 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method autocompleteMatchesForSystemAfterDot.

@Test
public void autocompleteMatchesForSystemAfterDot() throws Exception {
    String code = "System.";
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 98 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method shouldReturnResultEqualToToString.

@Test
public void shouldReturnResultEqualToToString() throws Exception {
    String code = "def v = 'str'\nv.toS";
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches().get(0)).isEqualToIgnoringCase("toString");
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 99 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method autocompleteForClass_shouldReturnResultEqualToCoordinates.

@Test
public void autocompleteForClass_shouldReturnResultEqualToCoordinates() throws Exception {
    String code = "class Coordinates {\n" + "double latitude\n" + "double longitude }\n" + "def coordinates = new Coordinates(latitude: 43.23, longitude: 3.67)\n" + "this.class.co";
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches().get(0)).isEqualToIgnoringCase("coordinates");
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 100 with AutocompleteResult

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

the class GroovyEvaluatorAutocompleteTest method autocompleteToMethodsForImportedClassesSeparatedByNewLine.

@Test
public void autocompleteToMethodsForImportedClassesSeparatedByNewLine() throws Exception {
    String code = "import com.twosigma.beakerx.mimetype.MIMEContainer\n" + "import groovy.json.JsonSlurper\n" + "def jsonSlurper = new JsonSlurper()\n" + "def json = jsonSlurper.";
    // when
    AutocompleteResult autocomplete = groovyEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(code.length());
}
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