author | coleenp |
Wed, 15 Nov 2017 08:14:31 -0500 | |
changeset 47894 | 352b17f62ff7 |
parent 47484 | d0cb66d8cbf1 |
child 47840 | e0f08a49f3e3 |
permissions | -rw-r--r-- |
44459 | 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 |
|
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 | 37 |
*/ |
38 |
||
39 |
import java.util.regex.Pattern; |
|
40 |
||
41 |
import org.testng.annotations.Test; |
|
42 |
||
43 |
@Test |
|
46185
f4c981fc7818
8182270: JShell API: Tools need snippet information without evaluating snippet
rfield
parents:
45501
diff
changeset
|
44 |
public class ToolTabCommandTest extends UITesting { |
44459 | 45 |
|
46 |
public void testCommand() throws Exception { |
|
45501
a13e5e2ee35e
8180306: jshell tool: /help -- confusing identifier in feedback mode examples
rfield
parents:
45215
diff
changeset
|
47 |
// 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
|
48 |
System.setProperty("test.terminal.height", "1000000"); |
a13e5e2ee35e
8180306: jshell tool: /help -- confusing identifier in feedback mode examples
rfield
parents:
45215
diff
changeset
|
49 |
|
44459 | 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 |
||
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44811
diff
changeset
|
72 |
inputSink.write("ed\011"); |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44811
diff
changeset
|
73 |
waitOutput(out, "edit $"); |
44459 | 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"); |
|
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44811
diff
changeset
|
79 |
waitOutput(out, Pattern.quote(getResource("help.edit.summary")) + "\n\n" + |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44811
diff
changeset
|
80 |
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/edit "); |
44459 | 81 |
inputSink.write("\011"); |
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44811
diff
changeset
|
82 |
waitOutput(out, Pattern.quote(getResource("help.edit").replaceAll("\t", " "))); |
44459 | 83 |
|
84 |
inputSink.write("\u0003/env \011"); |
|
85 |
waitOutput(out, "\u0005/env -\n" + |
|
86 |
"-add-exports -add-modules -class-path -module-path \n" + |
|
87 |
"\n" + |
|
88 |
Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" + |
|
89 |
"\r\u0005/env -"); |
|
90 |
||
91 |
inputSink.write("\011"); |
|
92 |
waitOutput(out, Pattern.quote(getResource("help.env.summary")) + "\n\n" + |
|
93 |
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n" + |
|
94 |
"\r\u0005/env -"); |
|
95 |
||
96 |
inputSink.write("\011"); |
|
97 |
waitOutput(out, Pattern.quote(getResource("help.env").replaceAll("\t", " ")) + "\n" + |
|
98 |
"\r\u0005/env -"); |
|
99 |
||
100 |
inputSink.write("\011"); |
|
101 |
waitOutput(out, "-add-exports -add-modules -class-path -module-path \n" + |
|
102 |
"\n" + |
|
103 |
Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" + |
|
104 |
"\r\u0005/env -"); |
|
105 |
||
106 |
inputSink.write("\u0003/exit \011"); |
|
107 |
waitOutput(out, Pattern.quote(getResource("help.exit.summary")) + "\n\n" + |
|
108 |
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/exit "); |
|
109 |
inputSink.write("\011"); |
|
110 |
waitOutput(out, Pattern.quote(getResource("help.exit")) + "\n" + |
|
111 |
"\r\u0005/exit "); |
|
112 |
inputSink.write("\011"); |
|
113 |
waitOutput(out, Pattern.quote(getResource("help.exit.summary")) + "\n\n" + |
|
114 |
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/exit "); |
|
115 |
inputSink.write("\u0003/doesnotexist\011"); |
|
116 |
waitOutput(out, "\u0005/doesnotexist\n" + |
|
117 |
Pattern.quote(getResource("jshell.console.no.such.command")) + "\n" + |
|
118 |
"\n" + |
|
119 |
"\r\u0005/doesnotexist"); |
|
120 |
}); |
|
121 |
} |
|
122 |
||
123 |
} |