test/jdk/jdk/internal/jline/extra/HistoryTest.java
changeset 48987 513e98643998
parent 47216 71c04702a3d5
equal deleted inserted replaced
48986:3381b1e0713e 48987:513e98643998
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 8178821
    26  * @bug 8178821 8198670
    27  * @summary Test Completion
    27  * @summary Test Completion
    28  * @modules jdk.internal.le/jdk.internal.jline
    28  * @modules jdk.internal.le/jdk.internal.jline
    29  *          jdk.internal.le/jdk.internal.jline.console
    29  *          jdk.internal.le/jdk.internal.jline.console
    30  *          jdk.internal.le/jdk.internal.jline.console.history
    30  *          jdk.internal.le/jdk.internal.jline.console.history
    31  *          jdk.internal.le/jdk.internal.jline.extra
    31  *          jdk.internal.le/jdk.internal.jline.extra
   131 
   131 
   132         complete.set(true);  history.add("/*current1*/");
   132         complete.set(true);  history.add("/*current1*/");
   133         complete.set(true);  history.add("/*current2*/");
   133         complete.set(true);  history.add("/*current2*/");
   134         complete.set(true);  history.add("/*current3*/");
   134         complete.set(true);  history.add("/*current3*/");
   135 
   135 
   136         assertEquals(history.currentSessionEntries(), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/"));
   136         assertEquals(history.entries(true), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/"));
       
   137         assertEquals(history.entries(false), Arrays.asList(
       
   138                 "void test() {",
       
   139                 "    System.err.println(1);",
       
   140                 "}",
       
   141                 "/exit",
       
   142                 "void test() { /*changed*/",
       
   143                 "    System.err.println(2);",
       
   144                 "} /*changed*/",
       
   145                 "{",
       
   146                 "}",
       
   147                 "/*current1*/", "/*current2*/", "/*current3*/"), history.entries(false).toString());
   137 
   148 
   138         history.remove(0);
   149         history.remove(0);
   139 
   150 
   140         assertEquals(history.currentSessionEntries(), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/"));
   151         assertEquals(history.entries(true), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/"));
   141 
   152 
   142         while (history.size() > 2)
   153         while (history.size() > 2)
   143             history.remove(0);
   154             history.remove(0);
   144 
   155 
   145         assertEquals(history.currentSessionEntries(), Arrays.asList("/*current2*/", "/*current3*/"));
   156         assertEquals(history.entries(true), Arrays.asList("/*current2*/", "/*current3*/"));
   146 
   157 
   147         for (int i = 0; i < MemoryHistory.DEFAULT_MAX_SIZE * 2; i++) {
   158         for (int i = 0; i < MemoryHistory.DEFAULT_MAX_SIZE * 2; i++) {
   148             complete.set(true);  history.add("/exit");
   159             complete.set(true);  history.add("/exit");
   149         }
   160         }
   150 
   161