langtools/test/jdk/jshell/ToolFormatTest.java
author jlahoda
Thu, 05 May 2016 12:55:21 +0200
changeset 37939 3eb8c2a89b77
parent 37640 42e5136a367c
child 38513 0ae85633d035
permissions -rw-r--r--
8153761: JShell: Completion -- Show parameter names if possible Summary: Compiling code with -parameters; keeping parameter names when reading classfiles; searching JDK sources if parameter names are not available. Reviewed-by: rfield
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
37640
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
    26
 * @bug 8148316 8148317 8151755 8152246 8153551
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
 */
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    36
import java.util.ArrayList;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    37
import java.util.List;
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    38
import org.testng.annotations.Test;
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    39
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    40
@Test
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    41
public class ToolFormatTest extends ReplToolTesting {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    42
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    43
    public void testSetFormat() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    44
        try {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    45
            test(
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    46
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode test command", "|  Created new feedback mode: test"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    47
                    (a) -> assertCommand(a, "/set format test pre '$ '", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    48
                    (a) -> assertCommand(a, "/set format test post ''", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    49
                    (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
    50
                    (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
    51
                    (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
    52
                    (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
    53
                    (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
    54
                    (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
    55
                    (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
    56
                    (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
    57
                    (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
    58
                    (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
    59
                    (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
    60
                    (a) -> assertCommand(a, "/set format test fname ':{name} ' ", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    61
                    (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
    62
                    (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
    63
                    (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
    64
                    (a) -> assertCommand(a, "/set format test display '{pre}HI this is enum' enum", ""),
36990
ec0b843a7af5 8147515: JShell: Internationalize
rfield
parents: 36778
diff changeset
    65
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback test", "$ Feedback mode: test"),
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    66
                    (a) -> assertCommand(a, "class D {}", "$ ADD :D OK"),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    67
                    (a) -> assertCommand(a, "void m() {}", "$ ADD []:m OK"),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    68
                    (a) -> assertCommand(a, "interface EX extends EEX {}", "$ ADD :EX NODEF"),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    69
                    (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
    70
                    (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
    71
                    (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
    72
                    (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
    73
                    (a) -> assertCommand(a, "z()", "$ UP-USE []:z DEF"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    74
                    (a) -> assertCommand(a, "/drop z", "$ DRP []:z OK"),
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    75
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    76
            );
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    77
        } finally {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    78
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    79
            });
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    80
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    81
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
    82
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    83
    public void testSetFormatSelector() {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    84
        List<ReplTest> tests = new ArrayList<>();
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    85
        tests.add((a) -> assertCommandOutputStartsWith(a, "/set newmode ate quiet",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    86
                            "|  Created new feedback mode: ate"));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    87
        tests.add((a) -> assertCommand(a, "/set feedback ate", ""));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    88
        StringBuilder sb = new StringBuilder();
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    89
        class KindList {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    90
            final String[] values;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    91
            final int matchIndex;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    92
            int current;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    93
            boolean match;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    94
            KindList(String[] values, int matchIndex) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    95
                this.values = values;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    96
                this.matchIndex = matchIndex;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    97
                this.current = 1 << values.length;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    98
            }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
    99
            boolean next() {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   100
                if (current <= 0) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   101
                    return false;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   102
                }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   103
                --current;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   104
                return true;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   105
            }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   106
            boolean append(boolean ahead) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   107
                boolean any = false;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   108
                match = false;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   109
                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
   110
                    if ((current & (1 << i)) != 0) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   111
                        match |= i == matchIndex;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   112
                        if (any) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   113
                            sb.append(",");
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   114
                        } else {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   115
                            if (ahead) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   116
                                sb.append("-");
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   117
                            }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   118
                        }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   119
                        sb.append(values[i]);
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   120
                        any = true;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   121
                    }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   122
                }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   123
                match |= !any;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   124
                return ahead || any;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   125
            }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   126
        }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   127
        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
   128
        while (klcase.next()) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   129
            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
   130
            while (klact.next()) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   131
                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
   132
                while (klwhen.next()) {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   133
                    sb.setLength(0);
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   134
                    klwhen.append(
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   135
                        klact.append(
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   136
                            klcase.append(false)));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   137
                    boolean match = klcase.match && klact.match && klwhen.match;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   138
                    String select = sb.toString();
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   139
                    String yes = "+++" + select + "+++";
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   140
                    String no  = "---" + select + "---";
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   141
                    String expect = match? yes : no;
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   142
                    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
   143
                    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
   144
                    tests.add((a) -> assertCommand(a, "\"" + select + "\"", expect));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   145
                }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   146
            }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   147
        }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   148
        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
   149
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   150
        try {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   151
            test(tests.toArray(new ReplTest[tests.size()]));
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   152
        } finally {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   153
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   154
            });
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   155
        }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   156
    }
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   157
37640
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   158
    public void testShowFeedbackModes() {
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   159
        test(
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   160
                (a) -> assertCommandOutputContains(a, "/set feedback", "normal")
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   161
        );
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   162
    }
42e5136a367c 8153551: jshell tool: no longer a mechanism to see current feedback modes
rfield
parents: 36990
diff changeset
   163
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   164
    public void testSetNewModeQuiet() {
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   165
        try {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   166
            test(
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   167
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode nmq quiet normal", "|  Created new feedback mode: nmq"),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   168
                    (a) -> assertCommand(a, "/set feedback nmq", ""),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   169
                    (a) -> assertCommand(a, "/se ne nmq2 q nor", ""),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   170
                    (a) -> assertCommand(a, "/se fee nmq2", ""),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   171
                    (a) -> assertCommand(a, "/set newmode nmc command normal", ""),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   172
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback nmc", "|  Feedback mode: nmc"),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   173
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode nm", "|  Created new feedback mode: nm"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   174
                    (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
   175
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   176
            );
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   177
        } finally {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   178
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   179
            });
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   180
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   181
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   182
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   183
    public void testSetError() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   184
        try {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   185
            test(
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   186
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode tee command foo",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   187
                            "|  Does not match any current feedback mode: foo"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   188
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode tee flurb",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   189
                            "|  Specify either 'command' or 'quiet'"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   190
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te2",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   191
                            "|  Created new feedback mode: te2"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   192
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te2 command",
36990
ec0b843a7af5 8147515: JShell: Internationalize
rfield
parents: 36778
diff changeset
   193
                            "|  Expected a new feedback mode name. 'te2' is a known feedback mode"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   194
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te command normal",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   195
                            "|  Created new feedback mode: te"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   196
                    (a) -> assertCommand(a, "/set format te errorpre 'ERROR: '", ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   197
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback te",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   198
                            ""),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   199
                    (a) -> assertCommandOutputStartsWith(a, "/set ",
36990
ec0b843a7af5 8147515: JShell: Internationalize
rfield
parents: 36778
diff changeset
   200
                            "ERROR: The '/set' command requires a sub-command and arguments"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   201
                    (a) -> assertCommandOutputStartsWith(a, "/set xyz",
36990
ec0b843a7af5 8147515: JShell: Internationalize
rfield
parents: 36778
diff changeset
   202
                            "ERROR: Invalid '/set' argument: xyz"),
36718
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   203
                    (a) -> assertCommandOutputStartsWith(a, "/set f",
36990
ec0b843a7af5 8147515: JShell: Internationalize
rfield
parents: 36778
diff changeset
   204
                            "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
   205
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   206
                            "ERROR: Expected a feedback mode"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   207
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback xyz",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   208
                            "ERROR: Does not match any current feedback mode"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   209
                    (a) -> assertCommandOutputStartsWith(a, "/set format",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   210
                            "ERROR: Expected a feedback mode"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   211
                    (a) -> assertCommandOutputStartsWith(a, "/set format xyz",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   212
                            "ERROR: Does not match any current feedback mode"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   213
                    (a) -> assertCommandOutputStartsWith(a, "/set format t",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   214
                            "ERROR: Matches more then one current feedback mode: t"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   215
                    (a) -> assertCommandOutputStartsWith(a, "/set format te",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   216
                            "ERROR: Expected field name missing"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   217
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   218
                            "ERROR: Expected format missing"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   219
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld aaa",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   220
                            "ERROR: Format 'aaa' must be quoted"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   221
                    (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
   222
                            "ERROR: Not a valid selector"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   223
                    (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
   224
                            "ERROR: Not a valid selector"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   225
                    (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
   226
                            "ERROR: Selector kind in multiple sections of"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   227
                    (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
   228
                            "ERROR: Different selector kinds in same sections of"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   229
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   230
                            "ERROR: Expected new feedback mode"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   231
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   232
                            "ERROR: Expected a new feedback mode name"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   233
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode x xyz",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   234
                            "ERROR: Specify either 'command' or 'quiet'"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   235
                    (a) -> assertCommandOutputStartsWith(a, "/set newmode x quiet y",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   236
                            "ERROR: Does not match any current feedback mode"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   237
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   238
                            "ERROR: Expected a feedback mode"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   239
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   240
                            "ERROR: Expected format missing"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   241
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te aaa xyz",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   242
                            "ERROR: Format 'aaa' must be quoted"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   243
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te 'aaa' xyz",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   244
                            "ERROR: Format 'xyz' must be quoted"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   245
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   246
                            "ERROR: Expected a feedback mode"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   247
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   248
                            "ERROR: Expected format missing"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   249
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te aaa",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   250
                            "ERROR: Format 'aaa' must be quoted"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   251
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te 'aaa'",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   252
                            "ERROR: Expected format missing"),
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   253
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal",
bf40906bf49d 8151755: jshell tool: properly cover resolution issues in output configuration
rfield
parents: 36526
diff changeset
   254
                            "|  Feedback mode: normal")
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   255
            );
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   256
        } finally {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   257
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   258
            });
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   259
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   260
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   261
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   262
    public void testSetHelp() {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   263
        try {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   264
            test(
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   265
                    (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
   266
                    (a) -> assertCommandOutputContains(a, "/help /set format", "display"),
36494
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   267
                    (a) -> assertCommandOutputContains(a, "/hel /se for", "vardecl"),
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   268
                    (a) -> assertCommandOutputContains(a, "/help /set editor", "temporary file")
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   269
            );
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   270
        } finally {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   271
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   272
            });
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   273
        }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   274
    }
4175f47b2a50 8148316: jshell tool: Configurable output format
rfield
parents:
diff changeset
   275
}