8210808: jshell tool: only considers the first snippet of the external editor
Reviewed-by: jlahoda, sundar
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Mon Oct 29 12:31:49 2018 -0300
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Mon Oct 29 08:34:33 2018 -0700
@@ -2936,7 +2936,7 @@
}
String tsrc = trimNewlines(an.source());
if (!failed && !currSrcs.contains(tsrc)) {
- failed = processSource(tsrc);
+ failed = !processSource(tsrc);
}
nextSrcs.add(tsrc);
if (an.remaining().isEmpty()) {
--- a/test/langtools/jdk/jshell/EditorTestBase.java Mon Oct 29 12:31:49 2018 -0300
+++ b/test/langtools/jdk/jshell/EditorTestBase.java Mon Oct 29 08:34:33 2018 -0700
@@ -125,6 +125,24 @@
);
}
+ @Test
+ public void testWriteVariables() {
+ testEditor(
+ a -> assertEditOutput(a, "/edit",
+ "x ==> 1\n" +
+ "y ==> 2\n" +
+ "z ==> 3",
+ () -> {
+ writeSource(
+ "var x = 1;\n" +
+ "var y = 2;\n" +
+ "var z = 3;\n");
+ exit();
+ }),
+ a -> assertCommand(a, "z", "z ==> 3")
+ );
+ }
+
public void testEditClass1() {
testEditor(
a -> assertClass(a, "class A {}", "class", "A"),
--- a/test/langtools/jdk/jshell/ExternalEditorTest.java Mon Oct 29 12:31:49 2018 -0300
+++ b/test/langtools/jdk/jshell/ExternalEditorTest.java Mon Oct 29 08:34:33 2018 -0700
@@ -24,7 +24,7 @@
/*
* @test
* @summary Testing external editor.
- * @bug 8143955 8080843 8163816 8143006 8169828 8171130 8162989
+ * @bug 8143955 8080843 8163816 8143006 8169828 8171130 8162989 8210808
* @modules jdk.jshell/jdk.internal.jshell.tool
* @build ReplToolTesting CustomEditor EditorTestBase
* @run testng ExternalEditorTest