8157261: jshell tool: truncation for expressions is not consistent
authorrfield
Fri, 27 May 2016 10:37:46 -0700
changeset 38615 9221159d84fb
parent 38614 364c1a6618c0
child 38616 31e503b8ea65
8157261: jshell tool: truncation for expressions is not consistent Reviewed-by: vromero
langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties
langtools/test/jdk/jshell/ToolFormatTest.java
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Thu May 26 17:35:26 2016 -0700
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Fri May 27 10:37:46 2016 -0700
@@ -742,7 +742,7 @@
 /set format verbose display '{pre}attempted to call method {name}({type}){resolve}{post}'    used-method    \n\
 \n\
 /set truncation verbose 80\n\
-/set truncation verbose 500                                                                  varvalue\n\
+/set truncation verbose 1000                                                                  varvalue,expression\n\
 \n\
 /set mode normal -command verbose    \n\
 /set format normal display ''                                                               added,modified,replaced,overwrote,dropped-update    \n\
--- a/langtools/test/jdk/jshell/ToolFormatTest.java	Thu May 26 17:35:26 2016 -0700
+++ b/langtools/test/jdk/jshell/ToolFormatTest.java	Fri May 27 10:37:46 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8148316 8148317 8151755 8152246 8153551 8154812
+ * @bug 8148316 8148317 8151755 8152246 8153551 8154812 8157261
  * @summary Tests for output customization
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
@@ -36,6 +36,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import org.testng.annotations.Test;
+import static org.testng.Assert.assertTrue;
 
 @Test
 public class ToolFormatTest extends ReplToolTesting {
@@ -178,6 +179,28 @@
         }
     }
 
+    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() {
         test(
                 (a) -> assertCommandOutputContains(a, "/set feedback", "normal")