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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations