8157261: jshell tool: truncation for expressions is not consistent

Reviewed-by: vromero
This commit is contained in:
Robert Field 2016-05-27 10:37:46 -07:00
parent f6dd27010c
commit c65d2e5dac
2 changed files with 25 additions and 2 deletions

View file

@ -742,7 +742,7 @@ startup.feedback = \
/set format verbose display '{pre}attempted to call method {name}({type}){resolve}{post}' used-method \n\ /set format verbose display '{pre}attempted to call method {name}({type}){resolve}{post}' used-method \n\
\n\ \n\
/set truncation verbose 80\n\ /set truncation verbose 80\n\
/set truncation verbose 500 varvalue\n\ /set truncation verbose 1000 varvalue,expression\n\
\n\ \n\
/set mode normal -command verbose \n\ /set mode normal -command verbose \n\
/set format normal display '' added,modified,replaced,overwrote,dropped-update \n\ /set format normal display '' added,modified,replaced,overwrote,dropped-update \n\

View file

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8148316 8148317 8151755 8152246 8153551 8154812 * @bug 8148316 8148317 8151755 8152246 8153551 8154812 8157261
* @summary Tests for output customization * @summary Tests for output customization
* @library /tools/lib * @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api * @modules jdk.compiler/com.sun.tools.javac.api
@ -36,6 +36,7 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import static org.testng.Assert.assertTrue;
@Test @Test
public class ToolFormatTest extends ReplToolTesting { public class ToolFormatTest extends ReplToolTesting {
@ -178,6 +179,28 @@ public class ToolFormatTest extends ReplToolTesting {
} }
} }
public void testDefaultTruncation() {
test(
(a) -> assertCommand(a, "char[] cs = new char[2000];", null),
(a) -> assertCommand(a, "Arrays.fill(cs, 'A');", ""),
(a) -> assertCommandCheckOutput(a, "String s = new String(cs)",
(s) -> {
assertTrue(s.length() < 120, "Result too long (" + s.length() + ") -- " + s);
assertTrue(s.contains("AAAAAAAAAAAAAAAAAA"), "Bad value: " + s);
}),
(a) -> assertCommandCheckOutput(a, "s",
(s) -> {
assertTrue(s.length() > 300, "Result too short (" + s.length() + ") -- " + s);
assertTrue(s.contains("AAAAAAAAAAAAAAAAAA"), "Bad value: " + s);
}),
(a) -> assertCommandCheckOutput(a, "\"X\" + s",
(s) -> {
assertTrue(s.length() > 300, "Result too short (" + s.length() + ") -- " + s);
assertTrue(s.contains("XAAAAAAAAAAAAAAAAAA"), "Bad value: " + s);
})
);
}
public void testShowFeedbackModes() { public void testShowFeedbackModes() {
test( test(
(a) -> assertCommandOutputContains(a, "/set feedback", "normal") (a) -> assertCommandOutputContains(a, "/set feedback", "normal")