Skip to content

Commit

Permalink
Add completion candidate suffix test, #425
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Nov 7, 2020
1 parent 404565b commit 40c4d32
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions reader/src/test/java/org/jline/reader/impl/CompletionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
import java.io.IOException;
import java.util.Arrays;

import static java.util.Arrays.asList;
import org.jline.reader.Completer;
import org.jline.reader.*;
import org.jline.reader.LineReader.Option;
import org.jline.reader.Reference;
import org.jline.reader.impl.completer.AggregateCompleter;
import org.jline.reader.impl.completer.ArgumentCompleter;
import org.jline.reader.impl.completer.NullCompleter;
Expand Down Expand Up @@ -134,6 +132,35 @@ public void testCompletePrefix() throws Exception {
assertLine("read and nd", new TestBuffer("read and\033[D\033[D\t\n"));
}

@Test
public void testSuffix() {
reader.setCompleter((reader, line, candidates) -> {
candidates.add(new Candidate(
/* value = */ "range(",
/* displ = */ "range(",
/* group = */ null,
/* descr = */ null,
/* suffix = */ "(",
/* key = */ null,
/* complete = */ false));
candidates.add(new Candidate(
/* value = */ "strangeTest",
/* displ = */ "strangeTest",
/* group = */ null,
/* descr = */ null,
/* suffix = */ "Test",
/* key = */ null,
/* complete = */ false));
}
);
// DEFAULT_REMOVE_SUFFIX_CHARS = " \t\n;&|";

assertLine("range ;", new TestBuffer("r\t;\n"));
assertLine("range(1", new TestBuffer("r\t1\n"));
assertLine("strange ", new TestBuffer("s\t\n"));
assertLine("strangeTests", new TestBuffer("s\ts\n"));
}

@Test
public void testMenuOrder() {
reader.setCompleter(new StringsCompleter(Arrays.asList("ae_helloWorld1", "ad_helloWorld12", "ac_helloWorld1234", "ab_helloWorld123", "aa_helloWorld12345")));
Expand Down Expand Up @@ -161,4 +188,5 @@ public void testParserEofOnEscapedNewLine() {

assertLine("test ", new TestBuffer("test \\\t\n\n"));
}

}

0 comments on commit 40c4d32

Please sign in to comment.