Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/jdk/jshell/HistoryUITest.java
40930 views
1
/*
2
* Copyright (c) 2017, 2018, 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 8178077 8232856
27
* @summary Check the UI behavior of editing history.
28
* @modules
29
* jdk.compiler/com.sun.tools.javac.api
30
* jdk.compiler/com.sun.tools.javac.main
31
* jdk.jshell/jdk.internal.jshell.tool:open
32
* jdk.jshell/jdk.internal.jshell.tool.resources:open
33
* jdk.jshell/jdk.jshell:open
34
* @library /tools/lib
35
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
36
* @build Compiler UITesting
37
* @compile HistoryUITest.java
38
* @run testng HistoryUITest
39
*/
40
41
import org.testng.annotations.Test;
42
43
@Test
44
public class HistoryUITest extends UITesting {
45
46
public HistoryUITest() {
47
super(true);
48
}
49
50
public void testPrevNextSnippet() throws Exception {
51
doRunTest((inputSink, out) -> {
52
inputSink.write("void test1() {\nSystem.err.println(1);\n}\n");
53
waitOutput(out, PROMPT);
54
inputSink.write("void test2() {\nSystem.err.println(2);\n}\n");
55
waitOutput(out, PROMPT);
56
inputSink.write(UP);
57
waitOutput(out, "^void test2\\(\\) \\{\n" +
58
CONTINUATION_PROMPT + " System.err.println\\(2\\);\n" +
59
CONTINUATION_PROMPT + "\\}");
60
inputSink.write(UP);
61
waitOutput(out, "^\u001b\\[A");
62
inputSink.write(UP);
63
waitOutput(out, "^\u001b\\[A");
64
inputSink.write(UP);
65
waitOutput(out, "^\u001b\\[8C1\n" +
66
"\u001b\\[23C1\n\u001b\\[C");
67
inputSink.write(DOWN);
68
waitOutput(out, "^\u001B\\[2A\u001b\\[8C2\n" +
69
"\u001b\\[23C2\n\u001b\\[C");
70
inputSink.write(UP);
71
waitOutput(out, "^\u001b\\[A");
72
for (int i = 0; i < 23; i++) inputSink.write("\033[C");
73
waitOutput(out, "C");
74
inputSink.write("\u0008\"Modified!\"\n");
75
waitOutput(out, PROMPT);
76
inputSink.write("test2()\n");
77
waitOutput(out, "\\u001B\\[\\?2004lModified!\n\\u001B\\[\\?2004h" + PROMPT);
78
});
79
}
80
81
public void testReRun() throws Exception {
82
doRunTest((inputSink, out) -> {
83
inputSink.write("System.err.println(\"RAN\");\n");
84
waitOutput(out, "RAN.*" + PROMPT);
85
inputSink.write("/!\n");
86
waitOutput(out, "RAN.*" + PROMPT);
87
inputSink.write(UP);
88
inputSink.write("\n");
89
waitOutput(out, "RAN.*" + PROMPT);
90
});
91
}
92
93
}
94
95