langtools/test/jdk/jshell/ToolFormatTest.java
changeset 38513 0ae85633d035
parent 37640 42e5136a367c
child 38520 17e72b872ffd
equal deleted inserted replaced
38512:c71e1cdd6674 38513:0ae85633d035
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 8148316 8148317 8151755 8152246 8153551
    26  * @bug 8148316 8148317 8151755 8152246 8153551 8154812
    27  * @summary Tests for output customization
    27  * @summary Tests for output customization
    28  * @library /tools/lib
    28  * @library /tools/lib
    29  * @modules jdk.compiler/com.sun.tools.javac.api
    29  * @modules jdk.compiler/com.sun.tools.javac.api
    30  *          jdk.compiler/com.sun.tools.javac.main
    30  *          jdk.compiler/com.sun.tools.javac.main
    31  *          jdk.jdeps/com.sun.tools.javap
    31  *          jdk.jdeps/com.sun.tools.javap
   153             assertCommandCheckOutput(false, "/set feedback normal", s -> {
   153             assertCommandCheckOutput(false, "/set feedback normal", s -> {
   154             });
   154             });
   155         }
   155         }
   156     }
   156     }
   157 
   157 
       
   158     public void testSetTruncation() {
       
   159         try {
       
   160             test(
       
   161                     (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", ""),
       
   162                     (a) -> assertCommand(a, "String s = java.util.stream.IntStream.range(65, 74)"+
       
   163                             ".mapToObj(i -> \"\"+(char)i).reduce((a,b) -> a + b + a).get()",
       
   164                             "s ==> \"ABACABADABACABAEABACABADABACABAFABACABADABACABAEABACABADABACABAGABACABADABA ..."),
       
   165                     (a) -> assertCommandOutputStartsWith(a, "/set newmode test quiet", ""),
       
   166                     (a) -> assertCommandOutputStartsWith(a, "/set feedback test", ""),
       
   167                     (a) -> assertCommand(a, "/set format test display '{type}:{value}' primary", ""),
       
   168                     (a) -> assertCommand(a, "/set truncation test 20", ""),
       
   169                     (a) -> assertCommand(a, "/set trunc test 10 varvalue", ""),
       
   170                     (a) -> assertCommand(a, "/set trunc test 3 assignment", ""),
       
   171                     (a) -> assertCommand(a, "String r = s", "String:\"ABACABADABACABA ..."),
       
   172                     (a) -> assertCommand(a, "r", "String:\"ABACA ..."),
       
   173                     (a) -> assertCommand(a, "r=s", "String:\"AB")
       
   174             );
       
   175         } finally {
       
   176             assertCommandCheckOutput(false, "/set feedback normal", s -> {
       
   177             });
       
   178         }
       
   179     }
       
   180 
   158     public void testShowFeedbackModes() {
   181     public void testShowFeedbackModes() {
   159         test(
   182         test(
   160                 (a) -> assertCommandOutputContains(a, "/set feedback", "normal")
   183                 (a) -> assertCommandOutputContains(a, "/set feedback", "normal")
   161         );
   184         );
   162     }
   185     }
   224                             "ERROR: Not a valid selector"),
   247                             "ERROR: Not a valid selector"),
   225                     (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import-import",
   248                     (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import-import",
   226                             "ERROR: Selector kind in multiple sections of"),
   249                             "ERROR: Selector kind in multiple sections of"),
   227                     (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import,added",
   250                     (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import,added",
   228                             "ERROR: Different selector kinds in same sections of"),
   251                             "ERROR: Different selector kinds in same sections of"),
       
   252                     (a) -> assertCommandOutputStartsWith(a, "/set trunc te 20x",
       
   253                             "ERROR: Truncation length must be an integer: 20x"),
       
   254                     (a) -> assertCommandOutputStartsWith(a, "/set trunc te",
       
   255                             "ERROR: Expected truncation length"),
       
   256                     (a) -> assertCommandOutputStartsWith(a, "/set truncation te 111 import,added",
       
   257                             "ERROR: Different selector kinds in same sections of"),
   229                     (a) -> assertCommandOutputStartsWith(a, "/set newmode",
   258                     (a) -> assertCommandOutputStartsWith(a, "/set newmode",
   230                             "ERROR: Expected new feedback mode"),
   259                             "ERROR: Expected new feedback mode"),
   231                     (a) -> assertCommandOutputStartsWith(a, "/set newmode te",
   260                     (a) -> assertCommandOutputStartsWith(a, "/set newmode te",
   232                             "ERROR: Expected a new feedback mode name"),
   261                             "ERROR: Expected a new feedback mode name"),
   233                     (a) -> assertCommandOutputStartsWith(a, "/set newmode x xyz",
   262                     (a) -> assertCommandOutputStartsWith(a, "/set newmode x xyz",