langtools/test/jdk/jshell/HistoryTest.java
author rfield
Tue, 20 Dec 2016 13:42:13 -0800
changeset 42843 a8d83044a192
parent 42407 f3702cff2933
child 44683 610dc2b48954
permissions -rw-r--r--
8170162: jshell tool: no mechanism to programmatically launch 8170044: jshell tool: jshell missing from javax.tools.ToolProvider Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     1
/*
38521
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     4
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     8
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    14
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    18
 *
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    21
 * questions.
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    22
 */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    23
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    24
/*
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    25
 * @test
41249
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
    26
 * @bug 8166744
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    27
 * @summary Test Completion
38521
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    28
 * @modules jdk.internal.le/jdk.internal.jline.extra
42407
f3702cff2933 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41249
diff changeset
    29
 *          jdk.jshell/jdk.internal.jshell.tool:+open
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    30
 * @build HistoryTest
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    31
 * @run testng HistoryTest
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    32
 */
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    33
38521
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    34
import java.lang.reflect.Field;
42843
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    35
import java.util.Locale;
38521
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    36
import jdk.internal.jline.extra.EditingHistory;
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    37
import org.testng.annotations.Test;
42843
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    38
import jdk.internal.jshell.tool.JShellTool;
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    39
import jdk.internal.jshell.tool.JShellToolBuilder;
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    40
import static org.testng.Assert.*;
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    41
38521
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    42
public class HistoryTest extends ReplToolTesting {
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    43
42843
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    44
    private JShellTool repl;
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    45
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    46
    @Override
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    47
    protected void testRawRun(Locale locale, String[] args) {
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    48
        repl = ((JShellToolBuilder) builder(locale))
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    49
                .rawTool();
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    50
        try {
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    51
            repl.start(args);
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    52
        } catch (Exception ex) {
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    53
            fail("Repl tool died with exception", ex);
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    54
        }
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    55
    }
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    56
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    57
    @Test
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    58
    public void testHistory() {
38521
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    59
        test(
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    60
             a -> {if (!a) setCommandInput("void test() {\n");},
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    61
             a -> {if (!a) setCommandInput("    System.err.println(1);\n");},
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    62
             a -> {if (!a) setCommandInput("    System.err.println(1);\n");},
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    63
             a -> {assertCommand(a, "} //test", "|  created method test()");},
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    64
             a -> {
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    65
                 if (!a) {
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    66
                     try {
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    67
                         previousAndAssert(getHistory(), "} //test");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    68
                         previousSnippetAndAssert(getHistory(), "void test() {");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    69
                     } catch (Exception ex) {
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    70
                         throw new IllegalStateException(ex);
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    71
                     }
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    72
                 }
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    73
                 assertCommand(a, "int dummy;", "dummy ==> 0");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    74
             });
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    75
        test(
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    76
             a -> {if (!a) setCommandInput("void test2() {\n");},
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    77
             a -> {assertCommand(a, "} //test2", "|  created method test2()");},
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    78
             a -> {
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    79
                 if (!a) {
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    80
                     try {
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    81
                         previousAndAssert(getHistory(), "} //test2");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    82
                         previousSnippetAndAssert(getHistory(), "void test2() {");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    83
                         previousSnippetAndAssert(getHistory(), "/debug 0"); //added by test framework
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    84
                         previousSnippetAndAssert(getHistory(), "/exit");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    85
                         previousSnippetAndAssert(getHistory(), "int dummy;");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    86
                         previousSnippetAndAssert(getHistory(), "void test() {");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    87
                     } catch (Exception ex) {
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    88
                         throw new IllegalStateException(ex);
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    89
                     }
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    90
                 }
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    91
                 assertCommand(a, "int dummy;", "dummy ==> 0");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
    92
             });
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    93
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
    94
42843
a8d83044a192 8170162: jshell tool: no mechanism to programmatically launch
rfield
parents: 42407
diff changeset
    95
    @Test
41249
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
    96
    public void test8166744() {
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
    97
        test(
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
    98
             a -> {if (!a) setCommandInput("class C {\n");},
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
    99
             a -> {if (!a) setCommandInput("void f() {\n");},
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   100
             a -> {if (!a) setCommandInput("}\n");},
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   101
             a -> {assertCommand(a, "}", "|  created class C");},
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   102
             a -> {
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   103
                 if (!a) {
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   104
                     try {
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   105
                         previousAndAssert(getHistory(), "}");
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   106
                         previousAndAssert(getHistory(), "}");
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   107
                         previousAndAssert(getHistory(), "void f() {");
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   108
                         previousAndAssert(getHistory(), "class C {");
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   109
                         getHistory().add("class C{");
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   110
                     } catch (Exception ex) {
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   111
                         throw new IllegalStateException(ex);
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   112
                     }
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   113
                 }
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   114
                 assertCommand(a, "int dummy;", "dummy ==> 0");
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   115
             });
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   116
        test(
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   117
             a -> {if (!a) setCommandInput("class C {\n");},
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   118
             a -> {if (!a) setCommandInput("void f() {\n");},
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   119
             a -> {if (!a) setCommandInput("}\n");},
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   120
             a -> {assertCommand(a, "}", "|  created class C");},
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   121
             a -> {
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   122
                 if (!a) {
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   123
                     try {
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   124
                         previousSnippetAndAssert(getHistory(), "class C {");
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   125
                         getHistory().add("class C{");
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   126
                     } catch (Exception ex) {
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   127
                         throw new IllegalStateException(ex);
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   128
                     }
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   129
                 }
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   130
                 assertCommand(a, "int dummy;", "dummy ==> 0");
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   131
             });
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   132
    }
8c2aab77c2d2 8166744: JShell: java.lang.IndexOutOfBoundsException for legal history access
shinyafox
parents: 38521
diff changeset
   133
38521
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
   134
    private EditingHistory getHistory() throws Exception {
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
   135
        Field input = repl.getClass().getDeclaredField("input");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
   136
        input.setAccessible(true);
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
   137
        Object console = input.get(repl);
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
   138
        Field history = console.getClass().getDeclaredField("history");
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
   139
        history.setAccessible(true);
f2fe39ab9256 8133549: Generalize jshell's EditingHistory
jlahoda
parents: 35359
diff changeset
   140
        return (EditingHistory) history.get(console);
33362
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   141
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   142
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   143
    private void previousAndAssert(EditingHistory history, String expected) {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   144
        assertTrue(history.previous());
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   145
        assertEquals(history.current().toString(), expected);
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   146
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   147
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   148
    private void previousSnippetAndAssert(EditingHistory history, String expected) {
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   149
        assertTrue(history.previousSnippet());
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   150
        assertEquals(history.current().toString(), expected);
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   151
    }
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   152
65ec6de1d6b4 8134254: JShell API/tool: REPL for Java into JDK9
jlahoda
parents:
diff changeset
   153
}