@@ -97,6 +97,35 @@ public void testScriptModuleValue() throws Exception {
9797 assertEquals (context , info .context ());
9898 }
9999
100+ @ Test
101+ public void testAutoCompleter () {
102+ final ScriptLanguage hello = scriptService .getLanguageByName ("Hello" );
103+ final ScriptEngine engine = hello .getScriptEngine ();
104+ final AutoCompleter ac = hello .getAutoCompleter ();
105+
106+ // test all matches
107+ engine .put ("thing" , new Object ());
108+ final AutoCompletionResult result = ac .autocomplete ("thing." , engine );
109+ assertEquals (0 , result .getStartIndex ());
110+ final List <String > matches = result .getMatches ();
111+ final List <String > expected = Arrays .asList ("thing.equals(" ,
112+ "thing.getClass(" , "thing.hashCode(" , "thing.notify(" , "thing.notifyAll(" ,
113+ "thing.toString(" , "thing.wait(" );
114+ assertEquals (matches , expected );
115+
116+ // test prefix
117+ engine .put ("hello" , "world" );
118+ final AutoCompletionResult cWords = ac .autocomplete ("hello.c" , engine );
119+ assertEquals (0 , cWords .getStartIndex ());
120+ final List <String > cMatches = cWords .getMatches ();
121+ final List <String > cExpected = Arrays .asList ("hello.CASE_INSENSITIVE_ORDER" ,
122+ "hello.charAt(" , "hello.chars(" , "hello.codePointAt(" ,
123+ "hello.codePointBefore(" , "hello.codePointCount(" , "hello.codePoints(" ,
124+ "hello.compareTo(" , "hello.compareToIgnoreCase(" , "hello.concat(" ,
125+ "hello.contains(" , "hello.contentEquals(" , "hello.copyValueOf(" );
126+ assertEquals (cMatches , cExpected );
127+ }
128+
100129 @ Plugin (type = ScriptLanguage .class )
101130 public static class Rot13 extends AbstractScriptLanguage {
102131
0 commit comments