8173073: jshell tool: blank lines removed from multi-line snippets

Reviewed-by: jlahoda
This commit is contained in:
Robert Field 2017-01-20 11:05:48 -08:00
parent 6e24cb584c
commit bba1175418
2 changed files with 31 additions and 2 deletions

View File

@ -987,7 +987,7 @@ public class JShellTool implements MessageHandler {
break;
}
String trimmed = trimEnd(raw);
if (!trimmed.isEmpty()) {
if (!trimmed.isEmpty() || !incomplete.isEmpty()) {
String line = incomplete + trimmed;
// No commands in the middle of unprocessed source

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405
* @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073
* @summary Simple jshell tool tests
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
@ -495,6 +495,35 @@ public class ToolSimpleTest extends ReplToolTesting {
);
}
@Test
public void testBlankLinesInSnippetContinuation() {
test(Locale.ROOT, false, new String[]{"--no-startup"}, "",
a -> assertCommand(a, "class C {",
""),
a -> assertCommand(a, "",
""),
a -> assertCommand(a, "",
""),
a -> assertCommand(a, " int x;",
""),
a -> assertCommand(a, "",
""),
a -> assertCommand(a, "",
""),
a -> assertCommand(a, "}",
"| created class C"),
a -> assertCommand(a, "/list",
"\n" +
" 1 : class C {\n" +
" \n" +
" \n" +
" int x;\n" +
" \n" +
" \n" +
" }")
);
}
@Test
public void testCompoundStart() {
test(new String[]{"--startup", "DEFAULT", "--startup", "PRINTING"},