author | stefank |
Thu, 07 Jun 2018 10:11:36 +0200 | |
changeset 50621 | 4216de02077e |
parent 50338 | 1d5694c1aa03 |
child 52938 | 5ff7480c9e28 |
permissions | -rw-r--r-- |
46923
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
1 |
/* |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
4 |
* |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
8 |
* |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
13 |
* accompanied this code). |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
14 |
* |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
18 |
* |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
21 |
* questions. |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
22 |
*/ |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
23 |
|
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
24 |
/** |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
25 |
* @test |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
26 |
* @bug 8182297 |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
27 |
* @summary Verify that pasting multi-line snippets works properly. |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
28 |
* @library /tools/lib |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
29 |
* @modules |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
30 |
* java.base/java.lang:open |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
31 |
* java.base/java.io:open |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.javac.api |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
33 |
* jdk.compiler/com.sun.tools.javac.main |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
34 |
* jdk.jshell/jdk.internal.jshell.tool.resources:open |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
35 |
* jdk.jshell/jdk.jshell:open |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
36 |
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
37 |
* @build Compiler UITesting |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
38 |
* @build PasteAndMeasurementsUITest |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
39 |
* @run testng/othervm PasteAndMeasurementsUITest |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
40 |
*/ |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
41 |
|
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
42 |
import java.io.Console; |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
43 |
import java.lang.reflect.Constructor; |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
44 |
import java.lang.reflect.Field; |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
45 |
|
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
46 |
import org.testng.annotations.Test; |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
47 |
|
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
48 |
@Test |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
49 |
public class PasteAndMeasurementsUITest extends UITesting { |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
50 |
|
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
51 |
public void testPrevNextSnippet() throws Exception { |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
52 |
Field cons = System.class.getDeclaredField("cons"); |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
53 |
cons.setAccessible(true); |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
54 |
Constructor console = Console.class.getDeclaredConstructor(); |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
55 |
console.setAccessible(true); |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
56 |
cons.set(null, console.newInstance()); |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
57 |
doRunTest((inputSink, out) -> { |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
58 |
inputSink.write("void test1() {\nSystem.err.println(1);\n}\n" + LOC + |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
59 |
"void test2() {\nSystem.err.println(1);\n}\n" + LOC + LOC + LOC + LOC + LOC); |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
60 |
waitOutput(out, "\u001b\\[6nvoid test1\\(\\) \\{\n" + |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
61 |
"\u0006\u001b\\[6nSystem.err.println\\(1\\);\n" + |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
62 |
"\u0006\u001b\\[6n\\}\n" + |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
63 |
"\\| created method test1\\(\\)\n" + |
48275
b2190c70a1ac
8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents:
47216
diff
changeset
|
64 |
PROMPT + "\u001b\\[6nvoid test2\\(\\) \\{\n" + |
46923
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
65 |
"\u0006\u001b\\[6nSystem.err.println\\(1\\);\n" + |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
66 |
"\u0006\u001b\\[6n\\}\n" + |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
67 |
"\\| created method test2\\(\\)\n" + |
48275
b2190c70a1ac
8192863: jshell tool: /<id><tab> gives "No such command"
rfield
parents:
47216
diff
changeset
|
68 |
PROMPT + "\u001b\\[6n"); |
46923
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
69 |
}); |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
70 |
} |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
71 |
private static final String LOC = "\033[12;1R"; |
0172e4350f65
8182297: jshell tool: pasting multiple lines of code truncated
jlahoda
parents:
diff
changeset
|
72 |
} |