test/langtools/jdk/jshell/ToolFormatTest.java
author coleenp
Wed, 15 Nov 2017 08:14:31 -0500
changeset 47894 352b17f62ff7
parent 47216 71c04702a3d5
permissions -rw-r--r--
8191315: Add serviceability/sa/TestRevPtrsForInvokeDynamic.java to ProblemList.txt Reviewed-by: dholmes, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     1
/*
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     4
 *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     8
 *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    13
 * accompanied this code).
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    14
 *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    18
 *
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    21
 * questions.
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    22
 */
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    23
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    24
/*
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    25
 * @test
43264
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
    26
 * @bug 8148316 8148317 8151755 8152246 8153551 8154812 8157261 8163840 8166637 8161969 8173007
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    27
 * @summary Tests for output customization
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    28
 * @library /tools/lib
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36494
diff changeset
    29
 * @modules jdk.compiler/com.sun.tools.javac.api
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36494
diff changeset
    30
 *          jdk.compiler/com.sun.tools.javac.main
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36494
diff changeset
    31
 *          jdk.jdeps/com.sun.tools.javap
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36494
diff changeset
    32
 *          jdk.jshell/jdk.internal.jshell.tool
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36718
diff changeset
    33
 * @build KullaTesting TestingInputStream toolbox.ToolBox Compiler
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    34
 * @run testng ToolFormatTest
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    35
 */
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    36
import java.io.BufferedReader;
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    37
import java.io.IOException;
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    38
import java.io.StringReader;
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    39
import java.util.ArrayList;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    40
import java.util.List;
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    41
import org.testng.annotations.Test;
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    42
import static org.testng.Assert.assertEquals;
38615
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
    43
import static org.testng.Assert.assertTrue;
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    44
import static org.testng.Assert.fail;
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    45
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    46
@Test
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    47
public class ToolFormatTest extends ReplToolTesting {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    48
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    49
    public void testSetFormat() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    50
        try {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    51
            test(
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
    52
                    (a) -> assertCommandOutputStartsWith(a, "/set mode test -command", "|  Created new feedback mode: test"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    53
                    (a) -> assertCommand(a, "/set format test pre '$ '", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    54
                    (a) -> assertCommand(a, "/set format test post ''", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    55
                    (a) -> assertCommand(a, "/set format test act 'ADD' added", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    56
                    (a) -> assertCommand(a, "/set format test act 'MOD' modified", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    57
                    (a) -> assertCommand(a, "/set format test act 'REP' replaced", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    58
                    (a) -> assertCommand(a, "/set format test act 'OVR' overwrote", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    59
                    (a) -> assertCommand(a, "/set format test act 'USE' used", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    60
                    (a) -> assertCommand(a, "/set format test act 'DRP' dropped", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    61
                    (a) -> assertCommand(a, "/set format test up 'UP-' update", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    62
                    (a) -> assertCommand(a, "/set format test action '{up}{act} '", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    63
                    (a) -> assertCommand(a, "/set format test resolve 'OK' ok", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    64
                    (a) -> assertCommand(a, "/set format test resolve 'DEF' defined", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    65
                    (a) -> assertCommand(a, "/set format test resolve 'NODEF' notdefined", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    66
                    (a) -> assertCommand(a, "/set format test fname ':{name} ' ", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    67
                    (a) -> assertCommand(a, "/set format test ftype '[{type}]' method,expression", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    68
                    (a) -> assertCommand(a, "/set format test result '={value} ' expression", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    69
                    (a) -> assertCommand(a, "/set format test display '{pre}{action}{ftype}{fname}{result}{resolve}'", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    70
                    (a) -> assertCommand(a, "/set format test display '{pre}HI this is enum' enum", ""),
36990
ec0b843a7af5 8147515: JShell: Internationalize
rfield
parents: 36778
diff changeset
    71
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback test", "$ Feedback mode: test"),
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    72
                    (a) -> assertCommand(a, "class D {}", "$ ADD :D OK"),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    73
                    (a) -> assertCommand(a, "void m() {}", "$ ADD []:m OK"),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    74
                    (a) -> assertCommand(a, "interface EX extends EEX {}", "$ ADD :EX NODEF"),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    75
                    (a) -> assertCommand(a, "56", "$ ADD [int]:$4 =56 OK"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    76
                    (a) -> assertCommand(a, "class D { int hh; }", "$ REP :D OK$ UP-OVR :D OK"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    77
                    (a) -> assertCommand(a, "enum E {A,B}", "$ HI this is enum"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    78
                    (a) -> assertCommand(a, "int z() { return f(); }", "$ ADD []:z DEF"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    79
                    (a) -> assertCommand(a, "z()", "$ UP-USE []:z DEF"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    80
                    (a) -> assertCommand(a, "/drop z", "$ DRP []:z OK"),
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    81
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    82
            );
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    83
        } finally {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    84
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    85
            });
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    86
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    87
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    88
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    89
    public void testSetFormatOverride() {
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    90
        test(
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    91
                (a) -> assertCommand(a, "/set mode tm -c", "|  Created new feedback mode: tm"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    92
                (a) -> assertCommand(a, "/se fo tm x \"aaa\"", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    93
                (a) -> assertCommand(a, "/se fo tm x \"bbb\" class,method-added", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    94
                (a) -> assertCommand(a, "/se fo tm x",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    95
                        "|  /set format tm x \"aaa\" \n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    96
                        "|  /set format tm x \"bbb\" class,method-added"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    97
                (a) -> assertCommand(a, "/se fo tm x \"ccc\" class,method-added,modified", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    98
                (a) -> assertCommand(a, "/se fo tm x \"ddd\" class,method-added", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
    99
                (a) -> assertCommand(a, "/se fo tm x \"eee\" method-added", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   100
                (a) -> assertCommand(a, "/se fo tm x",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   101
                        "|  /set format tm x \"aaa\" \n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   102
                        "|  /set format tm x \"ccc\" class,method-added,modified\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   103
                        "|  /set format tm x \"ddd\" class,method-added\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   104
                        "|  /set format tm x \"eee\" method-added"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   105
                (a) -> assertCommand(a, "/se fo tm x \"EEE\" method-added,replaced", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   106
                (a) -> assertCommand(a, "/se fo tm x",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   107
                        "|  /set format tm x \"aaa\" \n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   108
                        "|  /set format tm x \"ccc\" class,method-added,modified\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   109
                        "|  /set format tm x \"ddd\" class,method-added\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   110
                        "|  /set format tm x \"EEE\" method-added,replaced"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   111
                (a) -> assertCommand(a, "/se fo tm x \"fff\" method-added,replaced-ok", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   112
                (a) -> assertCommand(a, "/se fo tm x",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   113
                        "|  /set format tm x \"aaa\" \n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   114
                        "|  /set format tm x \"ccc\" class,method-added,modified\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   115
                        "|  /set format tm x \"ddd\" class,method-added\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   116
                        "|  /set format tm x \"EEE\" method-added,replaced\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   117
                        "|  /set format tm x \"fff\" method-added,replaced-ok"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   118
                (a) -> assertCommand(a, "/se fo tm x \"ggg\" method-ok", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   119
                (a) -> assertCommand(a, "/se fo tm x",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   120
                        "|  /set format tm x \"aaa\" \n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   121
                        "|  /set format tm x \"ccc\" class,method-added,modified\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   122
                        "|  /set format tm x \"ddd\" class,method-added\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   123
                        "|  /set format tm x \"EEE\" method-added,replaced\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   124
                        "|  /set format tm x \"ggg\" method-ok"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   125
                (a) -> assertCommand(a, "/se fo tm x \"hhh\" method", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   126
                (a) -> assertCommand(a, "/se fo tm x",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   127
                        "|  /set format tm x \"aaa\" \n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   128
                        "|  /set format tm x \"ccc\" class,method-added,modified\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   129
                        "|  /set format tm x \"ddd\" class,method-added\n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   130
                        "|  /set format tm x \"hhh\" method"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   131
                (a) -> assertCommand(a, "/se fo tm x \"iii\" method,class", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   132
                (a) -> assertCommand(a, "/se fo tm x",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   133
                        "|  /set format tm x \"aaa\" \n" +
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   134
                        "|  /set format tm x \"iii\" class,method"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   135
                (a) -> assertCommand(a, "/se fo tm x \"jjj\"", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   136
                (a) -> assertCommand(a, "/se fo tm x",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   137
                        "|  /set format tm x \"jjj\"")
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   138
        );
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   139
    }
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   140
43264
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   141
    public void testSetFormatSelectorSample() {
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   142
        test(
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   143
                (a) -> assertCommandOutputStartsWith(a, "/set mode ate -quiet",
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   144
                            "|  Created new feedback mode: ate"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   145
                (a) -> assertCommand(a, "/set feedback ate", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   146
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   147
                (a) -> assertCommand(a, "/set format ate display '---replaced,modified,added-primary---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   148
                (a) -> assertCommand(a, "/set format ate display '+++replaced,modified,added-primary+++' replaced,modified,added-primary", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   149
                (a) -> assertCommand(a, "\"replaced,modified,added-primary\"", "+++replaced,modified,added-primary+++"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   150
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   151
                (a) -> assertCommand(a, "/set format ate display '---added-primary,update---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   152
                (a) -> assertCommand(a, "/set format ate display '+++added-primary,update+++' added-primary,update", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   153
                (a) -> assertCommand(a, "\"added-primary,update\"", "+++added-primary,update+++"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   154
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   155
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   156
                (a) -> assertCommand(a, "/set format ate display '---method-replaced-primary---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   157
                (a) -> assertCommand(a, "/set format ate display '+++method-replaced-primary+++' method-replaced-primary", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   158
                (a) -> assertCommand(a, "\"method-replaced-primary\"", "---method-replaced-primary---"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   159
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   160
                (a) -> assertCommand(a, "/set format ate display '---method-replaced-update---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   161
                (a) -> assertCommand(a, "/set format ate display '+++method-replaced-update+++' method-replaced-update", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   162
                (a) -> assertCommand(a, "\"method-replaced-update\"", "---method-replaced-update---"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   163
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   164
                (a) -> assertCommand(a, "/set format ate display '---method-added-update---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   165
                (a) -> assertCommand(a, "/set format ate display '+++method-added-update+++' method-added-update", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   166
                (a) -> assertCommand(a, "\"method-added-update\"", "---method-added-update---"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   167
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   168
                (a) -> assertCommand(a, "/set format ate display '---method-added---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   169
                (a) -> assertCommand(a, "/set format ate display '+++method-added+++' method-added", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   170
                (a) -> assertCommand(a, "\"method-added\"", "---method-added---"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   171
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   172
                (a) -> assertCommand(a, "/set format ate display '---class-modified,added-primary,update---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   173
                (a) -> assertCommand(a, "/set format ate display '+++class-modified,added-primary,update+++' class-modified,added-primary,update", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   174
                (a) -> assertCommand(a, "\"class-modified,added-primary,update\"", "---class-modified,added-primary,update---"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   175
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   176
                (a) -> assertCommand(a, "/set format ate display '---class-modified,added-primary---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   177
                (a) -> assertCommand(a, "/set format ate display '+++class-modified,added-primary+++' class-modified,added-primary", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   178
                (a) -> assertCommand(a, "\"class-modified,added-primary\"", "---class-modified,added-primary---"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   179
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   180
                (a) -> assertCommand(a, "/set format ate display '---class-modified,added-update---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   181
                (a) -> assertCommand(a, "/set format ate display '+++class-modified,added-update+++' class-modified,added-update", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   182
                (a) -> assertCommand(a, "\"class-modified,added-update\"", "---class-modified,added-update---"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   183
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   184
                (a) -> assertCommand(a, "/set format ate display '---replaced,added---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   185
                (a) -> assertCommand(a, "/set format ate display '+++replaced,added+++' replaced,added", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   186
                (a) -> assertCommand(a, "\"replaced,added\"", "+++replaced,added+++"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   187
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   188
                (a) -> assertCommand(a, "/set format ate display '---replaced-primary,update---'", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   189
                (a) -> assertCommand(a, "/set format ate display '+++replaced-primary,update+++' replaced-primary,update", ""),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   190
                (a) -> assertCommand(a, "\"replaced-primary,update\"", "---replaced-primary,update---"),
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   191
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   192
                (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   193
        );
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   194
    }
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   195
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   196
    // This test is exhaustive and takes to long for routine testing -- disabled.
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   197
    // A sampling of these has been added (above: testSetFormatSelectorSample).
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   198
    // See 8173007
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   199
    // Save for possible future deep testing or debugging
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   200
    @Test(enabled = false)
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   201
    public void testSetFormatSelector() {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   202
        List<ReplTest> tests = new ArrayList<>();
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   203
        tests.add((a) -> assertCommandOutputStartsWith(a, "/set mode ate -quiet",
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   204
                            "|  Created new feedback mode: ate"));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   205
        tests.add((a) -> assertCommand(a, "/set feedback ate", ""));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   206
        StringBuilder sb = new StringBuilder();
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   207
        class KindList {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   208
            final String[] values;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   209
            final int matchIndex;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   210
            int current;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   211
            boolean match;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   212
            KindList(String[] values, int matchIndex) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   213
                this.values = values;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   214
                this.matchIndex = matchIndex;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   215
                this.current = 1 << values.length;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   216
            }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   217
            boolean next() {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   218
                if (current <= 0) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   219
                    return false;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   220
                }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   221
                --current;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   222
                return true;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   223
            }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   224
            boolean append(boolean ahead) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   225
                boolean any = false;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   226
                match = false;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   227
                for (int i = values.length - 1; i >= 0 ; --i) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   228
                    if ((current & (1 << i)) != 0) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   229
                        match |= i == matchIndex;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   230
                        if (any) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   231
                            sb.append(",");
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   232
                        } else {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   233
                            if (ahead) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   234
                                sb.append("-");
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   235
                            }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   236
                        }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   237
                        sb.append(values[i]);
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   238
                        any = true;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   239
                    }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   240
                }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   241
                match |= !any;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   242
                return ahead || any;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   243
            }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   244
        }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   245
        KindList klcase = new KindList(new String[] {"class", "method", "expression", "vardecl"}, 2);
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   246
        while (klcase.next()) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   247
            KindList klact  = new KindList(new String[] {"added", "modified", "replaced"}, 0);
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   248
            while (klact.next()) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   249
                KindList klwhen = new KindList(new String[] {"update", "primary"}, 1);
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   250
                while (klwhen.next()) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   251
                    sb.setLength(0);
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   252
                    klwhen.append(
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   253
                        klact.append(
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   254
                            klcase.append(false)));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   255
                    boolean match = klcase.match && klact.match && klwhen.match;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   256
                    String select = sb.toString();
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   257
                    String yes = "+++" + select + "+++";
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   258
                    String no  = "---" + select + "---";
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   259
                    String expect = match? yes : no;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   260
                    tests.add((a) -> assertCommand(a, "/set format ate display '" + no  + "'", ""));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   261
                    tests.add((a) -> assertCommand(a, "/set format ate display '" + yes + "' " + select, ""));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   262
                    tests.add((a) -> assertCommand(a, "\"" + select + "\"", expect));
43264
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   263
             /**** for sample generation ****
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   264
             System.err.println("                (a) -> assertCommand(a, \"/set format ate display '" + no  + "'\", \"\"),");
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   265
             System.err.println("                (a) -> assertCommand(a, \"/set format ate display '" + yes + "' " + select + "\", \"\"),");
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   266
             System.err.println("                (a) -> assertCommand(a, \"\\\"" + select + "\\\"\", \"" + expect + "\"),\n");
7b06e19184de 8171130: jshell tool: /edit adds empty statement to brace terminated snippet
rfield
parents: 41937
diff changeset
   267
             ****/
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   268
                }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   269
            }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   270
        }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   271
        tests.add((a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal"));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   272
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   273
        try {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   274
            test(tests.toArray(new ReplTest[tests.size()]));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   275
        } finally {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   276
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   277
            });
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   278
        }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   279
    }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   280
38513
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   281
    public void testSetTruncation() {
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   282
        try {
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   283
            test(
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   284
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", ""),
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   285
                    (a) -> assertCommand(a, "String s = java.util.stream.IntStream.range(65, 74)"+
41937
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   286
                            ".mapToObj(i -> \"\"+(char)i).reduce((a,b) -> a + b + a).get() + \"XYZ\"",
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   287
                            "s ==> \"ABACABADABACABAEABACABADABACABAFABACABADABACABAE ... BACABAEABACABADABACABAXYZ\""),
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   288
                    (a) -> assertCommandOutputStartsWith(a, "/set mode test -quiet", ""),
38513
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   289
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback test", ""),
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   290
                    (a) -> assertCommand(a, "/set format test display '{type}:{value}' primary", ""),
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   291
                    (a) -> assertCommand(a, "/set truncation test 20", ""),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   292
                    (a) -> assertCommand(a, "/set truncation test", "|  /set truncation test 20"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   293
                    (a) -> assertCommandOutputContains(a, "/set truncation", "/set truncation test 20"),
38513
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   294
                    (a) -> assertCommand(a, "/set trunc test 10 varvalue", ""),
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   295
                    (a) -> assertCommand(a, "/set trunc test 3 assignment", ""),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   296
                    (a) -> assertCommandOutputContains(a, "/set truncation",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   297
                            "/set truncation test 10 varvalue"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   298
                    (a) -> assertCommandOutputContains(a, "/set truncation test",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   299
                            "/set truncation test 10 varvalue"),
41937
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   300
                    (a) -> assertCommand(a, "/var", "|    String s = \"ABACABADA"),
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   301
                    (a) -> assertCommand(a, "String r = s", "String:\"ABACABAD ... BAXYZ\""),
1313399705e9 8161969: jshell tool: /var value is not truncated per feedback setting
rfield
parents: 41635
diff changeset
   302
                    (a) -> assertCommand(a, "r", "String:\"ABACABADA"),
38513
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   303
                    (a) -> assertCommand(a, "r=s", "String:\"AB")
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   304
            );
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   305
        } finally {
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   306
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   307
            });
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   308
        }
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   309
    }
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   310
38615
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   311
    public void testDefaultTruncation() {
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   312
        test(
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   313
                    (a) -> assertCommand(a, "char[] cs = new char[2000];", null),
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   314
                    (a) -> assertCommand(a, "Arrays.fill(cs, 'A');", ""),
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   315
                    (a) -> assertCommandCheckOutput(a, "String s = new String(cs)",
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   316
                            (s) -> {
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   317
                                assertTrue(s.length() < 120, "Result too long (" + s.length() + ") -- " + s);
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   318
                                assertTrue(s.contains("AAAAAAAAAAAAAAAAAA"), "Bad value: " + s);
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   319
                            }),
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   320
                    (a) -> assertCommandCheckOutput(a, "s",
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   321
                            (s) -> {
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   322
                                assertTrue(s.length() > 300, "Result too short (" + s.length() + ") -- " + s);
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   323
                                assertTrue(s.contains("AAAAAAAAAAAAAAAAAA"), "Bad value: " + s);
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   324
                            }),
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   325
                    (a) -> assertCommandCheckOutput(a, "\"X\" + s",
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   326
                            (s) -> {
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   327
                                assertTrue(s.length() > 300, "Result too short (" + s.length() + ") -- " + s);
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   328
                                assertTrue(s.contains("XAAAAAAAAAAAAAAAAAA"), "Bad value: " + s);
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   329
                            })
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   330
        );
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   331
    }
9221159d84fb 8157261: jshell tool: truncation for expressions is not consistent
rfield
parents: 38539
diff changeset
   332
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   333
    public void testPrompt() {
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   334
        test(
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   335
                (a) -> assertCommand(a, "/set mode tp -quiet", "|  Created new feedback mode: tp"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   336
                (a) -> assertCommand(a, "/set prompt tp 'aaa' 'bbb'", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   337
                (a) -> assertCommand(a, "/set prompt tp",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   338
                        "|  /set prompt tp \"aaa\" \"bbb\""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   339
                (a) -> assertCommandOutputContains(a, "/set prompt",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   340
                        "|  /set prompt tp \"aaa\" \"bbb\""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   341
                (a) -> assertCommand(a, "/set mode -retain tp", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   342
                (a) -> assertCommand(a, "/set prompt tp 'ccc' 'ddd'", ""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   343
                (a) -> assertCommand(a, "/set prompt tp",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   344
                        "|  /set prompt tp \"ccc\" \"ddd\""),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   345
                (a) -> assertCommandCheckOutput(a, "/set mode tp",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   346
                        (s) -> {
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   347
                            try {
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   348
                                BufferedReader rdr = new BufferedReader(new StringReader(s));
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   349
                                assertEquals(rdr.readLine(), "|  /set mode tp -quiet",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   350
                                        "|  /set mode tp -quiet");
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   351
                                assertEquals(rdr.readLine(), "|  /set prompt tp \"aaa\" \"bbb\"",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   352
                                        "|  /set prompt tp \"aaa\" \"bbb\"");
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   353
                                String l = rdr.readLine();
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   354
                                while (l.startsWith("|  /set format tp ")) {
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   355
                                    l = rdr.readLine();
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   356
                                }
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   357
                                assertEquals(l, "|  /set mode -retain tp",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   358
                                        "|  /set mode -retain tp");
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   359
                                assertEquals(rdr.readLine(), "|  ",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   360
                                        "|  ");
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   361
                                assertEquals(rdr.readLine(), "|  /set mode tp -quiet",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   362
                                        "|  /set mode tp -quiet");
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   363
                                assertEquals(rdr.readLine(), "|  /set prompt tp \"ccc\" \"ddd\"",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   364
                                        "|  /set prompt tp \"ccc\" \"ddd\"");
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   365
                            } catch (IOException ex) {
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   366
                                fail("threw " + ex);
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   367
                            }
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   368
                        })
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   369
        );
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   370
    }
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   371
37640
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   372
    public void testShowFeedbackModes() {
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   373
        test(
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   374
                (a) -> assertCommandOutputContains(a, "/set feedback", "normal")
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   375
        );
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   376
    }
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   377
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   378
    public void testSetNewModeQuiet() {
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   379
        try {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   380
            test(
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   381
                    (a) -> assertCommandOutputStartsWith(a, "/set mode nmq -quiet normal", "|  Created new feedback mode: nmq"),
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   382
                    (a) -> assertCommand(a, "/set feedback nmq", ""),
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   383
                    (a) -> assertCommand(a, "/se mo nmq2 -q nor", ""),
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   384
                    (a) -> assertCommand(a, "/se fee nmq2", ""),
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   385
                    (a) -> assertCommand(a, "/set mode nmc -command normal", ""),
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   386
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback nmc", "|  Feedback mode: nmc"),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   387
                    (a) -> assertCommandOutputStartsWith(a, "/set mode nm -command",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   388
                            "|  Created new feedback mode: nm"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   389
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback nm", "|  Feedback mode: nm"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   390
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   391
            );
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   392
        } finally {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   393
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   394
            });
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   395
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   396
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   397
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   398
    public void testSetError() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   399
        try {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   400
            test(
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   401
                    (a) -> assertCommandOutputStartsWith(a, "/set mode tee -command foo",
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   402
                            "|  Does not match any current feedback mode: foo"),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   403
                    (a) -> assertCommandOutputStartsWith(a, "/set mode tee -quiet flurb",
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   404
                            "|  Does not match any current feedback mode: flurb"),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   405
                    (a) -> assertCommandOutputStartsWith(a, "/set mode -command tee",
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   406
                            "|  Created new feedback mode: tee"),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   407
                    (a) -> assertCommandOutputStartsWith(a, "/set mode verbose -command",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   408
                            "|  Mode to be created already exists: verbose"),
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   409
                    (a) -> assertCommandOutputStartsWith(a, "/set mode te -command normal",
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   410
                            "|  Created new feedback mode: te"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   411
                    (a) -> assertCommand(a, "/set format te errorpre 'ERROR: '", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   412
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback te",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   413
                            ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   414
                    (a) -> assertCommandOutputStartsWith(a, "/set xyz",
36990
ec0b843a7af5 8147515: JShell: Internationalize
rfield
parents: 36778
diff changeset
   415
                            "ERROR: Invalid '/set' argument: xyz"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   416
                    (a) -> assertCommandOutputStartsWith(a, "/set f",
36990
ec0b843a7af5 8147515: JShell: Internationalize
rfield
parents: 36778
diff changeset
   417
                            "ERROR: Ambiguous sub-command argument to '/set': f"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   418
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback",
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   419
                            "|  /set feedback te"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   420
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback xyz",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   421
                            "ERROR: Does not match any current feedback mode"),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   422
                    (a) -> assertCommandOutputStartsWith(a, "/set feed",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   423
                            "|  /set feedback te"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   424
                    (a) -> assertCommandOutputStartsWith(a, "/set format xyz",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   425
                            "ERROR: Does not match any current feedback mode"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   426
                    (a) -> assertCommandOutputStartsWith(a, "/set format t",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   427
                            "ERROR: Matches more then one current feedback mode: t"),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   428
                    (a) -> assertCommandOutputStartsWith(a, "/set format qqq",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   429
                            "ERROR: Does not match any current feedback mode: qqq"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   430
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld",
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   431
                            "ERROR: Expected a field name:"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   432
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld aaa",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   433
                            "ERROR: Format 'aaa' must be quoted"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   434
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' frog",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   435
                            "ERROR: Not a valid selector"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   436
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import-frog",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   437
                            "ERROR: Not a valid selector"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   438
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import-import",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   439
                            "ERROR: Selector kind in multiple sections of"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   440
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import,added",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   441
                            "ERROR: Different selector kinds in same sections of"),
38513
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   442
                    (a) -> assertCommandOutputStartsWith(a, "/set trunc te 20x",
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   443
                            "ERROR: Truncation length must be an integer: 20x"),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   444
                    (a) -> assertCommandOutputStartsWith(a, "/set trunc qaz",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   445
                            "ERROR: Does not match any current feedback mode: qaz -- /set trunc qaz"),
38513
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   446
                    (a) -> assertCommandOutputStartsWith(a, "/set truncation te 111 import,added",
0ae85633d035 8154812: jshell tool: value printing truncation
rfield
parents: 37640
diff changeset
   447
                            "ERROR: Different selector kinds in same sections of"),
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   448
                    (a) -> assertCommandOutputContains(a, "/set mode",
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   449
                            "|  /set truncation verbose"),
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   450
                    (a) -> assertCommandOutputStartsWith(a, "/set mode -command",
38539
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   451
                            "ERROR: Missing the feedback mode"),
71874886920f 8157517: jshell tool: allow undoing operations
rfield
parents: 38531
diff changeset
   452
                    (a) -> assertCommandOutputStartsWith(a, "/set mode x -quiet y",
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   453
                            "ERROR: Does not match any current feedback mode"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   454
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt",
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   455
                            "|  /set prompt"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   456
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te",
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   457
                            "|  /set prompt te "),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   458
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te aaa xyz",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   459
                            "ERROR: Format 'aaa' must be quoted"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   460
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te 'aaa' xyz",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   461
                            "ERROR: Format 'xyz' must be quoted"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   462
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te aaa",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   463
                            "ERROR: Format 'aaa' must be quoted"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   464
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te 'aaa'",
41635
cb3d04878117 8163840: jshell tool: provide way to display configuration settings
rfield
parents: 38615
diff changeset
   465
                            "ERROR: Continuation prompt required"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   466
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   467
                            "|  Feedback mode: normal")
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   468
            );
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   469
        } finally {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   470
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   471
            });
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   472
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   473
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   474
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   475
    public void testSetHelp() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   476
        try {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   477
            test(
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   478
                    (a) -> assertCommandOutputContains(a, "/help /set", "command to launch"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   479
                    (a) -> assertCommandOutputContains(a, "/help /set format", "display"),
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   480
                    (a) -> assertCommandOutputContains(a, "/hel /se for", "vardecl"),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   481
                    (a) -> assertCommandOutputContains(a, "/help /set editor", "temporary file")
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   482
            );
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   483
        } finally {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   484
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   485
            });
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   486
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   487
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   488
}