langtools/test/jdk/jshell/CommandCompletionTest.java
changeset 41635 cb3d04878117
parent 40765 6f9556cf4404
child 42265 b36ad5a64e75
equal deleted inserted replaced
41634:3f9c491b05aa 41635:cb3d04878117
    52 @Test
    52 @Test
    53 public class CommandCompletionTest extends ReplToolTesting {
    53 public class CommandCompletionTest extends ReplToolTesting {
    54 
    54 
    55     public void testCommand() {
    55     public void testCommand() {
    56         assertCompletion("/deb|", false);
    56         assertCompletion("/deb|", false);
    57         assertCompletion("/re|", false, "/reload ", "/reset ", "/retain ");
    57         assertCompletion("/re|", false, "/reload ", "/reset ");
    58         assertCompletion("/h|", false, "/help ", "/history ");
    58         assertCompletion("/h|", false, "/help ", "/history ");
    59     }
    59     }
    60 
    60 
    61     public void testList() {
    61     public void testList() {
    62         test(false, new String[] {"--no-startup"},
    62         test(false, new String[] {"--no-startup"},
   193                 a -> assertCompletion(a, "/set tr|", false, "truncation "),
   193                 a -> assertCompletion(a, "/set tr|", false, "truncation "),
   194                 a -> assertCompletion(a, "/set tr |", false, modes)
   194                 a -> assertCompletion(a, "/set tr |", false, modes)
   195         );
   195         );
   196     }
   196     }
   197 
   197 
   198     public void testRetain() throws IOException {
       
   199         List<String> p1 = listFiles(Paths.get(""));
       
   200         FileSystems.getDefault().getRootDirectories().forEach(s -> p1.add(s.toString()));
       
   201         Collections.sort(p1);
       
   202 
       
   203         String[] modes = {"concise ", "normal ", "silent ", "verbose "};
       
   204         test(false, new String[] {"--no-startup"},
       
   205                 a -> assertCompletion(a, "/ret|", false, "/retain "),
       
   206                 a -> assertCompletion(a, "/retain |", false, "editor ", "feedback ", "mode ", "start "),
       
   207 
       
   208                 // /retain editor
       
   209                 a -> assertCompletion(a, "/retain e|", false, "editor "),
       
   210                 a -> assertCompletion(a, "/retain editor |", false, p1.toArray(new String[p1.size()])),
       
   211 
       
   212                 // /retain feedback
       
   213                 a -> assertCompletion(a, "/retain fe|", false, "feedback "),
       
   214                 a -> assertCompletion(a, "/retain fe |", false, modes),
       
   215 
       
   216                 // /retain mode
       
   217                 a -> assertCompletion(a, "/retain mo|", false, "mode "),
       
   218                 a -> assertCompletion(a, "/retain mo |", false, modes),
       
   219 
       
   220                 // /retain start
       
   221                 a -> assertCompletion(a, "/retain st|", false, "start "),
       
   222                 a -> assertCompletion(a, "/retain st |", false, p1.toArray(new String[p1.size()]))
       
   223         );
       
   224     }
       
   225 
       
   226     private void createIfNeeded(Path file) throws IOException {
   198     private void createIfNeeded(Path file) throws IOException {
   227         if (!Files.exists(file))
   199         if (!Files.exists(file))
   228             Files.createFile(file);
   200             Files.createFile(file);
   229     }
   201     }
   230     private List<String> listFiles(Path path) throws IOException {
   202     private List<String> listFiles(Path path) throws IOException {