test/langtools/jdk/jshell/ToolTabCommandTest.java
author mchung
Sat, 24 Feb 2018 09:41:42 -0800
changeset 48984 b5d1fb0701d4
parent 48275 b2190c70a1ac
child 52938 5ff7480c9e28
permissions -rw-r--r--
8198653: ClassLoader::getSystemClassLoader throws InternalError when called after shutdown Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
     1
/*
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
     4
 *
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
     8
 *
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    14
 *
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    18
 *
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    21
 * questions.
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    22
 */
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    23
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    24
/**
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    25
 * @test
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    26
 * @bug 8177076 8185840 8178109 8192863
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    27
 * @modules
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    28
 *     jdk.compiler/com.sun.tools.javac.api
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    29
 *     jdk.compiler/com.sun.tools.javac.main
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    30
 *     jdk.jshell/jdk.internal.jshell.tool.resources:open
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    31
 *     jdk.jshell/jdk.jshell:open
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    32
 * @library /tools/lib
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    33
 * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
44570
7fec4e13a5cf 8178077: jshell tool: crash on ctrl-up or ctrl-down
jlahoda
parents: 44459
diff changeset
    34
 * @build Compiler UITesting
46185
f4c981fc7818 8182270: JShell API: Tools need snippet information without evaluating snippet
rfield
parents: 45501
diff changeset
    35
 * @build ToolTabCommandTest
f4c981fc7818 8182270: JShell API: Tools need snippet information without evaluating snippet
rfield
parents: 45501
diff changeset
    36
 * @run testng ToolTabCommandTest
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    37
 */
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    38
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    39
import org.testng.annotations.Test;
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    40
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    41
@Test
46185
f4c981fc7818 8182270: JShell API: Tools need snippet information without evaluating snippet
rfield
parents: 45501
diff changeset
    42
public class ToolTabCommandTest extends UITesting {
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    43
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    44
    public void testCommand() throws Exception {
45501
a13e5e2ee35e 8180306: jshell tool: /help -- confusing identifier in feedback mode examples
rfield
parents: 45215
diff changeset
    45
        // set terminal height so that help output won't hit page breaks
a13e5e2ee35e 8180306: jshell tool: /help -- confusing identifier in feedback mode examples
rfield
parents: 45215
diff changeset
    46
        System.setProperty("test.terminal.height", "1000000");
a13e5e2ee35e 8180306: jshell tool: /help -- confusing identifier in feedback mode examples
rfield
parents: 45215
diff changeset
    47
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    48
        doRunTest((inputSink, out) -> {
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    49
            inputSink.write("1\n");
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    50
            waitOutput(out, PROMPT);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    51
            inputSink.write("/" + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    52
            waitOutput(out, ".*/edit.*/list.*\n\n" + resource("jshell.console.see.synopsis") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    53
                            REDRAW_PROMPT + "/");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    54
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    55
            waitOutput(out,   ".*\n/edit\n" + resource("help.edit.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    56
                            "\n.*\n/list\n" + resource("help.list.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    57
                            ".*\n\n" + resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    58
                            REDRAW_PROMPT + "/");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    59
            inputSink.write(TAB);
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    60
            waitOutput(out,  "/!\n" +
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    61
                            resource("help.bang") + "\n" +
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    62
                            "\n" +
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    63
                            resource("jshell.console.see.next.command.doc") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    64
                            REDRAW_PROMPT + "/");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    65
            inputSink.write(TAB);
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    66
            waitOutput(out,  "/-<n>\n" +
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    67
                            resource("help.previous") + "\n" +
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    68
                            "\n" +
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    69
                            resource("jshell.console.see.next.command.doc") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    70
                            REDRAW_PROMPT + "/");
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    71
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    72
            inputSink.write("ed" + TAB);
45215
c9477e22877f 8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents: 44811
diff changeset
    73
            waitOutput(out, "edit $");
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    74
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    75
            inputSink.write(TAB);
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    76
            waitOutput(out, ".*-all.*" +
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    77
                            "\n\n" + resource("jshell.console.see.synopsis") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    78
                            REDRAW_PROMPT + "/");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    79
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    80
            waitOutput(out, resource("help.edit.summary") + "\n\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    81
                            resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    82
                            REDRAW_PROMPT + "/edit ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    83
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    84
            waitOutput(out, resource("help.edit"));
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    85
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    86
            inputSink.write(INTERRUPT + "/env " + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    87
            waitOutput(out, PROMPT + "/env -\n" +
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    88
                            "-add-exports    -add-modules    -class-path     -module-path    \n" +
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    89
                            "\n" +
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    90
                            resource("jshell.console.see.synopsis") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    91
                            REDRAW_PROMPT + "/env -");
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    92
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    93
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    94
            waitOutput(out, resource("help.env.summary") + "\n\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    95
                            resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    96
                            REDRAW_PROMPT + "/env -");
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
    97
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    98
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
    99
            waitOutput(out, resource("help.env") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   100
                            REDRAW_PROMPT + "/env -");
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
   101
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   102
            inputSink.write(TAB);
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
   103
            waitOutput(out, "-add-exports    -add-modules    -class-path     -module-path    \n" +
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
   104
                            "\n" +
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   105
                            resource("jshell.console.see.synopsis") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   106
                            REDRAW_PROMPT + "/env -");
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
   107
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   108
            inputSink.write(INTERRUPT + "/exit " + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   109
            waitOutput(out, resource("help.exit.summary") + "\n\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   110
                            resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   111
                            REDRAW_PROMPT + "/exit ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   112
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   113
            waitOutput(out, resource("help.exit") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   114
                            REDRAW_PROMPT + "/exit ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   115
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   116
            waitOutput(out, resource("help.exit.summary") + "\n\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   117
                            resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   118
                            REDRAW_PROMPT + "/exit ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   119
            inputSink.write(INTERRUPT);
47840
e0f08a49f3e3 8177076: jshell tool: allow non-zero /exit
rfield
parents: 47484
diff changeset
   120
            inputSink.write("int zebraStripes = 11\n");
e0f08a49f3e3 8177076: jshell tool: allow non-zero /exit
rfield
parents: 47484
diff changeset
   121
            waitOutput(out, "zebraStripes ==> 11\n\u0005");
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   122
            inputSink.write("/exit zeb" + TAB);
47840
e0f08a49f3e3 8177076: jshell tool: allow non-zero /exit
rfield
parents: 47484
diff changeset
   123
            waitOutput(out, "braStr.*es");
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   124
            inputSink.write(INTERRUPT + "/doesnotexist" + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   125
            waitOutput(out, PROMPT + "/doesnotexist\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   126
                            resource("jshell.console.no.such.command") + "\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   127
                            REDRAW_PROMPT + "/doesnotexist");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   128
        });
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   129
    }
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   130
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   131
    public void testRerunCommands() throws Exception {
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   132
        // set terminal height so that help output won't hit page breaks
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   133
        System.setProperty("test.terminal.height", "1000000");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   134
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   135
        doRunTest((inputSink, out) -> {
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   136
            inputSink.write("1\n");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   137
            waitOutput(out, PROMPT);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   138
            inputSink.write("2\n");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   139
            waitOutput(out, PROMPT);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   140
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   141
            inputSink.write("/1" + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   142
            waitOutput(out, resource("help.rerun.summary") + "\n\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   143
                            resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   144
                            REDRAW_PROMPT + "/1");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   145
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   146
            waitOutput(out, resource("help.rerun") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   147
                            REDRAW_PROMPT + "/1");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   148
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   149
            waitOutput(out, resource("help.rerun.summary") + "\n\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   150
                            resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   151
                            REDRAW_PROMPT + "/1");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   152
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   153
            inputSink.write(INTERRUPT);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   154
            inputSink.write("/-1" + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   155
            waitOutput(out, resource("help.rerun.summary") + "\n\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   156
                            resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   157
                            REDRAW_PROMPT + "/-1");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   158
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   159
            waitOutput(out, resource("help.rerun") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   160
                            REDRAW_PROMPT + "/-1");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   161
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   162
            waitOutput(out, resource("help.rerun.summary") + "\n\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   163
                            resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   164
                            REDRAW_PROMPT + "/-1");
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
   165
        });
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
   166
    }
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
   167
47931
b7ae1437111b 8178109: More useful documentation on /help
jlahoda
parents: 47840
diff changeset
   168
    public void testHelp() throws Exception {
b7ae1437111b 8178109: More useful documentation on /help
jlahoda
parents: 47840
diff changeset
   169
        // set terminal height so that help output won't hit page breaks
b7ae1437111b 8178109: More useful documentation on /help
jlahoda
parents: 47840
diff changeset
   170
        System.setProperty("test.terminal.height", "1000000");
b7ae1437111b 8178109: More useful documentation on /help
jlahoda
parents: 47840
diff changeset
   171
b7ae1437111b 8178109: More useful documentation on /help
jlahoda
parents: 47840
diff changeset
   172
        doRunTest((inputSink, out) -> {
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   173
            inputSink.write("/help " + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   174
            waitOutput(out, ".*/edit.*/list.*intro.*\n\n" + resource("jshell.console.see.synopsis") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   175
                            REDRAW_PROMPT + "/");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   176
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   177
            waitOutput(out,   ".*\n/edit\n" + resource("help.edit.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   178
                            "\n.*\n/list\n" + resource("help.list.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   179
                            "\n.*\nintro\n" + resource("help.intro.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   180
                            ".*\n\n" + resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   181
                            REDRAW_PROMPT + "/");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   182
            inputSink.write("/env" + TAB);
47931
b7ae1437111b 8178109: More useful documentation on /help
jlahoda
parents: 47840
diff changeset
   183
            waitOutput(out,   "help /env ");
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   184
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   185
            waitOutput(out,   ".*\n/env\n" + resource("help.env.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   186
                            ".*\n\n" + resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   187
                            REDRAW_PROMPT + "/help /env ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   188
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   189
            waitOutput(out,   ".*\n/env\n" + resource("help.env") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   190
                            REDRAW_PROMPT + "/help /env ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   191
            inputSink.write(INTERRUPT + "/help intro" + TAB);
47931
b7ae1437111b 8178109: More useful documentation on /help
jlahoda
parents: 47840
diff changeset
   192
            waitOutput(out,   "help intro ");
48275
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   193
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   194
            waitOutput(out,   ".*\nintro\n" + resource("help.intro.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   195
                            ".*\n\n" + resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   196
                            REDRAW_PROMPT + "/help intro ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   197
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   198
            waitOutput(out,   ".*\nintro\n" + resource("help.intro") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   199
                            REDRAW_PROMPT + "/help intro ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   200
            inputSink.write(INTERRUPT + "/help /set " + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   201
            waitOutput(out, ".*format.*truncation.*\n\n" + resource("jshell.console.see.synopsis") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   202
                            REDRAW_PROMPT + "/help /set ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   203
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   204
            waitOutput(out,   ".*\n/set format\n" + resource("help.set.format.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   205
                            "\n.*\n/set truncation\n" + resource("help.set.truncation.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   206
                            ".*\n\n" + resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   207
                            REDRAW_PROMPT + "/help /set ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   208
            inputSink.write("truncation" + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   209
            waitOutput(out,   ".*truncation\n" + resource("jshell.console.see.synopsis") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   210
                            REDRAW_PROMPT + "/help /set truncation");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   211
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   212
            waitOutput(out,   ".*/set truncation\n" + resource("help.set.truncation.summary") + "\n" +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   213
                            "\n" + resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   214
                            REDRAW_PROMPT + "/help /set truncation");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   215
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   216
            waitOutput(out,   ".*/set truncation\n" + resource("help.set.truncation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   217
                           "\r" + PROMPT + "/help /set truncation");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   218
            inputSink.write(INTERRUPT + "/help env " + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   219
            waitOutput(out,   ".*\n/env\n" + resource("help.env.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   220
                            ".*\n\n" + resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   221
                            REDRAW_PROMPT + "/help env ");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   222
            inputSink.write(INTERRUPT + "/help set truncation" + TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   223
            waitOutput(out,   ".*truncation\n" + resource("jshell.console.see.synopsis") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   224
                            REDRAW_PROMPT + "/help set truncation");
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   225
            inputSink.write(TAB);
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   226
            waitOutput(out,   ".*\n/set truncation\n" + resource("help.set.truncation.summary") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   227
                            ".*\n\n" + resource("jshell.console.see.full.documentation") +
b2190c70a1ac 8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents: 47931
diff changeset
   228
                            REDRAW_PROMPT + "/help set truncation");
47931
b7ae1437111b 8178109: More useful documentation on /help
jlahoda
parents: 47840
diff changeset
   229
        });
b7ae1437111b 8178109: More useful documentation on /help
jlahoda
parents: 47840
diff changeset
   230
    }
44459
5224425af378 8177076: jshell tool: usability of completion
jlahoda
parents:
diff changeset
   231
}