author | rfield |
Tue, 19 Dec 2017 11:37:00 -0800 | |
changeset 48349 | 3d4e8f5a2a69 |
parent 48292 | 191ae61bd1e9 |
child 48610 | a587f95313f1 |
permissions | -rw-r--r-- |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
1 |
/* |
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
4 |
* |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
8 |
* |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
13 |
* accompanied this code). |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
14 |
* |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
18 |
* |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
21 |
* questions. |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
22 |
*/ |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
23 |
|
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
24 |
/* |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
25 |
* @test |
48273
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
26 |
* @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079 8180508 8177466 8172154 8192979 |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
27 |
* @summary Simple jshell tool tests |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
28 |
* @modules jdk.compiler/com.sun.tools.javac.api |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
29 |
* jdk.compiler/com.sun.tools.javac.main |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
30 |
* jdk.jdeps/com.sun.tools.javap |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
31 |
* jdk.jshell/jdk.internal.jshell.tool |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
32 |
* @build KullaTesting TestingInputStream |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
33 |
* @run testng ToolSimpleTest |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
34 |
*/ |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
35 |
import java.util.Arrays; |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
36 |
import java.util.ArrayList; |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
37 |
import java.util.List; |
41937
1313399705e9
8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents:
41635
diff
changeset
|
38 |
import java.util.Locale; |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
39 |
import java.util.function.Consumer; |
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
40 |
import java.util.regex.Pattern; |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
41 |
import java.util.stream.Collectors; |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
42 |
import java.util.stream.Stream; |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
43 |
|
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
44 |
import org.testng.annotations.Test; |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
45 |
|
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
46 |
import static org.testng.Assert.assertEquals; |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
47 |
import static org.testng.Assert.assertTrue; |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
48 |
|
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
49 |
public class ToolSimpleTest extends ReplToolTesting { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
50 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
51 |
@Test |
37389 | 52 |
public void testRemaining() { |
53 |
test( |
|
54 |
(a) -> assertCommand(a, "int z; z =", "z ==> 0"), |
|
55 |
(a) -> assertCommand(a, "5", "z ==> 5"), |
|
56 |
(a) -> assertCommand(a, "/*nada*/; int q =", ""), |
|
57 |
(a) -> assertCommand(a, "77", "q ==> 77"), |
|
58 |
(a) -> assertCommand(a, "//comment;", ""), |
|
59 |
(a) -> assertCommand(a, "int v;", "v ==> 0"), |
|
60 |
(a) -> assertCommand(a, "int v; int c", |
|
61 |
"v ==> 0\n" + |
|
62 |
"c ==> 0") |
|
63 |
); |
|
64 |
} |
|
65 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
66 |
@Test |
38835
37280d52d723
8131024: JShell: multi-line comment not detected as incomplete
rfield
parents:
38539
diff
changeset
|
67 |
public void testOpenComment() { |
37280d52d723
8131024: JShell: multi-line comment not detected as incomplete
rfield
parents:
38539
diff
changeset
|
68 |
test( |
37280d52d723
8131024: JShell: multi-line comment not detected as incomplete
rfield
parents:
38539
diff
changeset
|
69 |
(a) -> assertCommand(a, "int z = /* blah", ""), |
37280d52d723
8131024: JShell: multi-line comment not detected as incomplete
rfield
parents:
38539
diff
changeset
|
70 |
(a) -> assertCommand(a, "baz */ 5", "z ==> 5"), |
37280d52d723
8131024: JShell: multi-line comment not detected as incomplete
rfield
parents:
38539
diff
changeset
|
71 |
(a) -> assertCommand(a, "/** hoge ", ""), |
37280d52d723
8131024: JShell: multi-line comment not detected as incomplete
rfield
parents:
38539
diff
changeset
|
72 |
(a) -> assertCommand(a, "baz **/", ""), |
37280d52d723
8131024: JShell: multi-line comment not detected as incomplete
rfield
parents:
38539
diff
changeset
|
73 |
(a) -> assertCommand(a, "int v", "v ==> 0") |
37280d52d723
8131024: JShell: multi-line comment not detected as incomplete
rfield
parents:
38539
diff
changeset
|
74 |
); |
37280d52d723
8131024: JShell: multi-line comment not detected as incomplete
rfield
parents:
38539
diff
changeset
|
75 |
} |
37280d52d723
8131024: JShell: multi-line comment not detected as incomplete
rfield
parents:
38539
diff
changeset
|
76 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
77 |
@Test |
43586
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
78 |
public void testLessThan() { |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
79 |
test( |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
80 |
(a) -> assertCommand(a, "45", "$1 ==> 45"), |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
81 |
(a) -> assertCommand(a, "72", "$2 ==> 72"), |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
82 |
(a) -> assertCommand(a, "$1 < $2", "$3 ==> true"), |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
83 |
(a) -> assertCommand(a, "int a, b", "a ==> 0\n" + |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
84 |
"b ==> 0"), |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
85 |
(a) -> assertCommand(a, "a < b", "$6 ==> false") |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
86 |
); |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
87 |
} |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
88 |
|
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
43274
diff
changeset
|
89 |
@Test |
37389 | 90 |
public void oneLineOfError() { |
91 |
test( |
|
92 |
(a) -> assertCommand(a, "12+", null), |
|
93 |
(a) -> assertCommandCheckOutput(a, " true", (s) -> |
|
94 |
assertTrue(s.contains("12+") && !s.contains("true"), "Output: '" + s + "'")) |
|
95 |
); |
|
96 |
} |
|
97 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
98 |
@Test |
37389 | 99 |
public void defineVariables() { |
100 |
test( |
|
101 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
102 |
(a) -> assertCommandCheckOutput(a, "/vars", assertVariables()), |
|
103 |
(a) -> assertVariable(a, "int", "a"), |
|
104 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
105 |
(a) -> assertCommandCheckOutput(a, "/vars", assertVariables()), |
|
106 |
(a) -> assertVariable(a, "double", "a", "1", "1.0"), |
|
107 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
108 |
(a) -> assertCommandCheckOutput(a, "/vars", assertVariables()), |
|
109 |
(a) -> evaluateExpression(a, "double", "2 * a", "2.0"), |
|
110 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
111 |
(a) -> assertCommandCheckOutput(a, "/vars", assertVariables()) |
|
112 |
); |
|
113 |
} |
|
114 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
115 |
@Test |
37389 | 116 |
public void defineMethods() { |
117 |
test( |
|
118 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
119 |
(a) -> assertCommandCheckOutput(a, "/methods", assertMethods()), |
|
120 |
(a) -> assertMethod(a, "int f() { return 0; }", "()int", "f"), |
|
121 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
122 |
(a) -> assertCommandCheckOutput(a, "/methods", assertMethods()), |
|
123 |
(a) -> assertMethod(a, "void f(int a) { g(); }", "(int)void", "f"), |
|
124 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
125 |
(a) -> assertCommandCheckOutput(a, "/methods", assertMethods()), |
|
126 |
(a) -> assertMethod(a, "void g() {}", "()void", "g"), |
|
127 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
128 |
(a) -> assertCommandCheckOutput(a, "/methods", assertMethods()) |
|
129 |
); |
|
130 |
} |
|
131 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
132 |
@Test |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
133 |
public void defineTypes() { |
37389 | 134 |
test( |
135 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
136 |
(a) -> assertCommandCheckOutput(a, "/types", assertClasses()), |
37389 | 137 |
(a) -> assertClass(a, "class A { }", "class", "A"), |
138 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
139 |
(a) -> assertCommandCheckOutput(a, "/types", assertClasses()), |
37389 | 140 |
(a) -> assertClass(a, "interface A { }", "interface", "A"), |
141 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
142 |
(a) -> assertCommandCheckOutput(a, "/types", assertClasses()), |
37389 | 143 |
(a) -> assertClass(a, "enum A { }", "enum", "A"), |
144 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
145 |
(a) -> assertCommandCheckOutput(a, "/types", assertClasses()), |
37389 | 146 |
(a) -> assertClass(a, "@interface A { }", "@interface", "A"), |
147 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
148 |
(a) -> assertCommandCheckOutput(a, "/types", assertClasses()) |
37389 | 149 |
); |
150 |
} |
|
151 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
152 |
@Test |
37389 | 153 |
public void defineImports() { |
154 |
test( |
|
155 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
156 |
(a) -> assertCommandCheckOutput(a, "/imports", assertImports()), |
|
157 |
(a) -> assertImport(a, "import java.util.stream.Stream;", "", "java.util.stream.Stream"), |
|
158 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
159 |
(a) -> assertCommandCheckOutput(a, "/imports", assertImports()), |
|
160 |
(a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"), |
|
161 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
162 |
(a) -> assertCommandCheckOutput(a, "/imports", assertImports()), |
|
163 |
(a) -> assertImport(a, "import static java.lang.Math.PI;", "static", "java.lang.Math.PI"), |
|
164 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
165 |
(a) -> assertCommandCheckOutput(a, "/imports", assertImports()), |
|
166 |
(a) -> assertImport(a, "import static java.lang.Math.*;", "static", "java.lang.Math.*"), |
|
167 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
|
168 |
(a) -> assertCommandCheckOutput(a, "/imports", assertImports()) |
|
169 |
); |
|
170 |
} |
|
171 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
172 |
@Test |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
173 |
public void defineVar() { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
174 |
test( |
37389 | 175 |
(a) -> assertCommand(a, "int x = 72", "x ==> 72"), |
176 |
(a) -> assertCommand(a, "x", "x ==> 72"), |
|
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
177 |
(a) -> assertCommand(a, "/vars", "| int x = 72") |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
178 |
); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
179 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
180 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
181 |
@Test |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
182 |
public void defineUnresolvedVar() { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
183 |
test( |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
184 |
(a) -> assertCommand(a, "undefined x", |
37389 | 185 |
"| created variable x, however, it cannot be referenced until class undefined is declared"), |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
186 |
(a) -> assertCommand(a, "/vars", "| undefined x = (not-active)") |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
187 |
); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
188 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
189 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
190 |
@Test |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
191 |
public void testUnresolved() { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
192 |
test( |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
193 |
(a) -> assertCommand(a, "int f() { return g() + x + new A().a; }", |
37389 | 194 |
"| created method f(), however, it cannot be invoked until method g(), variable x, and class A are declared"), |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
195 |
(a) -> assertCommand(a, "f()", |
37389 | 196 |
"| attempted to call method f() which cannot be invoked until method g(), variable x, and class A are declared"), |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
197 |
(a) -> assertCommandOutputStartsWith(a, "int g() { return x; }", |
37389 | 198 |
"| created method g(), however, it cannot be invoked until variable x is declared"), |
199 |
(a) -> assertCommand(a, "g()", "| attempted to call method g() which cannot be invoked until variable x is declared") |
|
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
200 |
); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
201 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
202 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
203 |
@Test |
37389 | 204 |
public void testUnknownCommand() { |
205 |
test((a) -> assertCommand(a, "/unknown", |
|
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
206 |
"| Invalid command: /unknown\n" + |
37389 | 207 |
"| Type /help for help.")); |
208 |
} |
|
209 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
210 |
@Test |
37389 | 211 |
public void testEmptyClassPath() { |
43038 | 212 |
test(after -> assertCommand(after, "/env --class-path", "| Argument to class-path missing.")); |
37389 | 213 |
} |
214 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
215 |
@Test |
43856
fcdebb803c62
8174797: jshell tool: invalid module path crashes tool
rfield
parents:
43766
diff
changeset
|
216 |
public void testInvalidClassPath() { |
fcdebb803c62
8174797: jshell tool: invalid module path crashes tool
rfield
parents:
43766
diff
changeset
|
217 |
test( |
43861
825bad9a162a
8174862: JShell tests: new JDK-8174797 testInvalidClassPath fails on Windows
rfield
parents:
43856
diff
changeset
|
218 |
a -> assertCommand(a, "/env --class-path snurgefusal", |
48259
c0bf7d8af037
8191636: [Windows] jshell tool: Wrong character in /env class-path command crashes jshell
jlahoda
parents:
47837
diff
changeset
|
219 |
"| File 'snurgefusal' for '--class-path' is not found."), |
c0bf7d8af037
8191636: [Windows] jshell tool: Wrong character in /env class-path command crashes jshell
jlahoda
parents:
47837
diff
changeset
|
220 |
a -> assertCommand(a, "/env --class-path ?", |
c0bf7d8af037
8191636: [Windows] jshell tool: Wrong character in /env class-path command crashes jshell
jlahoda
parents:
47837
diff
changeset
|
221 |
"| File '?' for '--class-path' is not found.") |
43856
fcdebb803c62
8174797: jshell tool: invalid module path crashes tool
rfield
parents:
43766
diff
changeset
|
222 |
); |
fcdebb803c62
8174797: jshell tool: invalid module path crashes tool
rfield
parents:
43766
diff
changeset
|
223 |
} |
fcdebb803c62
8174797: jshell tool: invalid module path crashes tool
rfield
parents:
43766
diff
changeset
|
224 |
|
fcdebb803c62
8174797: jshell tool: invalid module path crashes tool
rfield
parents:
43766
diff
changeset
|
225 |
@Test |
37389 | 226 |
public void testNoArgument() { |
38539 | 227 |
test( |
228 |
(a) -> assertCommand(a, "/save", |
|
229 |
"| '/save' requires a filename argument."), |
|
230 |
(a) -> assertCommand(a, "/open", |
|
231 |
"| '/open' requires a filename argument."), |
|
41635
cb3d04878117
8163840: jshell tool: provide way to display configuration settings
rfield
parents:
41514
diff
changeset
|
232 |
(a) -> assertCommandOutputStartsWith(a, "/drop", |
cb3d04878117
8163840: jshell tool: provide way to display configuration settings
rfield
parents:
41514
diff
changeset
|
233 |
"| In the /drop argument, please specify an import, variable, method, or class to drop.") |
38539 | 234 |
); |
37389 | 235 |
} |
236 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
237 |
@Test |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
238 |
public void testDebug() { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
239 |
test( |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
240 |
(a) -> assertCommand(a, "/deb", "| Debugging on"), |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
241 |
(a) -> assertCommand(a, "/debug", "| Debugging off"), |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
242 |
(a) -> assertCommand(a, "/debug", "| Debugging on"), |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
243 |
(a) -> assertCommand(a, "/deb", "| Debugging off") |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
244 |
); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
245 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
246 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
247 |
@Test |
37389 | 248 |
public void testDrop() { |
40588
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
249 |
test(false, new String[]{"--no-startup"}, |
37389 | 250 |
a -> assertVariable(a, "int", "a"), |
251 |
a -> dropVariable(a, "/drop 1", "int a = 0", "| dropped variable a"), |
|
43759
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
252 |
a -> assertMethod(a, "int b() { return 0; }", "()int", "b"), |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
253 |
a -> dropMethod(a, "/drop 2", "int b()", "| dropped method b()"), |
37389 | 254 |
a -> assertClass(a, "class A {}", "class", "A"), |
255 |
a -> dropClass(a, "/drop 3", "class A", "| dropped class A"), |
|
256 |
a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"), |
|
257 |
a -> dropImport(a, "/drop 4", "import java.util.stream.*", ""), |
|
41514
a75c2b869d8d
8167128: JShell: /drop of statement gives confusing output
rfield
parents:
40601
diff
changeset
|
258 |
a -> assertCommand(a, "for (int i = 0; i < 10; ++i) {}", ""), |
a75c2b869d8d
8167128: JShell: /drop of statement gives confusing output
rfield
parents:
40601
diff
changeset
|
259 |
a -> assertCommand(a, "/drop 5", ""), |
a75c2b869d8d
8167128: JShell: /drop of statement gives confusing output
rfield
parents:
40601
diff
changeset
|
260 |
a -> assertCommand(a, "/list", ""), |
37389 | 261 |
a -> assertCommandCheckOutput(a, "/vars", assertVariables()), |
262 |
a -> assertCommandCheckOutput(a, "/methods", assertMethods()), |
|
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
263 |
a -> assertCommandCheckOutput(a, "/types", assertClasses()), |
37389 | 264 |
a -> assertCommandCheckOutput(a, "/imports", assertImports()) |
265 |
); |
|
40588
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
266 |
test(false, new String[]{"--no-startup"}, |
37389 | 267 |
a -> assertVariable(a, "int", "a"), |
268 |
a -> dropVariable(a, "/drop a", "int a = 0", "| dropped variable a"), |
|
43759
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
269 |
a -> assertMethod(a, "int b() { return 0; }", "()int", "b"), |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
270 |
a -> dropMethod(a, "/drop b", "int b()", "| dropped method b()"), |
37389 | 271 |
a -> assertClass(a, "class A {}", "class", "A"), |
272 |
a -> dropClass(a, "/drop A", "class A", "| dropped class A"), |
|
273 |
a -> assertCommandCheckOutput(a, "/vars", assertVariables()), |
|
274 |
a -> assertCommandCheckOutput(a, "/methods", assertMethods()), |
|
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
275 |
a -> assertCommandCheckOutput(a, "/types", assertClasses()), |
37389 | 276 |
a -> assertCommandCheckOutput(a, "/imports", assertImports()) |
277 |
); |
|
278 |
} |
|
279 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
280 |
@Test |
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
281 |
public void testDropRange() { |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
282 |
test(false, new String[]{"--no-startup"}, |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
283 |
a -> assertVariable(a, "int", "a"), |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
284 |
a -> assertMethod(a, "int b() { return 0; }", "()int", "b"), |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
285 |
a -> assertClass(a, "class A {}", "class", "A"), |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
286 |
a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"), |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
287 |
a -> assertCommand(a, "for (int i = 0; i < 10; ++i) {}", ""), |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
288 |
a -> assertCommand(a, "/drop 3-5 b 1", |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
289 |
"| dropped class A\n" + |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
290 |
"| dropped method b()\n" + |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
291 |
"| dropped variable a\n"), |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
292 |
a -> assertCommand(a, "/list", "") |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
293 |
); |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
294 |
} |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
295 |
|
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
296 |
@Test |
37389 | 297 |
public void testDropNegative() { |
40588
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
298 |
test(false, new String[]{"--no-startup"}, |
48349
3d4e8f5a2a69
8179858: jshell tool: sync nomenclature from reference to online /help
rfield
parents:
48292
diff
changeset
|
299 |
a -> assertCommandOutputStartsWith(a, "/drop 0", "| No snippet with ID: 0"), |
38539 | 300 |
a -> assertCommandOutputStartsWith(a, "/drop a", "| No such snippet: a"), |
37389 | 301 |
a -> assertCommandCheckOutput(a, "/drop", |
302 |
assertStartsWith("| In the /drop argument, please specify an import, variable, method, or class to drop.")), |
|
303 |
a -> assertVariable(a, "int", "a"), |
|
304 |
a -> assertCommand(a, "a", "a ==> 0"), |
|
41514
a75c2b869d8d
8167128: JShell: /drop of statement gives confusing output
rfield
parents:
40601
diff
changeset
|
305 |
a -> assertCommand(a, "/drop 2", ""), |
38539 | 306 |
a -> assertCommand(a, "/drop 2", |
307 |
"| This command does not accept the snippet '2' : a\n" + |
|
308 |
"| See /types, /methods, /vars, or /list") |
|
37389 | 309 |
); |
310 |
} |
|
311 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
312 |
@Test |
37389 | 313 |
public void testAmbiguousDrop() { |
314 |
test( |
|
315 |
a -> assertVariable(a, "int", "a"), |
|
316 |
a -> assertMethod(a, "int a() { return 0; }", "()int", "a"), |
|
317 |
a -> assertClass(a, "class a {}", "class", "a"), |
|
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
318 |
a -> assertCommand(a, "/drop a", |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
319 |
"| dropped variable a\n" + |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
320 |
"| dropped method a()\n" + |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
321 |
"| dropped class a") |
37389 | 322 |
); |
323 |
test( |
|
324 |
a -> assertMethod(a, "int a() { return 0; }", "()int", "a"), |
|
325 |
a -> assertMethod(a, "double a(int a) { return 0; }", "(int)double", "a"), |
|
326 |
a -> assertMethod(a, "double a(double a) { return 0; }", "(double)double", "a"), |
|
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
327 |
a -> assertCommand(a, "/drop a", |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
328 |
"| dropped method a()\n" + |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
329 |
"| dropped method a(int)\n" + |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
330 |
"| dropped method a(double)\n") |
37389 | 331 |
); |
332 |
} |
|
333 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
334 |
@Test |
42412
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
335 |
public void testApplicationOfPost() { |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
336 |
test( |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
337 |
(a) -> assertCommand(a, "/set mode t normal -command", "| Created new feedback mode: t"), |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
338 |
(a) -> assertCommand(a, "/set feedback t", "| Feedback mode: t"), |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
339 |
(a) -> assertCommand(a, "/set format t post \"$%n\"", ""), |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
340 |
(a) -> assertCommand(a, "/set prompt t \"+\" \"-\"", ""), |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
341 |
(a) -> assertCommand(a, "/set prompt t", "| /set prompt t \"+\" \"-\"$") |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
342 |
); |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
343 |
} |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
344 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
345 |
@Test |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
346 |
public void testHelpLength() { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
347 |
Consumer<String> testOutput = (s) -> { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
348 |
List<String> ss = Stream.of(s.split("\n")) |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
349 |
.filter(l -> !l.isEmpty()) |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
350 |
.collect(Collectors.toList()); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
351 |
assertTrue(ss.size() >= 10, "Help does not print enough lines:" + s); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
352 |
}; |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
353 |
test( |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
354 |
(a) -> assertCommandCheckOutput(a, "/?", testOutput), |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
355 |
(a) -> assertCommandCheckOutput(a, "/help", testOutput), |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
356 |
(a) -> assertCommandCheckOutput(a, "/help /list", testOutput) |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
357 |
); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
358 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
359 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
360 |
@Test |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
361 |
public void testHelp() { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
362 |
test( |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
363 |
(a) -> assertHelp(a, "/?", "/list", "/help", "/exit", "intro"), |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
364 |
(a) -> assertHelp(a, "/help", "/list", "/help", "/exit", "intro"), |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
365 |
(a) -> assertHelp(a, "/help short", "shortcuts", "<tab>"), |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
366 |
(a) -> assertHelp(a, "/? /li", "/list -all", "snippets"), |
42412
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
367 |
(a) -> assertHelp(a, "/help /set prompt", "optionally contain '%s'", "quoted"), |
44454
74af976d6798
8177079: jshell tool: usability of /help for commands and sub-commands
rfield
parents:
43861
diff
changeset
|
368 |
(a) -> assertHelp(a, "/help /help", "/help <command>"), |
74af976d6798
8177079: jshell tool: usability of /help for commands and sub-commands
rfield
parents:
43861
diff
changeset
|
369 |
(a) -> assertHelp(a, "/help li", "/list -start"), |
74af976d6798
8177079: jshell tool: usability of /help for commands and sub-commands
rfield
parents:
43861
diff
changeset
|
370 |
(a) -> assertHelp(a, "/help fe", "/set feedback -retain") |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
371 |
); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
372 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
373 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
374 |
@Test |
48273
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
375 |
public void testHelpStart() { |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
376 |
test( |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
377 |
(a) -> assertCommandCheckOutput(a, "/help /exit", |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
378 |
s -> assertTrue(s.replaceAll("\\r\\n?", "\n").startsWith( |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
379 |
"| \n" + |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
380 |
"| /exit\n" + |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
381 |
"| =====\n" + |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
382 |
"| " |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
383 |
)) |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
384 |
) |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
385 |
); |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
386 |
} |
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
387 |
|
e2065f7505eb
8192979: jshell tool: Online help text for commands is confusing
rfield
parents:
47837
diff
changeset
|
388 |
@Test |
42412
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
389 |
public void testHelpFormat() { |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
390 |
test( |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
391 |
(a) -> assertCommandCheckOutput(a, "/help", s -> { |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
392 |
String[] lines = s.split("\\R"); |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
393 |
assertTrue(lines.length > 20, |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
394 |
"Too few lines of /help output: " + lines.length |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
395 |
+ "\n" + s); |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
396 |
for (int i = 0; i < lines.length; ++i) { |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
397 |
String l = lines[i]; |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
398 |
assertTrue(l.startsWith("| "), |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
399 |
"Expected /help line to start with | :\n" + l); |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
400 |
assertTrue(l.length() <= 80, |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
401 |
"/help line too long: " + l.length() + "\n" + l); |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
402 |
} |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
403 |
}) |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
404 |
); |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
405 |
} |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
406 |
|
45602
7aeef976cb06
8180510: jshell tool: crash on entering pseudo-commands: /<id> or /-<n>
rfield
parents:
45215
diff
changeset
|
407 |
@Test |
7aeef976cb06
8180510: jshell tool: crash on entering pseudo-commands: /<id> or /-<n>
rfield
parents:
45215
diff
changeset
|
408 |
public void testConfusedUserPseudoCommands() { |
7aeef976cb06
8180510: jshell tool: crash on entering pseudo-commands: /<id> or /-<n>
rfield
parents:
45215
diff
changeset
|
409 |
test( |
7aeef976cb06
8180510: jshell tool: crash on entering pseudo-commands: /<id> or /-<n>
rfield
parents:
45215
diff
changeset
|
410 |
(a) -> assertHelp(a, "/-<n>", "last snippet", "digits"), |
7aeef976cb06
8180510: jshell tool: crash on entering pseudo-commands: /<id> or /-<n>
rfield
parents:
45215
diff
changeset
|
411 |
(a) -> assertHelp(a, "/<id>", "last snippet", "digits") |
7aeef976cb06
8180510: jshell tool: crash on entering pseudo-commands: /<id> or /-<n>
rfield
parents:
45215
diff
changeset
|
412 |
); |
7aeef976cb06
8180510: jshell tool: crash on entering pseudo-commands: /<id> or /-<n>
rfield
parents:
45215
diff
changeset
|
413 |
} |
7aeef976cb06
8180510: jshell tool: crash on entering pseudo-commands: /<id> or /-<n>
rfield
parents:
45215
diff
changeset
|
414 |
|
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
415 |
private void assertHelp(boolean a, String command, String... find) { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
416 |
assertCommandCheckOutput(a, command, s -> { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
417 |
for (String f : find) { |
42412
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
418 |
assertTrue(s.contains(f), |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
419 |
"Expected output of " + command + " to contain: " + f |
ca6f4f1914b2
8169828: jdk/jshell/ExternalEditorTest.java testStatementMush() fails frequently on all platform
rfield
parents:
41937
diff
changeset
|
420 |
+ "\n" + s); |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
421 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
422 |
}); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
423 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
424 |
|
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
425 |
// Check that each line of output contains the corresponding string from the list |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
426 |
private void checkLineToList(String in, List<String> match) { |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
427 |
String trimmed = in.trim(); |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
428 |
String[] res = trimmed.isEmpty() |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
429 |
? new String[0] |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
430 |
: trimmed.split("\n"); |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
431 |
assertEquals(res.length, match.size(), "Got: " + Arrays.asList(res)); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
432 |
for (int i = 0; i < match.size(); ++i) { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
433 |
assertTrue(res[i].contains(match.get(i))); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
434 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
435 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
436 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
437 |
@Test |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
438 |
public void testListArgs() { |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
439 |
String arg = "qqqq"; |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
440 |
List<String> startVarList = new ArrayList<>(START_UP); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
441 |
startVarList.add("int aardvark"); |
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
442 |
startVarList.add("int weevil"); |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
443 |
test( |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
444 |
a -> assertCommandCheckOutput(a, "/list -all", |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
445 |
s -> checkLineToList(s, START_UP)), |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
446 |
a -> assertCommandOutputStartsWith(a, "/list " + arg, |
38539 | 447 |
"| No such snippet: " + arg), |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
448 |
a -> assertVariable(a, "int", "aardvark"), |
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
449 |
a -> assertVariable(a, "int", "weevil"), |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
450 |
a -> assertCommandOutputContains(a, "/list aardvark", "aardvark"), |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
451 |
a -> assertCommandCheckOutput(a, "/list -start", |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
452 |
s -> checkLineToList(s, START_UP)), |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
453 |
a -> assertCommandCheckOutput(a, "/list -all", |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
454 |
s -> checkLineToList(s, startVarList)), |
42972
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
455 |
a -> assertCommandOutputStartsWith(a, "/list s3", |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
456 |
"s3 : import"), |
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
457 |
a -> assertCommandCheckOutput(a, "/list 1-2 s3", |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
458 |
s -> { |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
459 |
assertTrue(Pattern.matches(".*aardvark.*\\R.*weevil.*\\R.*s3.*import.*", s.trim()), |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
460 |
"No match: " + s); |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
461 |
}), |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
462 |
a -> assertCommandOutputStartsWith(a, "/list " + arg, |
38539 | 463 |
"| No such snippet: " + arg) |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
464 |
); |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
465 |
} |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
466 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
467 |
@Test |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
468 |
public void testVarsArgs() { |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
469 |
String arg = "qqqq"; |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
470 |
List<String> startVarList = new ArrayList<>(); |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
471 |
test( |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
472 |
a -> assertCommandCheckOutput(a, "/vars -all", |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
473 |
s -> checkLineToList(s, startVarList)), |
38539 | 474 |
a -> assertCommand(a, "/vars " + arg, |
475 |
"| No such snippet: " + arg), |
|
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
476 |
a -> assertVariable(a, "int", "aardvark"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
477 |
a -> assertMethod(a, "int f() { return 0; }", "()int", "f"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
478 |
a -> assertVariable(a, "int", "a"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
479 |
a -> assertVariable(a, "double", "a", "1", "1.0"), |
38539 | 480 |
a -> assertCommandOutputStartsWith(a, "/vars aardvark", |
481 |
"| int aardvark = 0"), |
|
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
482 |
a -> assertCommandCheckOutput(a, "/vars -start", |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
483 |
s -> checkLineToList(s, startVarList)), |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
484 |
a -> assertCommandOutputStartsWith(a, "/vars -all", |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
485 |
"| int aardvark = 0\n| int a = "), |
45215
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
486 |
a -> assertCommandOutputStartsWith(a, "/vars 1-4", |
c9477e22877f
8167554: jshell tool: re-execute a range and/or sequence of snippets
rfield
parents:
44454
diff
changeset
|
487 |
"| int aardvark = 0\n| int a = "), |
42972
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
488 |
a -> assertCommandOutputStartsWith(a, "/vars f", |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
489 |
"| This command does not accept the snippet 'f'"), |
38539 | 490 |
a -> assertCommand(a, "/var " + arg, |
491 |
"| No such snippet: " + arg) |
|
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
492 |
); |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
493 |
} |
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
494 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
495 |
@Test |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
496 |
public void testMethodsArgs() { |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
497 |
String arg = "qqqq"; |
42972
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
498 |
List<String> printingMethodList = new ArrayList<>(PRINTING_CMD_METHOD); |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
499 |
test(new String[]{"--startup", "PRINTING"}, |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
500 |
a -> assertCommandCheckOutput(a, "/methods -all", |
42972
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
501 |
s -> checkLineToList(s, printingMethodList)), |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
502 |
a -> assertCommandCheckOutput(a, "/methods -start", |
42972
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
503 |
s -> checkLineToList(s, printingMethodList)), |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
504 |
a -> assertCommandCheckOutput(a, "/methods print println printf", |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
505 |
s -> checkLineToList(s, printingMethodList)), |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
506 |
a -> assertCommandCheckOutput(a, "/methods println", |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
507 |
s -> assertEquals(s.trim().split("\n").length, 10)), |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
508 |
a -> assertCommandCheckOutput(a, "/methods", |
42972
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
509 |
s -> checkLineToList(s, printingMethodList)), |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
510 |
a -> assertCommandOutputStartsWith(a, "/methods " + arg, |
38539 | 511 |
"| No such snippet: " + arg), |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
512 |
a -> assertMethod(a, "int f() { return 0; }", "()int", "f"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
513 |
a -> assertVariable(a, "int", "aardvark"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
514 |
a -> assertMethod(a, "void f(int a) { g(); }", "(int)void", "f"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
515 |
a -> assertMethod(a, "void g() {}", "()void", "g"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
516 |
a -> assertCommandOutputStartsWith(a, "/methods " + arg, |
38539 | 517 |
"| No such snippet: " + arg), |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
518 |
a -> assertCommandOutputStartsWith(a, "/methods aardvark", |
38539 | 519 |
"| This command does not accept the snippet 'aardvark' : int aardvark"), |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
520 |
a -> assertCommandCheckOutput(a, "/methods -start", |
42972
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
521 |
s -> checkLineToList(s, printingMethodList)), |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
522 |
a -> assertCommandCheckOutput(a, "/methods print println printf", |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
523 |
s -> checkLineToList(s, printingMethodList)), |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
524 |
a -> assertCommandOutputStartsWith(a, "/methods g", |
43759
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
525 |
"| void g()"), |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
526 |
a -> assertCommandOutputStartsWith(a, "/methods f", |
43759
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
527 |
"| int f()\n" + |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
528 |
"| void f(int)") |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
529 |
); |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
530 |
} |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
531 |
|
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
532 |
@Test |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
533 |
public void testMethodsWithErrors() { |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
534 |
test(new String[]{"--no-startup"}, |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
535 |
a -> assertCommand(a, "double m(int x) { return x; }", |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
536 |
"| created method m(int)"), |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
537 |
a -> assertCommand(a, "GARBAGE junk() { return TRASH; }", |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
538 |
"| created method junk(), however, it cannot be referenced until class GARBAGE, and variable TRASH are declared"), |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
539 |
a -> assertCommand(a, "int w = 5;", |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
540 |
"w ==> 5"), |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
541 |
a -> assertCommand(a, "int tyer() { return w; }", |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
542 |
"| created method tyer()"), |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
543 |
a -> assertCommand(a, "String w = \"hi\";", |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
544 |
"w ==> \"hi\""), |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
545 |
a -> assertCommand(a, "/methods", |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
546 |
"| double m(int)\n" + |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
547 |
"| GARBAGE junk()\n" + |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
548 |
"| which cannot be referenced until class GARBAGE, and variable TRASH are declared\n" + |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
549 |
"| int tyer()\n" + |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
550 |
"| which cannot be invoked until this error is corrected: \n" + |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
551 |
"| incompatible types: java.lang.String cannot be converted to int\n" + |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
552 |
"| int tyer() { return w; }\n" + |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
553 |
"| ^\n") |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
554 |
); |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
555 |
} |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
556 |
|
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
557 |
@Test |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
558 |
public void testTypesWithErrors() { |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
559 |
test(new String[]{"--no-startup"}, |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
560 |
a -> assertCommand(a, "class C extends NONE { int x; }", |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
561 |
"| created class C, however, it cannot be referenced until class NONE is declared"), |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
562 |
a -> assertCommand(a, "class D { void m() { System.out.println(nada); } }", |
43766
498b07dcf851
8174262: Error message misspelling: "instanciated"
rfield
parents:
43759
diff
changeset
|
563 |
"| created class D, however, it cannot be instantiated or its methods invoked until variable nada is declared"), |
43759
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
564 |
a -> assertCommand(a, "/types", |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
565 |
"| class C\n" + |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
566 |
"| which cannot be referenced until class NONE is declared\n" + |
61535ac55add
8173916: jshell tool: /methods signature confusing/non-standard format
rfield
parents:
43586
diff
changeset
|
567 |
"| class D\n" + |
43766
498b07dcf851
8174262: Error message misspelling: "instanciated"
rfield
parents:
43759
diff
changeset
|
568 |
"| which cannot be instantiated or its methods invoked until variable nada is declared\n") |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
569 |
); |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
570 |
} |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
571 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
572 |
@Test |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
573 |
public void testTypesArgs() { |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
574 |
String arg = "qqqq"; |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
575 |
List<String> startTypeList = new ArrayList<>(); |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
576 |
test( |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
577 |
a -> assertCommandCheckOutput(a, "/types -all", |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
578 |
s -> checkLineToList(s, startTypeList)), |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
579 |
a -> assertCommandCheckOutput(a, "/types -start", |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
580 |
s -> checkLineToList(s, startTypeList)), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
581 |
a -> assertCommandOutputStartsWith(a, "/types " + arg, |
38539 | 582 |
"| No such snippet: " + arg), |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
583 |
a -> assertVariable(a, "int", "aardvark"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
584 |
(a) -> assertClass(a, "class A { }", "class", "A"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
585 |
(a) -> assertClass(a, "interface A { }", "interface", "A"), |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
586 |
a -> assertCommandOutputStartsWith(a, "/types -all", |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
587 |
"| class A\n" + |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
588 |
"| interface A"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
589 |
(a) -> assertClass(a, "enum E { }", "enum", "E"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
590 |
(a) -> assertClass(a, "@interface B { }", "@interface", "B"), |
38539 | 591 |
a -> assertCommand(a, "/types aardvark", |
592 |
"| This command does not accept the snippet 'aardvark' : int aardvark;"), |
|
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
593 |
a -> assertCommandOutputStartsWith(a, "/types A", |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
594 |
"| interface A"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
595 |
a -> assertCommandOutputStartsWith(a, "/types E", |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
596 |
"| enum E"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
597 |
a -> assertCommandOutputStartsWith(a, "/types B", |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
598 |
"| @interface B"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
599 |
a -> assertCommandOutputStartsWith(a, "/types " + arg, |
38539 | 600 |
"| No such snippet: " + arg), |
38520
17e72b872ffd
8157185: jshell tool: ambiguous format -- distinguished arguments should be options
rfield
parents:
38514
diff
changeset
|
601 |
a -> assertCommandCheckOutput(a, "/types -start", |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
602 |
s -> checkLineToList(s, startTypeList)) |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
603 |
); |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
604 |
} |
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
605 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
606 |
@Test |
43274
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
607 |
public void testBlankLinesInSnippetContinuation() { |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
608 |
test(Locale.ROOT, false, new String[]{"--no-startup"}, "", |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
609 |
a -> assertCommand(a, "class C {", |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
610 |
""), |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
611 |
a -> assertCommand(a, "", |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
612 |
""), |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
613 |
a -> assertCommand(a, "", |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
614 |
""), |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
615 |
a -> assertCommand(a, " int x;", |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
616 |
""), |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
617 |
a -> assertCommand(a, "", |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
618 |
""), |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
619 |
a -> assertCommand(a, "", |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
620 |
""), |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
621 |
a -> assertCommand(a, "}", |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
622 |
"| created class C"), |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
623 |
a -> assertCommand(a, "/list", |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
624 |
"\n" + |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
625 |
" 1 : class C {\n" + |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
626 |
" \n" + |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
627 |
" \n" + |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
628 |
" int x;\n" + |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
629 |
" \n" + |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
630 |
" \n" + |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
631 |
" }") |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
632 |
); |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
633 |
} |
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
634 |
|
6b5ed4f9fb81
8173073: jshell tool: blank lines removed from multi-line snippets
rfield
parents:
43038
diff
changeset
|
635 |
@Test |
42972
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
636 |
public void testCompoundStart() { |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
637 |
test(new String[]{"--startup", "DEFAULT", "--startup", "PRINTING"}, |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
638 |
(a) -> assertCommand(a, "printf(\"%4.2f\", Math.PI)", |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
639 |
"", "", null, "3.14", "") |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
640 |
); |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
641 |
} |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
642 |
|
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
643 |
@Test |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
644 |
public void testJavaSeStart() { |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
645 |
test(new String[]{"--startup", "JAVASE"}, |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
646 |
(a) -> assertCommand(a, "ZoneOffsetTransitionRule.TimeDefinition.WALL", |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
647 |
"$1 ==> WALL") |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
648 |
); |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
649 |
} |
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
650 |
|
47ca49eee534
8172102: jshell tool: remove print method forwarding to System.out from default startup
rfield
parents:
42969
diff
changeset
|
651 |
@Test |
47837
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
652 |
public void testJavaSeSetStart() { |
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
653 |
test( |
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
654 |
(a) -> assertCommand(a, "/set sta JAVASE", ""), |
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
655 |
(a) -> assertCommand(a, "/reset", "| Resetting state."), |
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
656 |
(a) -> assertCommandCheckOutput(a, "/li -a", |
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
657 |
s -> assertTrue(s.split("import ").length > 160, |
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
658 |
"not enough imports for JAVASE:\n" + s)) |
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
659 |
); |
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
660 |
} |
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
661 |
|
ef7aad81c3d6
8172154: jshell tool: make all IMPORTS.jsh generated at build time
rfield
parents:
47268
diff
changeset
|
662 |
@Test |
38514
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
663 |
public void defineClasses() { |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
664 |
test( |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
665 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
666 |
(a) -> assertCommandCheckOutput(a, "/types", assertClasses()), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
667 |
(a) -> assertClass(a, "class A { }", "class", "A"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
668 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
669 |
(a) -> assertCommandCheckOutput(a, "/types", assertClasses()), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
670 |
(a) -> assertClass(a, "interface A { }", "interface", "A"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
671 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
672 |
(a) -> assertCommandCheckOutput(a, "/types", assertClasses()), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
673 |
(a) -> assertClass(a, "enum A { }", "enum", "A"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
674 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
675 |
(a) -> assertCommandCheckOutput(a, "/types", assertClasses()), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
676 |
(a) -> assertClass(a, "@interface A { }", "@interface", "A"), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
677 |
(a) -> assertCommandCheckOutput(a, "/list", assertList()), |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
678 |
(a) -> assertCommandCheckOutput(a, "/types", assertClasses()) |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
679 |
); |
f7df9ab653b0
8153920: jshell tool: allow a parameter on the /vars /methods /classes commands
rfield
parents:
37745
diff
changeset
|
680 |
} |
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
681 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
682 |
@Test |
37389 | 683 |
public void testCommandPrefix() { |
684 |
test(a -> assertCommandCheckOutput(a, "/s", |
|
685 |
assertStartsWith("| Command: '/s' is ambiguous: /save, /set")), |
|
686 |
a -> assertCommand(a, "int var", "var ==> 0"), |
|
687 |
a -> assertCommandCheckOutput(a, "/va", |
|
688 |
assertStartsWith("| int var = 0")), |
|
689 |
a -> assertCommandCheckOutput(a, "/save", |
|
690 |
assertStartsWith("| '/save' requires a filename argument."))); |
|
691 |
} |
|
692 |
||
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
693 |
@Test |
37745
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
694 |
public void testOptionQ() { |
41937
1313399705e9
8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents:
41635
diff
changeset
|
695 |
test(Locale.ROOT, false, new String[]{"-q", "--no-startup"}, "", |
37745
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
696 |
(a) -> assertCommand(a, "1+1", "$1 ==> 2"), |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
697 |
(a) -> assertCommand(a, "int x = 5", "") |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
698 |
); |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
699 |
} |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
700 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
701 |
@Test |
40588
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
702 |
public void testOptionS() { |
41937
1313399705e9
8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents:
41635
diff
changeset
|
703 |
test(Locale.ROOT, false, new String[]{"-s", "--no-startup"}, "", |
37745
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
704 |
(a) -> assertCommand(a, "1+1", "") |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
705 |
); |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
706 |
} |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
707 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
708 |
@Test |
37745
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
709 |
public void testOptionV() { |
40588
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
710 |
test(new String[]{"-v", "--no-startup"}, |
37745
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
711 |
(a) -> assertCommand(a, "1+1", |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
712 |
"$1 ==> 2\n" + |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
713 |
"| created scratch variable $1 : int") |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
714 |
); |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
715 |
} |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
716 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
717 |
@Test |
37745
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
718 |
public void testOptionFeedback() { |
41937
1313399705e9
8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents:
41635
diff
changeset
|
719 |
test(Locale.ROOT, false, new String[]{"--feedback", "concise", "--no-startup"}, "", |
37745
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
720 |
(a) -> assertCommand(a, "1+1", "$1 ==> 2"), |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
721 |
(a) -> assertCommand(a, "int x = 5", "") |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
722 |
); |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
723 |
} |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
724 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
725 |
@Test |
40588
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
726 |
public void testCompoundOptions() { |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
727 |
Consumer<String> confirmNoStartup = s -> { |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
728 |
assertEquals(0, Stream.of(s.split("\n")) |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
729 |
.filter(l -> !l.isEmpty()) |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
730 |
.count(), "Expected no lines: " + s); |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
731 |
}; |
41937
1313399705e9
8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents:
41635
diff
changeset
|
732 |
test(Locale.ROOT, false, new String[]{"-nq"}, "", |
40588
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
733 |
(a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup), |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
734 |
(a) -> assertCommand(a, "1+1", "$1 ==> 2"), |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
735 |
(a) -> assertCommand(a, "int x = 5", "") |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
736 |
); |
41937
1313399705e9
8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents:
41635
diff
changeset
|
737 |
test(Locale.ROOT, false, new String[]{"-qn"}, "", |
40588
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
738 |
(a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup), |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
739 |
(a) -> assertCommand(a, "1+1", "$1 ==> 2"), |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
740 |
(a) -> assertCommand(a, "int x = 5", "") |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
741 |
); |
41937
1313399705e9
8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents:
41635
diff
changeset
|
742 |
test(Locale.ROOT, false, new String[]{"-ns"}, "", |
40588
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
743 |
(a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup), |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
744 |
(a) -> assertCommand(a, "1+1", "") |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
745 |
); |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
746 |
} |
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
747 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
748 |
@Test |
37745
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
749 |
public void testOptionR() { |
40588
b5c32bfa9710
8160089: jshell tool: use new double-dash long-form command-line options
rfield
parents:
38835
diff
changeset
|
750 |
test(new String[]{"-R-Dthe.sound=blorp", "--no-startup"}, |
37745
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
751 |
(a) -> assertCommand(a, "System.getProperty(\"the.sound\")", |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
752 |
"$1 ==> \"blorp\"") |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
753 |
); |
4b6b59f8e327
8150382: JShell API: Allow setting remote JVM arguments
rfield
parents:
37389
diff
changeset
|
754 |
} |
38531
c449daa25b45
8157200: jshell tool: Add /retain command to persist settings
rfield
parents:
38520
diff
changeset
|
755 |
|
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42412
diff
changeset
|
756 |
@Test |
43038 | 757 |
public void testWrapSourceHandlerDiagCrash() { |
758 |
test(new String[]{"--add-exports", "jdk.javadoc/ALL-UNNAMED"}, |
|
759 |
(a) -> assertCommand(a, "1+1", "$1 ==> 2") |
|
760 |
); |
|
761 |
} |
|
762 |
||
763 |
@Test |
|
38531
c449daa25b45
8157200: jshell tool: Add /retain command to persist settings
rfield
parents:
38520
diff
changeset
|
764 |
public void test8156910() { |
c449daa25b45
8157200: jshell tool: Add /retain command to persist settings
rfield
parents:
38520
diff
changeset
|
765 |
test( |
c449daa25b45
8157200: jshell tool: Add /retain command to persist settings
rfield
parents:
38520
diff
changeset
|
766 |
(a) -> assertCommandOutputContains(a, "System.out.println(\"%5d\", 10);", "%5d"), |
c449daa25b45
8157200: jshell tool: Add /retain command to persist settings
rfield
parents:
38520
diff
changeset
|
767 |
(a) -> assertCommandOutputContains(a, "1234", "==> 1234") |
c449daa25b45
8157200: jshell tool: Add /retain command to persist settings
rfield
parents:
38520
diff
changeset
|
768 |
); |
c449daa25b45
8157200: jshell tool: Add /retain command to persist settings
rfield
parents:
38520
diff
changeset
|
769 |
} |
47268
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
770 |
|
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
771 |
@Test |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
772 |
public void testIntersection() { |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
773 |
test( |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
774 |
(a) -> assertCommandOutputContains(a, "<Z extends Runnable&CharSequence> Z get1() { return null; }", "get1()"), |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
775 |
(a) -> assertCommandOutputContains(a, "var g1 = get1()", "g1"), |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
776 |
(a) -> assertCommand(a, "/vars g1", "| CharSequence&Runnable g1 = null"), |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
777 |
(a) -> assertCommandOutputContains(a, "<Z extends Number&CharSequence> Z get2() { return null; }", "get2()"), |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
778 |
(a) -> assertCommandOutputContains(a, "var g2 = get2()", "g2"), |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
779 |
(a) -> assertCommand(a, "/vars g2", "| Number&CharSequence g2 = null") |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
780 |
); |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
781 |
} |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
782 |
|
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
783 |
@Test |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
784 |
public void testAnonymous() { |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
785 |
test( |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
786 |
(a) -> assertCommandOutputContains(a, "var r1 = new Object() {}", "r1"), |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
787 |
(a) -> assertCommandOutputContains(a, "/vars r1", "| <anonymous class extending Object> r1 = "), |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
788 |
(a) -> assertCommandOutputContains(a, "var r2 = new Runnable() { public void run() { } }", "r2"), |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
789 |
(a) -> assertCommandOutputContains(a, "/vars r2", "| <anonymous class implementing Runnable> r2 = ") |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
790 |
); |
48ec75306997
8177466: Add compiler support for local variable type-inference
mcimadamore
parents:
47216
diff
changeset
|
791 |
} |
37007
6023a9a9d58a
8153716: JShell tool: should warn when failed to launch editor
rfield
parents:
diff
changeset
|
792 |
} |