author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 45747 | langtools/test/jdk/jshell/CompletionSuggestionTest.java@bdf4b1b26697 |
child 47268 | 48ec75306997 |
permissions | -rw-r--r-- |
33362 | 1 |
/* |
36526 | 2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
33362 | 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 |
|
45747
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
26 |
* @bug 8131025 8141092 8153761 8145263 8131019 8175886 8176184 8176241 8176110 |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
27 |
* @summary Test Completion and Documentation |
41865 | 28 |
* @library /tools/lib |
35359 | 29 |
* @modules jdk.compiler/com.sun.tools.javac.api |
30 |
* jdk.compiler/com.sun.tools.javac.main |
|
36526 | 31 |
* jdk.jdeps/com.sun.tools.javap |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41865
diff
changeset
|
32 |
* jdk.jshell/jdk.jshell:open |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
33 |
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
34 |
* @build KullaTesting TestingInputStream Compiler |
33362 | 35 |
* @run testng CompletionSuggestionTest |
36 |
*/ |
|
37 |
||
37939
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
38 |
import java.io.IOException; |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
39 |
import java.lang.reflect.Field; |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
40 |
import java.nio.file.Files; |
33362 | 41 |
import java.nio.file.Path; |
42 |
import java.nio.file.Paths; |
|
43 |
import java.util.Arrays; |
|
44 |
import java.util.Collections; |
|
45 |
import java.util.Set; |
|
46 |
import java.util.HashSet; |
|
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
47 |
import java.util.function.BiFunction; |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
48 |
import java.util.function.Function; |
37939
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
49 |
import java.util.jar.JarEntry; |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
50 |
import java.util.jar.JarOutputStream; |
33362 | 51 |
|
52 |
import jdk.jshell.Snippet; |
|
37939
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
53 |
import org.testng.annotations.BeforeMethod; |
33362 | 54 |
import org.testng.annotations.Test; |
55 |
||
56 |
import static jdk.jshell.Snippet.Status.VALID; |
|
57 |
import static jdk.jshell.Snippet.Status.OVERWRITTEN; |
|
58 |
||
59 |
@Test |
|
60 |
public class CompletionSuggestionTest extends KullaTesting { |
|
61 |
||
33715
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
62 |
private final Compiler compiler = new Compiler(); |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
63 |
private final Path outDir = Paths.get("completion_suggestion_test"); |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
64 |
|
33362 | 65 |
public void testMemberExpr() { |
66 |
assertEval("class Test { static void test() { } }"); |
|
67 |
assertCompletion("Test.t|", "test()"); |
|
68 |
assertEval("Test ccTestInstance = new Test();"); |
|
69 |
assertCompletion("ccTestInstance.t|", "toString()"); |
|
70 |
assertCompletion(" ccTe|", "ccTestInstance"); |
|
71 |
assertCompletion("String value = ccTestInstance.to|", "toString()"); |
|
72 |
assertCompletion("java.util.Coll|", "Collection", "Collections"); |
|
73 |
assertCompletion("String.cla|", "class"); |
|
74 |
assertCompletion("boolean.cla|", "class"); |
|
75 |
assertCompletion("byte.cla|", "class"); |
|
76 |
assertCompletion("short.cla|", "class"); |
|
77 |
assertCompletion("char.cla|", "class"); |
|
78 |
assertCompletion("int.cla|", "class"); |
|
79 |
assertCompletion("float.cla|", "class"); |
|
80 |
assertCompletion("long.cla|", "class"); |
|
81 |
assertCompletion("double.cla|", "class"); |
|
82 |
assertCompletion("void.cla|", "class"); |
|
83 |
assertCompletion("Object[].|", "class"); |
|
84 |
assertCompletion("int[].|", "class"); |
|
85 |
assertEval("Object[] ao = null;"); |
|
86 |
assertCompletion("int i = ao.|", "length"); |
|
87 |
assertEval("int[] ai = null;"); |
|
88 |
assertCompletion("int i = ai.|", "length"); |
|
89 |
assertCompletionIncludesExcludes("\"\".|", |
|
90 |
new HashSet<>(Collections.emptyList()), |
|
91 |
new HashSet<>(Arrays.asList("String("))); |
|
92 |
assertEval("double d = 0;"); |
|
93 |
assertEval("void m() {}"); |
|
94 |
assertCompletionIncludesExcludes("d.|", |
|
95 |
new HashSet<>(Collections.emptyList()), |
|
96 |
new HashSet<>(Arrays.asList("class"))); |
|
97 |
assertCompletionIncludesExcludes("m().|", |
|
98 |
new HashSet<>(Collections.emptyList()), |
|
99 |
new HashSet<>(Arrays.asList("class"))); |
|
100 |
assertEval("class C {class D {} static class E {} enum F {} interface H {} void method() {} int number;}"); |
|
101 |
assertCompletionIncludesExcludes("C.|", |
|
102 |
new HashSet<>(Arrays.asList("D", "E", "F", "H", "class")), |
|
103 |
new HashSet<>(Arrays.asList("method()", "number"))); |
|
104 |
assertCompletionIncludesExcludes("new C().|", |
|
105 |
new HashSet<>(Arrays.asList("method()", "number")), |
|
106 |
new HashSet<>(Arrays.asList("D", "E", "F", "H", "class"))); |
|
107 |
assertCompletionIncludesExcludes("new C() {}.|", |
|
108 |
new HashSet<>(Arrays.asList("method()", "number")), |
|
109 |
new HashSet<>(Arrays.asList("D", "E", "F", "H", "class"))); |
|
110 |
} |
|
111 |
||
112 |
public void testStartOfExpression() { |
|
113 |
assertEval("int ccTest = 0;"); |
|
114 |
assertCompletion("System.err.println(cc|", "ccTest"); |
|
115 |
assertCompletion("for (int i = cc|", "ccTest"); |
|
116 |
} |
|
117 |
||
118 |
public void testParameter() { |
|
119 |
assertCompletion("class C{void method(int num){num|", "num"); |
|
120 |
} |
|
121 |
||
122 |
public void testPrimitive() { |
|
123 |
Set<String> primitives = new HashSet<>(Arrays.asList("boolean", "char", "byte", "short", "int", "long", "float", "double")); |
|
124 |
Set<String> onlyVoid = new HashSet<>(Collections.singletonList("void")); |
|
125 |
Set<String> primitivesOrVoid = new HashSet<>(primitives); |
|
126 |
primitivesOrVoid.addAll(onlyVoid); |
|
127 |
||
128 |
assertCompletionIncludesExcludes("|", |
|
129 |
primitivesOrVoid, |
|
130 |
new HashSet<>(Collections.emptyList())); |
|
131 |
assertCompletionIncludesExcludes("int num = |", |
|
132 |
primitivesOrVoid, |
|
133 |
new HashSet<>(Collections.emptyList())); |
|
134 |
assertCompletionIncludesExcludes("num = |", |
|
135 |
primitivesOrVoid, |
|
136 |
new HashSet<>(Collections.emptyList())); |
|
137 |
assertCompletionIncludesExcludes("class C{void m() {|", |
|
138 |
primitivesOrVoid, |
|
139 |
new HashSet<>(Collections.emptyList())); |
|
140 |
assertCompletionIncludesExcludes("void method(|", |
|
141 |
primitives, |
|
142 |
onlyVoid); |
|
143 |
assertCompletionIncludesExcludes("void method(int num, |", |
|
144 |
primitives, |
|
145 |
onlyVoid); |
|
146 |
assertCompletion("new java.util.ArrayList<doub|"); |
|
147 |
assertCompletion("class A extends doubl|"); |
|
148 |
assertCompletion("class A implements doubl|"); |
|
149 |
assertCompletion("interface A extends doubl|"); |
|
150 |
assertCompletion("enum A implements doubl|"); |
|
151 |
assertCompletion("class A<T extends doubl|"); |
|
152 |
} |
|
153 |
||
154 |
public void testEmpty() { |
|
155 |
assertCompletionIncludesExcludes("|", |
|
156 |
new HashSet<>(Arrays.asList("Object", "Void")), |
|
157 |
new HashSet<>(Arrays.asList("$REPL00DOESNOTMATTER"))); |
|
158 |
assertCompletionIncludesExcludes("V|", |
|
159 |
new HashSet<>(Collections.singletonList("Void")), |
|
160 |
new HashSet<>(Collections.singletonList("Object"))); |
|
161 |
assertCompletionIncludesExcludes("{ |", |
|
162 |
new HashSet<>(Arrays.asList("Object", "Void")), |
|
163 |
new HashSet<>(Arrays.asList("$REPL00DOESNOTMATTER"))); |
|
164 |
} |
|
165 |
||
166 |
public void testSmartCompletion() { |
|
167 |
assertEval("int ccTest1 = 0;"); |
|
168 |
assertEval("int ccTest2 = 0;"); |
|
169 |
assertEval("String ccTest3 = null;"); |
|
170 |
assertEval("void method(int i, String str) { }"); |
|
171 |
assertEval("void method(String str, int i) { }"); |
|
172 |
assertEval("java.util.List<String> list = null;"); |
|
173 |
assertCompletion("int ccTest4 = |", true, "ccTest1", "ccTest2"); |
|
174 |
assertCompletion("ccTest2 = |", true, "ccTest1", "ccTest2"); |
|
175 |
assertCompletion("int ccTest4 = ccTe|", "ccTest1", "ccTest2", "ccTest3"); |
|
176 |
assertCompletion("int ccTest4 = ccTest3.len|", true, "length()"); |
|
177 |
assertCompletion("method(|", true, "ccTest1", "ccTest2", "ccTest3"); |
|
178 |
assertCompletion("method(0, |", true, "ccTest3"); |
|
179 |
assertCompletion("list.add(|", true, "ccTest1", "ccTest2", "ccTest3"); |
|
180 |
assertCompletion("list.add(0, |", true, "ccTest3"); |
|
181 |
assertCompletion("new String(|", true, "ccTest3"); |
|
182 |
assertCompletion("new String(new char[0], |", true, "ccTest1", "ccTest2"); |
|
45747
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
183 |
assertCompletionIncludesExcludes("new jav|", new HashSet<>(Arrays.asList("java.", "javax.")), Collections.emptySet()); |
33362 | 184 |
assertCompletion("Class<String> clazz = String.c|", true, "class"); |
185 |
||
186 |
Snippet klass = classKey(assertEval("class Klass {void method(int n) {} private void method(String str) {}}")); |
|
187 |
assertCompletion("new Klass().method(|", true, "ccTest1", "ccTest2"); |
|
188 |
Snippet klass2 = classKey(assertEval("class Klass {static void method(int n) {} void method(String str) {}}", |
|
189 |
ste(MAIN_SNIPPET, VALID, VALID, true, null), |
|
190 |
ste(klass, VALID, OVERWRITTEN, false, MAIN_SNIPPET))); |
|
191 |
assertCompletion("Klass.method(|", true, "ccTest1", "ccTest2"); |
|
192 |
assertEval("class Klass {Klass(int n) {} private Klass(String str) {}}", |
|
193 |
ste(MAIN_SNIPPET, VALID, VALID, true, null), |
|
194 |
ste(klass2, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); |
|
195 |
assertCompletion("new Klass(|", true, "ccTest1", "ccTest2"); |
|
196 |
} |
|
197 |
||
198 |
public void testSmartCompletionInOverriddenMethodInvocation() { |
|
199 |
assertEval("int ccTest1 = 0;"); |
|
200 |
assertEval("int ccTest2 = 0;"); |
|
201 |
assertEval("String ccTest3 = null;"); |
|
202 |
assertCompletion("\"\".wait(|", true, "ccTest1", "ccTest2"); |
|
203 |
assertEval("class Base {void method(int n) {}}"); |
|
204 |
assertEval("class Extend extends Base {}"); |
|
205 |
assertCompletion("new Extend().method(|", true, "ccTest1", "ccTest2"); |
|
206 |
} |
|
207 |
||
208 |
public void testSmartCompletionForBoxedType() { |
|
209 |
assertEval("int ccTest1 = 0;"); |
|
210 |
assertEval("Integer ccTest2 = 0;"); |
|
211 |
assertEval("Object ccTest3 = null;"); |
|
212 |
assertEval("int method1(int n) {return n;}"); |
|
213 |
assertEval("Integer method2(Integer n) {return n;}"); |
|
214 |
assertEval("Object method3(Object o) {return o;}"); |
|
215 |
assertCompletion("int ccTest4 = |", true, "ccTest1", "ccTest2", "method1(", "method2("); |
|
216 |
assertCompletion("Integer ccTest4 = |", true, "ccTest1", "ccTest2", "method1(", "method2("); |
|
217 |
assertCompletion("Object ccTest4 = |", true, "ccTest1", "ccTest2", "ccTest3", "method1(", "method2(", "method3("); |
|
218 |
assertCompletion("method1(|", true, "ccTest1", "ccTest2", "method1(", "method2("); |
|
219 |
assertCompletion("method2(|", true, "ccTest1", "ccTest2", "method1(", "method2("); |
|
220 |
assertCompletion("method3(|", true, "ccTest1", "ccTest2", "ccTest3", "method1(", "method2(", "method3("); |
|
221 |
} |
|
222 |
||
223 |
public void testNewClass() { |
|
224 |
assertCompletion("String str = new Strin|", "String(", "StringBuffer(", "StringBuilder(", "StringIndexOutOfBoundsException("); |
|
225 |
assertCompletion("String str = new java.lang.Strin|", "String(", "StringBuffer(", "StringBuilder(", "StringIndexOutOfBoundsException("); |
|
226 |
assertCompletion("String str = new |", true, "String("); |
|
227 |
assertCompletion("String str = new java.lang.|", true, "String("); |
|
228 |
assertCompletion("throw new Strin|", true, "StringIndexOutOfBoundsException("); |
|
229 |
||
230 |
assertEval("class A{class B{} class C {C(int n) {}} static class D {} interface I {}}"); |
|
231 |
assertEval("A a;"); |
|
232 |
assertCompletion("new A().new |", "B()", "C("); |
|
233 |
assertCompletion("a.new |", "B()", "C("); |
|
234 |
assertCompletion("new A.|", "D()"); |
|
235 |
||
236 |
assertEval("enum E{; class A {}}"); |
|
237 |
assertEval("interface I{; class A {}}"); |
|
238 |
assertCompletion("new E.|", "A()"); |
|
239 |
assertCompletion("new I.|", "A()"); |
|
240 |
assertCompletion("new String(I.A|", "A"); |
|
241 |
} |
|
242 |
||
243 |
public void testFullyQualified() { |
|
45747
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
244 |
assertCompletion("Optional<String> opt = java.u|", "util."); |
33362 | 245 |
assertCompletionIncludesExcludes("Optional<Strings> opt = java.util.O|", new HashSet<>(Collections.singletonList("Optional")), Collections.emptySet()); |
246 |
||
247 |
assertEval("void method(java.util.Optional<String> opt) {}"); |
|
45747
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
248 |
assertCompletion("method(java.u|", "util."); |
33362 | 249 |
|
250 |
assertCompletion("Object.notElement.|"); |
|
45747
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
251 |
assertCompletion("Object o = com.su|", "sun."); |
33715
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
252 |
|
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
253 |
Path p1 = outDir.resolve("dir1"); |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
254 |
compiler.compile(p1, |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
255 |
"package p1.p2;\n" + |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
256 |
"public class Test {\n" + |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
257 |
"}", |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
258 |
"package p1.p3;\n" + |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
259 |
"public class Test {\n" + |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
260 |
"}"); |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
261 |
String jarName = "test.jar"; |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
262 |
compiler.jar(p1, jarName, "p1/p2/Test.class", "p1/p3/Test.class"); |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
263 |
addToClasspath(compiler.getPath(p1.resolve(jarName))); |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
264 |
|
45747
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
265 |
assertCompletionIncludesExcludes("|", new HashSet<>(Collections.singletonList("p1.")), Collections.emptySet()); |
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
266 |
assertCompletion("p1.|", "p2.", "p3."); |
33715
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
267 |
assertCompletion("p1.p2.|", "Test"); |
74b1bed86932
8141092: JShell: Completion hangs on identifier completion
jlahoda
parents:
33362
diff
changeset
|
268 |
assertCompletion("p1.p3.|", "Test"); |
33362 | 269 |
} |
270 |
||
271 |
public void testCheckAccessibility() { |
|
272 |
assertCompletion("java.util.regex.Pattern.co|", "compile("); |
|
273 |
} |
|
274 |
||
275 |
public void testCompletePackages() { |
|
45747
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
276 |
assertCompletion("java.u|", "util."); |
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
277 |
assertCompletionIncludesExcludes("jav|", new HashSet<>(Arrays.asList("java.", "javax.")), Collections.emptySet()); |
33362 | 278 |
} |
279 |
||
280 |
public void testImports() { |
|
45747
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
281 |
assertCompletion("import java.u|", "util."); |
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
282 |
assertCompletionIncludesExcludes("import jav|", new HashSet<>(Arrays.asList("java.", "javax.")), Collections.emptySet()); |
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
283 |
assertCompletion("import static java.u|", "util."); |
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
284 |
assertCompletionIncludesExcludes("import static jav|", new HashSet<>(Arrays.asList("java.", "javax.")), Collections.emptySet()); |
33362 | 285 |
assertCompletion("import static java.lang.Boolean.g|", "getBoolean"); |
286 |
assertCompletion("import java.util.*|"); |
|
287 |
assertCompletionIncludesExcludes("import java.lang.String.|", |
|
288 |
Collections.emptySet(), |
|
289 |
new HashSet<>(Arrays.asList("CASE_INSENSITIVE_ORDER", "copyValueOf", "format", "join", "valueOf", "class", "length"))); |
|
290 |
assertCompletionIncludesExcludes("import static java.lang.String.|", |
|
291 |
new HashSet<>(Arrays.asList("CASE_INSENSITIVE_ORDER", "copyValueOf", "format", "join", "valueOf")), |
|
292 |
new HashSet<>(Arrays.asList("class", "length"))); |
|
293 |
assertCompletionIncludesExcludes("import java.util.Map.|", |
|
294 |
new HashSet<>(Arrays.asList("Entry")), |
|
295 |
new HashSet<>(Arrays.asList("class"))); |
|
296 |
} |
|
297 |
||
44061 | 298 |
public void testImportStart() { |
45747
bdf4b1b26697
8176110: JShell: completions with package results should, in most cases, be dot terminated
rfield
parents:
44814
diff
changeset
|
299 |
assertCompletionIncludesExcludes("import c|", Set.of("com."), Set.of()); |
44061 | 300 |
} |
301 |
||
33362 | 302 |
public void testBrokenClassFile() throws Exception { |
303 |
Compiler compiler = new Compiler(); |
|
304 |
Path testOutDir = Paths.get("CompletionTestBrokenClassFile"); |
|
305 |
String input = "package test.inner; public class Test {}"; |
|
306 |
compiler.compile(testOutDir, input); |
|
307 |
addToClasspath(compiler.getPath(testOutDir).resolve("test")); |
|
308 |
assertCompletion("import inner.|"); |
|
309 |
} |
|
310 |
||
37939
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
311 |
public void testDocumentation() throws Exception { |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
312 |
dontReadParameterNamesFromClassFile(); |
41865 | 313 |
assertSignature("System.getProperty(|", |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
314 |
"String System.getProperty(String key)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
315 |
"String System.getProperty(String key, String def)"); |
33362 | 316 |
assertEval("char[] chars = null;"); |
41865 | 317 |
assertSignature("new String(chars, |", |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
318 |
"String(char[], int, int)"); |
41865 | 319 |
assertSignature("String.format(|", |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
320 |
"String String.format(String, Object...)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
321 |
"String String.format(java.util.Locale, String, Object...)"); |
41865 | 322 |
assertSignature("\"\".getBytes(\"\"|", "void String.getBytes(int, int, byte[], int)", |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
323 |
"byte[] String.getBytes(String) throws java.io.UnsupportedEncodingException", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
324 |
"byte[] String.getBytes(java.nio.charset.Charset)"); |
41865 | 325 |
assertSignature("\"\".getBytes(\"\" |", "void String.getBytes(int, int, byte[], int)", |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
326 |
"byte[] String.getBytes(String) throws java.io.UnsupportedEncodingException", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
327 |
"byte[] String.getBytes(java.nio.charset.Charset)"); |
33362 | 328 |
} |
329 |
||
37939
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
330 |
public void testMethodsWithNoArguments() throws Exception { |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
331 |
dontReadParameterNamesFromClassFile(); |
41865 | 332 |
assertSignature("System.out.println(|", |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
333 |
"void java.io.PrintStream.println()", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
334 |
"void java.io.PrintStream.println(boolean)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
335 |
"void java.io.PrintStream.println(char)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
336 |
"void java.io.PrintStream.println(int)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
337 |
"void java.io.PrintStream.println(long)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
338 |
"void java.io.PrintStream.println(float)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
339 |
"void java.io.PrintStream.println(double)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
340 |
"void java.io.PrintStream.println(char[])", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
341 |
"void java.io.PrintStream.println(String)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
342 |
"void java.io.PrintStream.println(Object)"); |
33362 | 343 |
} |
344 |
||
345 |
public void testErroneous() { |
|
346 |
assertCompletion("Undefined.|"); |
|
41865 | 347 |
assertSignature("does.not.exist|"); |
33362 | 348 |
} |
349 |
||
350 |
public void testClinit() { |
|
351 |
assertEval("enum E{;}"); |
|
352 |
assertEval("class C{static{}}"); |
|
353 |
assertCompletionIncludesExcludes("E.|", Collections.emptySet(), new HashSet<>(Collections.singletonList("<clinit>"))); |
|
354 |
assertCompletionIncludesExcludes("C.|", Collections.emptySet(), new HashSet<>(Collections.singletonList("<clinit>"))); |
|
355 |
} |
|
356 |
||
357 |
public void testMethodHeaderContext() { |
|
358 |
assertCompletion("private void f(Runn|", "Runnable"); |
|
359 |
assertCompletion("void f(Runn|", "Runnable"); |
|
360 |
assertCompletion("void f(Object o1, Runn|", "Runnable"); |
|
361 |
assertCompletion("void f(Object o1) throws Num|", true, "NumberFormatException"); |
|
362 |
assertCompletion("void f(Object o1) throws java.lang.Num|", true, "NumberFormatException"); |
|
363 |
assertEval("class HogeHoge {static class HogeHogeException extends Exception {}}"); |
|
364 |
assertCompletion("void f(Object o1) throws Hoge|", "HogeHoge"); |
|
365 |
assertCompletion("void f(Object o1) throws HogeHoge.|", true, "HogeHogeException"); |
|
366 |
} |
|
367 |
||
368 |
public void testTypeVariables() { |
|
369 |
assertCompletion("class A<TYPE> { public void test() { TY|", "TYPE"); |
|
370 |
assertCompletion("class A<TYPE> { public static void test() { TY|"); |
|
371 |
assertCompletion("class A<TYPE> { public <TYPE> void test() { TY|", "TYPE"); |
|
372 |
assertCompletion("class A<TYPE> { public static <TYPE> void test() { TY|", "TYPE"); |
|
373 |
} |
|
374 |
||
375 |
public void testGeneric() { |
|
376 |
assertEval("import java.util.concurrent.*;"); |
|
377 |
assertCompletion("java.util.List<Integ|", "Integer"); |
|
378 |
assertCompletion("class A<TYPE extends Call|", "Callable"); |
|
379 |
assertCompletion("class A<TYPE extends Callable<TY|", "TYPE"); |
|
380 |
assertCompletion("<TYPE> void f(TY|", "TYPE"); |
|
381 |
assertCompletion("class A<TYPE extends Callable<? sup|", "super"); |
|
382 |
assertCompletion("class A<TYPE extends Callable<? super TY|", "TYPE"); |
|
383 |
} |
|
384 |
||
385 |
public void testFields() { |
|
386 |
assertEval("interface Interface { int field = 0; }"); |
|
387 |
Snippet clazz = classKey(assertEval("class Clazz {" + |
|
388 |
"static int staticField = 0;" + |
|
389 |
"int field = 0;" + |
|
390 |
" }")); |
|
391 |
assertCompletion("Interface.fiel|", "field"); |
|
392 |
assertCompletion("Clazz.staticFiel|", "staticField"); |
|
393 |
assertCompletion("new Interface() {}.fiel|"); |
|
394 |
assertCompletion("new Clazz().staticFiel|"); |
|
395 |
assertCompletion("new Clazz().fiel|", "field"); |
|
396 |
assertCompletion("new Clazz() {}.fiel|", "field"); |
|
397 |
assertEval("class Clazz implements Interface {}", |
|
398 |
ste(MAIN_SNIPPET, VALID, VALID, true, null), |
|
399 |
ste(clazz, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); |
|
400 |
assertCompletion("Clazz.fiel|", "field"); |
|
401 |
assertCompletion("new Clazz().fiel|"); |
|
402 |
assertCompletion("new Clazz() {}.fiel|"); |
|
403 |
} |
|
404 |
||
405 |
public void testMethods() { |
|
406 |
assertEval("interface Interface {" + |
|
407 |
"default int defaultMethod() { return 0; }" + |
|
408 |
"static int staticMethod() { return 0; }" + |
|
409 |
"}"); |
|
410 |
Snippet clazz = classKey(assertEval("class Clazz {" + |
|
411 |
"static int staticMethod() { return 0; }" + |
|
412 |
"int method() { return 0; }" + |
|
413 |
"}")); |
|
414 |
assertCompletion("Interface.staticMeth|", "staticMethod()"); |
|
415 |
assertCompletion("Clazz.staticMeth|", "staticMethod()"); |
|
416 |
assertCompletion("new Interface() {}.defaultMe||", "defaultMethod()"); |
|
417 |
assertCompletion("new Clazz().staticMeth|"); |
|
418 |
assertCompletion("new Clazz().meth|", "method()"); |
|
419 |
assertEval("class Clazz implements Interface {}", |
|
420 |
ste(MAIN_SNIPPET, VALID, VALID, true, null), |
|
421 |
ste(clazz, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); |
|
422 |
assertCompletion("Clazz.staticMeth|"); |
|
423 |
assertCompletion("new Clazz() {}.defaultM|", "defaultMethod()"); |
|
424 |
} |
|
425 |
||
40318
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
426 |
@Test |
33362 | 427 |
public void testUncompletedDeclaration() { |
428 |
assertCompletion("class Clazz { Claz|", "Clazz"); |
|
429 |
assertCompletion("class Clazz { class A extends Claz|", "Clazz"); |
|
40770
dfccc36b61b6
8164952: JShell tests: jdk/jshell/CompletionSuggestionTest.testUncompletedDeclaration(): failure
jlahoda
parents:
40318
diff
changeset
|
430 |
assertCompletion("class Clazz { Clazz clazz; Object o = claz|", "clazz"); |
dfccc36b61b6
8164952: JShell tests: jdk/jshell/CompletionSuggestionTest.testUncompletedDeclaration(): failure
jlahoda
parents:
40318
diff
changeset
|
431 |
assertCompletion("class Clazz { static Clazz clazz; Object o = claz|", "clazz"); |
dfccc36b61b6
8164952: JShell tests: jdk/jshell/CompletionSuggestionTest.testUncompletedDeclaration(): failure
jlahoda
parents:
40318
diff
changeset
|
432 |
assertCompletion("class Clazz { Clazz clazz; static Object o = claz|", true); |
33362 | 433 |
assertCompletion("class Clazz { void method(Claz|", "Clazz"); |
40318
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
434 |
assertCompletion("class A { int method() { return 0; } int a = meth|", "method()"); |
33362 | 435 |
assertCompletion("class A { int field = 0; int method() { return fiel|", "field"); |
40318
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
436 |
assertCompletion("class A { static int method() { return 0; } int a = meth|", "method()"); |
33362 | 437 |
assertCompletion("class A { static int field = 0; int method() { return fiel|", "field"); |
438 |
assertCompletion("class A { int method() { return 0; } static int a = meth|", true); |
|
439 |
assertCompletion("class A { int field = 0; static int method() { return fiel|", true); |
|
440 |
} |
|
441 |
||
40318
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
442 |
@Test |
33362 | 443 |
public void testClassDeclaration() { |
40318
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
444 |
assertEval("void ClazzM() {}"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
445 |
assertEval("void InterfaceM() {}"); |
33362 | 446 |
assertEval("interface Interface {}"); |
447 |
assertCompletion("interface A extends Interf|", "Interface"); |
|
448 |
assertCompletion("class A implements Interf|", "Interface"); |
|
449 |
assertEval("class Clazz {}"); |
|
450 |
assertCompletion("class A extends Claz|", "Clazz"); |
|
451 |
assertCompletion("class A extends Clazz implements Interf|", "Interface"); |
|
452 |
assertEval("interface Interface1 {}"); |
|
453 |
assertCompletion("class A extends Clazz implements Interface, Interf|", "Interface", "Interface1"); |
|
454 |
assertCompletion("interface A implements Claz|"); |
|
455 |
assertCompletion("interface A implements Inter|"); |
|
456 |
assertCompletion("class A implements Claz|", true); |
|
457 |
assertCompletion("class A extends Clazz implements Interface, Interf|", true, "Interface1"); |
|
40318
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
458 |
assertCompletion("class A extends Clazz implements Interface, Interf|", true, "Interface1"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
459 |
assertEval("class InterfaceClazz {}"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
460 |
assertCompletion("class A <T extends Claz|", "Clazz"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
461 |
assertCompletion("class A <T extends Interf|", "Interface", "Interface1", "InterfaceClazz"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
462 |
assertCompletion("class A <T extends Interface & Interf|", "Interface", "Interface1", "InterfaceClazz"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
463 |
assertCompletion("class A <T extends Clazz & Interf|", "Interface", "Interface1", "InterfaceClazz"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
464 |
assertCompletion("class A <T extends Claz|", true, "Clazz"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
465 |
assertCompletion("class A <T extends Interf|", true, "Interface", "Interface1", "InterfaceClazz"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
466 |
assertCompletion("class A <T extends Interface & Interf|", true, "Interface1"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
467 |
assertCompletion("class A <T extends Clazz & Interf|", true, "Interface", "Interface1"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
468 |
} |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
469 |
|
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
470 |
public void testMethodDeclaration() { |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
471 |
assertEval("void ClazzM() {}"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
472 |
assertEval("void InterfaceM() {}"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
473 |
assertEval("interface Interface {}"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
474 |
assertCompletion("void m(Interf|", "Interface"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
475 |
assertCompletion("void m(Interface i1, Interf|", "Interface"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
476 |
assertEval("class InterfaceException extends Exception {}"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
477 |
assertCompletion("void m(Interface i1) throws Interf|", "Interface", "InterfaceException"); |
3f7eb1205cee
8129421: JShell: unacceptable suggestions in 'extends', 'implements' in smart completion
jlahoda
parents:
37939
diff
changeset
|
478 |
assertCompletion("void m(Interface i1) throws Interf|", true, "InterfaceException"); |
33362 | 479 |
} |
480 |
||
481 |
public void testDocumentationOfUserDefinedMethods() { |
|
482 |
assertEval("void f() {}"); |
|
41865 | 483 |
assertSignature("f(|", "void f()"); |
37939
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
484 |
assertEval("void f(int i) {}"); |
41865 | 485 |
assertSignature("f(|", "void f()", "void f(int i)"); |
37939
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
486 |
assertEval("<T> void f(T... ts) {}", DiagCheck.DIAG_WARNING, DiagCheck.DIAG_OK); |
41865 | 487 |
assertSignature("f(|", "void f()", "void f(int i)", "void <T>f(T... ts)"); |
33362 | 488 |
assertEval("class A {}"); |
489 |
assertEval("void f(A a) {}"); |
|
41865 | 490 |
assertSignature("f(|", "void f()", "void f(int i)", "void <T>f(T... ts)", "void f(A a)"); |
491 |
} |
|
492 |
||
493 |
public void testClass() { |
|
494 |
assertSignature("String|", "java.lang.String"); |
|
33362 | 495 |
} |
496 |
||
497 |
public void testDocumentationOfUserDefinedConstructors() { |
|
498 |
Snippet a = classKey(assertEval("class A {}")); |
|
41865 | 499 |
assertSignature("new A(|", "A()"); |
37939
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
500 |
Snippet a2 = classKey(assertEval("class A { A() {} A(int i) {}}", |
33362 | 501 |
ste(MAIN_SNIPPET, VALID, VALID, true, null), |
502 |
ste(a, VALID, OVERWRITTEN, false, MAIN_SNIPPET))); |
|
41865 | 503 |
assertSignature("new A(|", "A()", "A(int i)"); |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
504 |
assertEval("class A<T> { A(T a) {} A(int i) {} <U> A(T t, U u) {}}", |
33362 | 505 |
ste(MAIN_SNIPPET, VALID, VALID, true, null), |
506 |
ste(a2, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); |
|
41865 | 507 |
assertSignature("new A(|", "A<T>(T a)", "A<T>(int i)", "<U> A<T>(T t, U u)"); |
33362 | 508 |
} |
509 |
||
37939
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
510 |
public void testDocumentationOfOverriddenMethods() throws Exception { |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
511 |
dontReadParameterNamesFromClassFile(); |
41865 | 512 |
assertSignature("\"\".wait(|", |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
513 |
"void Object.wait(long) throws InterruptedException", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
514 |
"void Object.wait(long, int) throws InterruptedException", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
515 |
"void Object.wait() throws InterruptedException"); |
33362 | 516 |
assertEval("class Base {void method() {}}"); |
517 |
Snippet e = classKey(assertEval("class Extend extends Base {}")); |
|
41865 | 518 |
assertSignature("new Extend().method(|", "void Base.method()"); |
33362 | 519 |
assertEval("class Extend extends Base {void method() {}}", |
520 |
ste(MAIN_SNIPPET, VALID, VALID, true, null), |
|
521 |
ste(e, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); |
|
41865 | 522 |
assertSignature("new Extend().method(|", "void Extend.method()"); |
33362 | 523 |
} |
524 |
||
525 |
public void testDocumentationOfInvisibleMethods() { |
|
41865 | 526 |
assertSignature("Object.wait(|"); |
527 |
assertSignature("\"\".indexOfSupplementary(|"); |
|
33362 | 528 |
Snippet a = classKey(assertEval("class A {void method() {}}")); |
41865 | 529 |
assertSignature("A.method(|"); |
33362 | 530 |
assertEval("class A {private void method() {}}", |
531 |
ste(MAIN_SNIPPET, VALID, VALID, true, null), |
|
532 |
ste(a, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); |
|
41865 | 533 |
assertSignature("new A().method(|"); |
33362 | 534 |
} |
535 |
||
536 |
public void testDocumentationOfInvisibleConstructors() { |
|
41865 | 537 |
assertSignature("new Compiler(|"); |
33362 | 538 |
assertEval("class A { private A() {} }"); |
41865 | 539 |
assertSignature("new A(|"); |
33362 | 540 |
} |
541 |
||
542 |
public void testDocumentationWithBoxing() { |
|
543 |
assertEval("int primitive = 0;"); |
|
544 |
assertEval("Integer boxed = 0;"); |
|
545 |
assertEval("Object object = null;"); |
|
546 |
assertEval("void method(int n, Object o) { }"); |
|
547 |
assertEval("void method(Object n, int o) { }"); |
|
41865 | 548 |
assertSignature("method(primitive,|", |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
549 |
"void method(int n, Object o)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
550 |
"void method(Object n, int o)"); |
41865 | 551 |
assertSignature("method(boxed,|", |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
552 |
"void method(int n, Object o)", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
553 |
"void method(Object n, int o)"); |
41865 | 554 |
assertSignature("method(object,|", |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
555 |
"void method(Object n, int o)"); |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
556 |
} |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
557 |
|
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
558 |
public void testDocumentationWithGenerics() { |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
559 |
class TestDocumentationWithGenerics { |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
560 |
private final Function<Integer, String> codeFacotry; |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
561 |
private final BiFunction<String, Integer, String> evalFormatter; |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
562 |
private final BiFunction<String, Integer, String> docFormatter; |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
563 |
int count; |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
564 |
|
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
565 |
TestDocumentationWithGenerics( |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
566 |
Function<Integer, String> codeFactory, |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
567 |
BiFunction<String, Integer, String> evalFormatter, |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
568 |
BiFunction<String, Integer, String> documentationFormatter) { |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
569 |
this.codeFacotry = codeFactory; |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
570 |
this.evalFormatter = evalFormatter; |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
571 |
this.docFormatter = documentationFormatter; |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
572 |
} |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
573 |
|
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
574 |
void assertDoc(String generics) { |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
575 |
assertDoc(generics, generics); |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
576 |
} |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
577 |
|
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
578 |
void assertDoc(String generics, String expectedGenerics) { |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
579 |
assertEval(evalFormatter.apply(generics, count)); |
41865 | 580 |
assertSignature(codeFacotry.apply(count), docFormatter.apply(expectedGenerics, count)); |
41527
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
581 |
count++; |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
582 |
} |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
583 |
} |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
584 |
|
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
585 |
TestDocumentationWithGenerics[] tests = { |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
586 |
new TestDocumentationWithGenerics( |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
587 |
i -> "f" + i + "(|", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
588 |
(g, i) -> "<" + g + "> void f" + i + "() {}", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
589 |
(g, i) -> "void <" + g + ">f" + i + "()" |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
590 |
), |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
591 |
new TestDocumentationWithGenerics( |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
592 |
i -> "new C" + i + "().f(|", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
593 |
(g, i) -> "class C" + i + "<" + g + "> { void f() {} }", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
594 |
(g, i) -> "void C" + i + "<" + g + ">.f()" |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
595 |
) |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
596 |
}; |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
597 |
|
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
598 |
Arrays.stream(tests).forEach(t -> { |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
599 |
t.assertDoc("T"); |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
600 |
t.assertDoc("T extends Object", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
601 |
"T"); |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
602 |
t.assertDoc("T extends String"); |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
603 |
t.assertDoc("T extends java.lang.String", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
604 |
"T extends String"); |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
605 |
t.assertDoc("T extends Number & Comparable<T>"); |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
606 |
t.assertDoc("T extends java.io.Serializable & CharSequence"); |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
607 |
t.assertDoc("K, D, M extends java.util.Map<K, D>", |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
608 |
"K, D, M extends java.util.Map<K,D>"); |
e8f487b79e24
8145263: JShell: Fix the format of SourceCodeAnalysis#documentation
shinyafox
parents:
40837
diff
changeset
|
609 |
}); |
33362 | 610 |
} |
611 |
||
612 |
public void testVarArgs() { |
|
613 |
assertEval("int i = 0;"); |
|
614 |
assertEval("class Foo1 { static void m(int... i) { } } "); |
|
615 |
assertCompletion("Foo1.m(|", true, "i"); |
|
616 |
assertCompletion("Foo1.m(i, |", true, "i"); |
|
617 |
assertCompletion("Foo1.m(i, i, |", true, "i"); |
|
618 |
assertEval("class Foo2 { static void m(String s, int... i) { } } "); |
|
619 |
assertCompletion("Foo2.m(|", true); |
|
620 |
assertCompletion("Foo2.m(i, |", true); |
|
621 |
assertCompletion("Foo2.m(\"\", |", true, "i"); |
|
622 |
assertCompletion("Foo2.m(\"\", i, |", true, "i"); |
|
623 |
assertCompletion("Foo2.m(\"\", i, i, |", true, "i"); |
|
624 |
assertEval("class Foo3 { Foo3(String s, int... i) { } } "); |
|
625 |
assertCompletion("new Foo3(|", true); |
|
626 |
assertCompletion("new Foo3(i, |", true); |
|
627 |
assertCompletion("new Foo3(\"\", |", true, "i"); |
|
628 |
assertCompletion("new Foo3(\"\", i, |", true, "i"); |
|
629 |
assertCompletion("new Foo3(\"\", i, i, |", true, "i"); |
|
630 |
assertEval("int[] ia = null;"); |
|
631 |
assertCompletion("Foo1.m(ia, |", true); |
|
632 |
assertEval("class Foo4 { static void m(int... i) { } static void m(int[] ia, String str) { } } "); |
|
633 |
assertEval("String str = null;"); |
|
634 |
assertCompletion("Foo4.m(ia, |", true, "str"); |
|
635 |
} |
|
636 |
||
637 |
public void testConstructorAsMemberOf() { |
|
638 |
assertEval("class Baz<X> { Baz(X x) { } } "); |
|
639 |
assertEval("String str = null;"); |
|
640 |
assertEval("Integer i = null;"); |
|
641 |
assertCompletion("new Baz(|", true, "i", "str"); |
|
642 |
assertCompletion("new Baz<String>(|", true, "str"); |
|
643 |
assertCompletion("Baz<String> bz = new Baz<>(|", true, "str"); |
|
644 |
assertEval("class Foo { static void m(String str) {} static void m(Baz<String> baz) {} }"); |
|
645 |
assertCompletion("Foo.m(new Baz<>(|", true, "str"); |
|
646 |
} |
|
37939
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
647 |
|
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
648 |
@BeforeMethod |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
649 |
public void setUp() { |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
650 |
super.setUp(); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
651 |
|
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
652 |
Path srcZip = Paths.get("src.zip"); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
653 |
|
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
654 |
try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(srcZip))) { |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
655 |
out.putNextEntry(new JarEntry("java/lang/System.java")); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
656 |
out.write(("package java.lang;\n" + |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
657 |
"public class System {\n" + |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
658 |
" public String getProperty(String key) { return null; }\n" + |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
659 |
" public String getProperty(String key, String def) { return def; }\n" + |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
660 |
"}\n").getBytes()); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
661 |
} catch (IOException ex) { |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
662 |
throw new IllegalStateException(ex); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
663 |
} |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
664 |
|
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
665 |
try { |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
666 |
Field availableSources = getAnalysis().getClass().getDeclaredField("availableSources"); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
667 |
availableSources.setAccessible(true); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
668 |
availableSources.set(getAnalysis(), Arrays.asList(srcZip)); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
669 |
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) { |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
670 |
throw new IllegalStateException(ex); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
671 |
} |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
672 |
} |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
673 |
|
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
674 |
private void dontReadParameterNamesFromClassFile() throws Exception { |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
675 |
Field keepParameterNames = getAnalysis().getClass().getDeclaredField("keepParameterNames"); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
676 |
keepParameterNames.setAccessible(true); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
677 |
keepParameterNames.set(getAnalysis(), new String[0]); |
3eb8c2a89b77
8153761: JShell: Completion -- Show parameter names if possible
jlahoda
parents:
36778
diff
changeset
|
678 |
} |
40837
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
679 |
|
43146
7c249fca6c06
8172678: JShell Tests: Disable CompletionSuggestionTest.testBrokenClassFile2()
rfield
parents:
42407
diff
changeset
|
680 |
@Test(enabled = false) //TODO 8171829 |
40837
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
681 |
public void testBrokenClassFile2() throws IOException { |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
682 |
Path broken = outDir.resolve("broken"); |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
683 |
compiler.compile(broken, |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
684 |
"package p;\n" + |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
685 |
"public class BrokenA {\n" + |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
686 |
"}", |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
687 |
"package p.q;\n" + |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
688 |
"public class BrokenB {\n" + |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
689 |
"}", |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
690 |
"package p;\n" + |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
691 |
"public class BrokenC {\n" + |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
692 |
"}"); |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
693 |
Path cp = compiler.getPath(broken); |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
694 |
Path target = cp.resolve("p").resolve("BrokenB.class"); |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
695 |
Files.deleteIfExists(target); |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
696 |
Files.move(cp.resolve("p").resolve("q").resolve("BrokenB.class"), target); |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
697 |
addToClasspath(cp); |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
698 |
|
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
699 |
assertEval("import p.*;"); |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
700 |
assertCompletion("Broke|", "BrokenA", "BrokenC"); |
d071bcc8d32e
8131025: JShell: crash on tab-complete reference to bad class file
jlahoda
parents:
40770
diff
changeset
|
701 |
} |
33362 | 702 |
} |