langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java
changeset 46185 f4c981fc7818
parent 46184 f1325703ea85
child 46186 5e941736c260
equal deleted inserted replaced
46184:f1325703ea85 46185:f4c981fc7818
     1 /*
       
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     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
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 /**
       
    25  * @test
       
    26  * @bug 8177076
       
    27  * @modules
       
    28  *     jdk.compiler/com.sun.tools.javac.api
       
    29  *     jdk.compiler/com.sun.tools.javac.main
       
    30  *     jdk.jshell/jdk.internal.jshell.tool.resources:open
       
    31  *     jdk.jshell/jdk.jshell:open
       
    32  * @library /tools/lib
       
    33  * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
       
    34  * @build Compiler UITesting
       
    35  * @build MergedTabShiftTabCommandTest
       
    36  * @run testng MergedTabShiftTabCommandTest
       
    37  */
       
    38 
       
    39 import java.util.regex.Pattern;
       
    40 
       
    41 import org.testng.annotations.Test;
       
    42 
       
    43 @Test
       
    44 public class MergedTabShiftTabCommandTest extends UITesting {
       
    45 
       
    46     public void testCommand() throws Exception {
       
    47         // set terminal height so that help output won't hit page breaks
       
    48         System.setProperty("test.terminal.height", "1000000");
       
    49 
       
    50         doRunTest((inputSink, out) -> {
       
    51             inputSink.write("1\n");
       
    52             waitOutput(out, "\u0005");
       
    53             inputSink.write("/\011");
       
    54             waitOutput(out, ".*/edit.*/list.*\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/");
       
    55             inputSink.write("\011");
       
    56             waitOutput(out,   ".*\n/edit\n" + Pattern.quote(getResource("help.edit.summary")) +
       
    57                             "\n.*\n/list\n" + Pattern.quote(getResource("help.list.summary")) +
       
    58                             ".*\n\n" + Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/");
       
    59             inputSink.write("\011");
       
    60             waitOutput(out,  "/!\n" +
       
    61                             Pattern.quote(getResource("help.bang")) + "\n" +
       
    62                             "\n" +
       
    63                             Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" +
       
    64                             "\r\u0005/");
       
    65             inputSink.write("\011");
       
    66             waitOutput(out,  "/-<n>\n" +
       
    67                             Pattern.quote(getResource("help.previous")) + "\n" +
       
    68                             "\n" +
       
    69                             Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" +
       
    70                             "\r\u0005/");
       
    71 
       
    72             inputSink.write("ed\011");
       
    73             waitOutput(out, "edit $");
       
    74 
       
    75             inputSink.write("\011");
       
    76             waitOutput(out, ".*-all.*" +
       
    77                             "\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/");
       
    78             inputSink.write("\011");
       
    79             waitOutput(out, Pattern.quote(getResource("help.edit.summary")) + "\n\n" +
       
    80                             Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/edit ");
       
    81             inputSink.write("\011");
       
    82             waitOutput(out, Pattern.quote(getResource("help.edit").replaceAll("\t", "    ")));
       
    83 
       
    84             inputSink.write("\u0003/env \011");
       
    85             waitOutput(out, "\u0005/env -\n" +
       
    86                             "-add-exports    -add-modules    -class-path     -module-path    \n" +
       
    87                             "\r\u0005/env -");
       
    88 
       
    89             inputSink.write("\011");
       
    90             waitOutput(out, "-add-exports    -add-modules    -class-path     -module-path    \n" +
       
    91                             "\n" +
       
    92                             Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" +
       
    93                             "\r\u0005/env -");
       
    94 
       
    95             inputSink.write("\011");
       
    96             waitOutput(out, Pattern.quote(getResource("help.env.summary")) + "\n\n" +
       
    97                             Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n" +
       
    98                             "\r\u0005/env -");
       
    99 
       
   100             inputSink.write("\011");
       
   101             waitOutput(out, Pattern.quote(getResource("help.env").replaceAll("\t", "    ")) + "\n" +
       
   102                             "\r\u0005/env -");
       
   103 
       
   104             inputSink.write("\011");
       
   105             waitOutput(out, "-add-exports    -add-modules    -class-path     -module-path    \n" +
       
   106                             "\n" +
       
   107                             Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" +
       
   108                             "\r\u0005/env -");
       
   109 
       
   110             inputSink.write("\u0003/exit \011");
       
   111             waitOutput(out, Pattern.quote(getResource("help.exit.summary")) + "\n\n" +
       
   112                             Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/exit ");
       
   113             inputSink.write("\011");
       
   114             waitOutput(out, Pattern.quote(getResource("help.exit")) + "\n" +
       
   115                             "\r\u0005/exit ");
       
   116             inputSink.write("\011");
       
   117             waitOutput(out, Pattern.quote(getResource("help.exit.summary")) + "\n\n" +
       
   118                             Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/exit ");
       
   119             inputSink.write("\u0003/doesnotexist\011");
       
   120             waitOutput(out, "\u0005/doesnotexist\n" +
       
   121                             Pattern.quote(getResource("jshell.console.no.such.command")) + "\n" +
       
   122                             "\n" +
       
   123                             "\r\u0005/doesnotexist");
       
   124         });
       
   125     }
       
   126 
       
   127 }