File: ToolFormatTest.java

package info (click to toggle)
libnb-javaparser-java 9%2B2018-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 65,320 kB
  • sloc: java: 440,096; xml: 6,359; sh: 865; makefile: 314
file content (488 lines) | stat: -rw-r--r-- 28,989 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
/*
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

/*
 * @test
 * @bug 8148316 8148317 8151755 8152246 8153551 8154812 8157261 8163840 8166637 8161969 8173007
 * @summary Tests for output customization
 * @library /tools/lib
 * @modules jdk.compiler/com.sun.tools.javac.api
 *          jdk.compiler/com.sun.tools.javac.main
 *          jdk.jdeps/com.sun.tools.javap
 *          jdk.jshell/jdk.internal.jshell.tool
 * @build KullaTesting TestingInputStream toolbox.ToolBox Compiler
 * @run testng ToolFormatTest
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;

@Test
public class ToolFormatTest extends ReplToolTesting {

    public void testSetFormat() {
        try {
            test(
                    (a) -> assertCommandOutputStartsWith(a, "/set mode test -command", "|  Created new feedback mode: test"),
                    (a) -> assertCommand(a, "/set format test pre '$ '", ""),
                    (a) -> assertCommand(a, "/set format test post ''", ""),
                    (a) -> assertCommand(a, "/set format test act 'ADD' added", ""),
                    (a) -> assertCommand(a, "/set format test act 'MOD' modified", ""),
                    (a) -> assertCommand(a, "/set format test act 'REP' replaced", ""),
                    (a) -> assertCommand(a, "/set format test act 'OVR' overwrote", ""),
                    (a) -> assertCommand(a, "/set format test act 'USE' used", ""),
                    (a) -> assertCommand(a, "/set format test act 'DRP' dropped", ""),
                    (a) -> assertCommand(a, "/set format test up 'UP-' update", ""),
                    (a) -> assertCommand(a, "/set format test action '{up}{act} '", ""),
                    (a) -> assertCommand(a, "/set format test resolve 'OK' ok", ""),
                    (a) -> assertCommand(a, "/set format test resolve 'DEF' defined", ""),
                    (a) -> assertCommand(a, "/set format test resolve 'NODEF' notdefined", ""),
                    (a) -> assertCommand(a, "/set format test fname ':{name} ' ", ""),
                    (a) -> assertCommand(a, "/set format test ftype '[{type}]' method,expression", ""),
                    (a) -> assertCommand(a, "/set format test result '={value} ' expression", ""),
                    (a) -> assertCommand(a, "/set format test display '{pre}{action}{ftype}{fname}{result}{resolve}'", ""),
                    (a) -> assertCommand(a, "/set format test display '{pre}HI this is enum' enum", ""),
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback test", "$ Feedback mode: test"),
                    (a) -> assertCommand(a, "class D {}", "$ ADD :D OK"),
                    (a) -> assertCommand(a, "void m() {}", "$ ADD []:m OK"),
                    (a) -> assertCommand(a, "interface EX extends EEX {}", "$ ADD :EX NODEF"),
                    (a) -> assertCommand(a, "56", "$ ADD [int]:$4 =56 OK"),
                    (a) -> assertCommand(a, "class D { int hh; }", "$ REP :D OK$ UP-OVR :D OK"),
                    (a) -> assertCommand(a, "enum E {A,B}", "$ HI this is enum"),
                    (a) -> assertCommand(a, "int z() { return f(); }", "$ ADD []:z DEF"),
                    (a) -> assertCommand(a, "z()", "$ UP-USE []:z DEF"),
                    (a) -> assertCommand(a, "/drop z", "$ DRP []:z OK"),
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
            );
        } finally {
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
            });
        }
    }

    public void testSetFormatOverride() {
        test(
                (a) -> assertCommand(a, "/set mode tm -c", "|  Created new feedback mode: tm"),
                (a) -> assertCommand(a, "/se fo tm x \"aaa\"", ""),
                (a) -> assertCommand(a, "/se fo tm x \"bbb\" class,method-added", ""),
                (a) -> assertCommand(a, "/se fo tm x",
                        "|  /set format tm x \"aaa\" \n" +
                        "|  /set format tm x \"bbb\" class,method-added"),
                (a) -> assertCommand(a, "/se fo tm x \"ccc\" class,method-added,modified", ""),
                (a) -> assertCommand(a, "/se fo tm x \"ddd\" class,method-added", ""),
                (a) -> assertCommand(a, "/se fo tm x \"eee\" method-added", ""),
                (a) -> assertCommand(a, "/se fo tm x",
                        "|  /set format tm x \"aaa\" \n" +
                        "|  /set format tm x \"ccc\" class,method-added,modified\n" +
                        "|  /set format tm x \"ddd\" class,method-added\n" +
                        "|  /set format tm x \"eee\" method-added"),
                (a) -> assertCommand(a, "/se fo tm x \"EEE\" method-added,replaced", ""),
                (a) -> assertCommand(a, "/se fo tm x",
                        "|  /set format tm x \"aaa\" \n" +
                        "|  /set format tm x \"ccc\" class,method-added,modified\n" +
                        "|  /set format tm x \"ddd\" class,method-added\n" +
                        "|  /set format tm x \"EEE\" method-added,replaced"),
                (a) -> assertCommand(a, "/se fo tm x \"fff\" method-added,replaced-ok", ""),
                (a) -> assertCommand(a, "/se fo tm x",
                        "|  /set format tm x \"aaa\" \n" +
                        "|  /set format tm x \"ccc\" class,method-added,modified\n" +
                        "|  /set format tm x \"ddd\" class,method-added\n" +
                        "|  /set format tm x \"EEE\" method-added,replaced\n" +
                        "|  /set format tm x \"fff\" method-added,replaced-ok"),
                (a) -> assertCommand(a, "/se fo tm x \"ggg\" method-ok", ""),
                (a) -> assertCommand(a, "/se fo tm x",
                        "|  /set format tm x \"aaa\" \n" +
                        "|  /set format tm x \"ccc\" class,method-added,modified\n" +
                        "|  /set format tm x \"ddd\" class,method-added\n" +
                        "|  /set format tm x \"EEE\" method-added,replaced\n" +
                        "|  /set format tm x \"ggg\" method-ok"),
                (a) -> assertCommand(a, "/se fo tm x \"hhh\" method", ""),
                (a) -> assertCommand(a, "/se fo tm x",
                        "|  /set format tm x \"aaa\" \n" +
                        "|  /set format tm x \"ccc\" class,method-added,modified\n" +
                        "|  /set format tm x \"ddd\" class,method-added\n" +
                        "|  /set format tm x \"hhh\" method"),
                (a) -> assertCommand(a, "/se fo tm x \"iii\" method,class", ""),
                (a) -> assertCommand(a, "/se fo tm x",
                        "|  /set format tm x \"aaa\" \n" +
                        "|  /set format tm x \"iii\" class,method"),
                (a) -> assertCommand(a, "/se fo tm x \"jjj\"", ""),
                (a) -> assertCommand(a, "/se fo tm x",
                        "|  /set format tm x \"jjj\"")
        );
    }

    public void testSetFormatSelectorSample() {
        test(
                (a) -> assertCommandOutputStartsWith(a, "/set mode ate -quiet",
                            "|  Created new feedback mode: ate"),
                (a) -> assertCommand(a, "/set feedback ate", ""),

                (a) -> assertCommand(a, "/set format ate display '---replaced,modified,added-primary---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++replaced,modified,added-primary+++' replaced,modified,added-primary", ""),
                (a) -> assertCommand(a, "\"replaced,modified,added-primary\"", "+++replaced,modified,added-primary+++"),

                (a) -> assertCommand(a, "/set format ate display '---added-primary,update---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++added-primary,update+++' added-primary,update", ""),
                (a) -> assertCommand(a, "\"added-primary,update\"", "+++added-primary,update+++"),


                (a) -> assertCommand(a, "/set format ate display '---method-replaced-primary---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++method-replaced-primary+++' method-replaced-primary", ""),
                (a) -> assertCommand(a, "\"method-replaced-primary\"", "---method-replaced-primary---"),

                (a) -> assertCommand(a, "/set format ate display '---method-replaced-update---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++method-replaced-update+++' method-replaced-update", ""),
                (a) -> assertCommand(a, "\"method-replaced-update\"", "---method-replaced-update---"),

                (a) -> assertCommand(a, "/set format ate display '---method-added-update---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++method-added-update+++' method-added-update", ""),
                (a) -> assertCommand(a, "\"method-added-update\"", "---method-added-update---"),

                (a) -> assertCommand(a, "/set format ate display '---method-added---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++method-added+++' method-added", ""),
                (a) -> assertCommand(a, "\"method-added\"", "---method-added---"),

                (a) -> assertCommand(a, "/set format ate display '---class-modified,added-primary,update---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++class-modified,added-primary,update+++' class-modified,added-primary,update", ""),
                (a) -> assertCommand(a, "\"class-modified,added-primary,update\"", "---class-modified,added-primary,update---"),

                (a) -> assertCommand(a, "/set format ate display '---class-modified,added-primary---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++class-modified,added-primary+++' class-modified,added-primary", ""),
                (a) -> assertCommand(a, "\"class-modified,added-primary\"", "---class-modified,added-primary---"),

                (a) -> assertCommand(a, "/set format ate display '---class-modified,added-update---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++class-modified,added-update+++' class-modified,added-update", ""),
                (a) -> assertCommand(a, "\"class-modified,added-update\"", "---class-modified,added-update---"),

                (a) -> assertCommand(a, "/set format ate display '---replaced,added---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++replaced,added+++' replaced,added", ""),
                (a) -> assertCommand(a, "\"replaced,added\"", "+++replaced,added+++"),

                (a) -> assertCommand(a, "/set format ate display '---replaced-primary,update---'", ""),
                (a) -> assertCommand(a, "/set format ate display '+++replaced-primary,update+++' replaced-primary,update", ""),
                (a) -> assertCommand(a, "\"replaced-primary,update\"", "---replaced-primary,update---"),

                (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
        );
    }

    // This test is exhaustive and takes to long for routine testing -- disabled.
    // A sampling of these has been added (above: testSetFormatSelectorSample).
    // See 8173007
    // Save for possible future deep testing or debugging
    @Test(enabled = false)
    public void testSetFormatSelector() {
        List<ReplTest> tests = new ArrayList<>();
        tests.add((a) -> assertCommandOutputStartsWith(a, "/set mode ate -quiet",
                            "|  Created new feedback mode: ate"));
        tests.add((a) -> assertCommand(a, "/set feedback ate", ""));
        StringBuilder sb = new StringBuilder();
        class KindList {
            final String[] values;
            final int matchIndex;
            int current;
            boolean match;
            KindList(String[] values, int matchIndex) {
                this.values = values;
                this.matchIndex = matchIndex;
                this.current = 1 << values.length;
            }
            boolean next() {
                if (current <= 0) {
                    return false;
                }
                --current;
                return true;
            }
            boolean append(boolean ahead) {
                boolean any = false;
                match = false;
                for (int i = values.length - 1; i >= 0 ; --i) {
                    if ((current & (1 << i)) != 0) {
                        match |= i == matchIndex;
                        if (any) {
                            sb.append(",");
                        } else {
                            if (ahead) {
                                sb.append("-");
                            }
                        }
                        sb.append(values[i]);
                        any = true;
                    }
                }
                match |= !any;
                return ahead || any;
            }
        }
        KindList klcase = new KindList(new String[] {"class", "method", "expression", "vardecl"}, 2);
        while (klcase.next()) {
            KindList klact  = new KindList(new String[] {"added", "modified", "replaced"}, 0);
            while (klact.next()) {
                KindList klwhen = new KindList(new String[] {"update", "primary"}, 1);
                while (klwhen.next()) {
                    sb.setLength(0);
                    klwhen.append(
                        klact.append(
                            klcase.append(false)));
                    boolean match = klcase.match && klact.match && klwhen.match;
                    String select = sb.toString();
                    String yes = "+++" + select + "+++";
                    String no  = "---" + select + "---";
                    String expect = match? yes : no;
                    tests.add((a) -> assertCommand(a, "/set format ate display '" + no  + "'", ""));
                    tests.add((a) -> assertCommand(a, "/set format ate display '" + yes + "' " + select, ""));
                    tests.add((a) -> assertCommand(a, "\"" + select + "\"", expect));
             /**** for sample generation ****
             System.err.println("                (a) -> assertCommand(a, \"/set format ate display '" + no  + "'\", \"\"),");
             System.err.println("                (a) -> assertCommand(a, \"/set format ate display '" + yes + "' " + select + "\", \"\"),");
             System.err.println("                (a) -> assertCommand(a, \"\\\"" + select + "\\\"\", \"" + expect + "\"),\n");
             ****/
                }
            }
        }
        tests.add((a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal"));

        try {
            test(tests.toArray(new ReplTest[tests.size()]));
        } finally {
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
            });
        }
    }

    public void testSetTruncation() {
        try {
            test(
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", ""),
                    (a) -> assertCommand(a, "String s = java.util.stream.IntStream.range(65, 74)"+
                            ".mapToObj(i -> \"\"+(char)i).reduce((a,b) -> a + b + a).get() + \"XYZ\"",
                            "s ==> \"ABACABADABACABAEABACABADABACABAFABACABADABACABAE ... BACABAEABACABADABACABAXYZ\""),
                    (a) -> assertCommandOutputStartsWith(a, "/set mode test -quiet", ""),
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback test", ""),
                    (a) -> assertCommand(a, "/set format test display '{type}:{value}' primary", ""),
                    (a) -> assertCommand(a, "/set truncation test 20", ""),
                    (a) -> assertCommand(a, "/set truncation test", "|  /set truncation test 20"),
                    (a) -> assertCommandOutputContains(a, "/set truncation", "/set truncation test 20"),
                    (a) -> assertCommand(a, "/set trunc test 10 varvalue", ""),
                    (a) -> assertCommand(a, "/set trunc test 3 assignment", ""),
                    (a) -> assertCommandOutputContains(a, "/set truncation",
                            "/set truncation test 10 varvalue"),
                    (a) -> assertCommandOutputContains(a, "/set truncation test",
                            "/set truncation test 10 varvalue"),
                    (a) -> assertCommand(a, "/var", "|    String s = \"ABACABADA"),
                    (a) -> assertCommand(a, "String r = s", "String:\"ABACABAD ... BAXYZ\""),
                    (a) -> assertCommand(a, "r", "String:\"ABACABADA"),
                    (a) -> assertCommand(a, "r=s", "String:\"AB")
            );
        } finally {
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
            });
        }
    }

    public void testDefaultTruncation() {
        test(
                    (a) -> assertCommand(a, "char[] cs = new char[2000];", null),
                    (a) -> assertCommand(a, "Arrays.fill(cs, 'A');", ""),
                    (a) -> assertCommandCheckOutput(a, "String s = new String(cs)",
                            (s) -> {
                                assertTrue(s.length() < 120, "Result too long (" + s.length() + ") -- " + s);
                                assertTrue(s.contains("AAAAAAAAAAAAAAAAAA"), "Bad value: " + s);
                            }),
                    (a) -> assertCommandCheckOutput(a, "s",
                            (s) -> {
                                assertTrue(s.length() > 300, "Result too short (" + s.length() + ") -- " + s);
                                assertTrue(s.contains("AAAAAAAAAAAAAAAAAA"), "Bad value: " + s);
                            }),
                    (a) -> assertCommandCheckOutput(a, "\"X\" + s",
                            (s) -> {
                                assertTrue(s.length() > 300, "Result too short (" + s.length() + ") -- " + s);
                                assertTrue(s.contains("XAAAAAAAAAAAAAAAAAA"), "Bad value: " + s);
                            })
        );
    }

    public void testPrompt() {
        test(
                (a) -> assertCommand(a, "/set mode tp -quiet", "|  Created new feedback mode: tp"),
                (a) -> assertCommand(a, "/set prompt tp 'aaa' 'bbb'", ""),
                (a) -> assertCommand(a, "/set prompt tp",
                        "|  /set prompt tp \"aaa\" \"bbb\""),
                (a) -> assertCommandOutputContains(a, "/set prompt",
                        "|  /set prompt tp \"aaa\" \"bbb\""),
                (a) -> assertCommand(a, "/set mode -retain tp", ""),
                (a) -> assertCommand(a, "/set prompt tp 'ccc' 'ddd'", ""),
                (a) -> assertCommand(a, "/set prompt tp",
                        "|  /set prompt tp \"ccc\" \"ddd\""),
                (a) -> assertCommandCheckOutput(a, "/set mode tp",
                        (s) -> {
                            try {
                                BufferedReader rdr = new BufferedReader(new StringReader(s));
                                assertEquals(rdr.readLine(), "|  /set mode tp -quiet",
                                        "|  /set mode tp -quiet");
                                assertEquals(rdr.readLine(), "|  /set prompt tp \"aaa\" \"bbb\"",
                                        "|  /set prompt tp \"aaa\" \"bbb\"");
                                String l = rdr.readLine();
                                while (l.startsWith("|  /set format tp ")) {
                                    l = rdr.readLine();
                                }
                                assertEquals(l, "|  /set mode -retain tp",
                                        "|  /set mode -retain tp");
                                assertEquals(rdr.readLine(), "|  ",
                                        "|  ");
                                assertEquals(rdr.readLine(), "|  /set mode tp -quiet",
                                        "|  /set mode tp -quiet");
                                assertEquals(rdr.readLine(), "|  /set prompt tp \"ccc\" \"ddd\"",
                                        "|  /set prompt tp \"ccc\" \"ddd\"");
                            } catch (IOException ex) {
                                fail("threw " + ex);
                            }
                        })
        );
    }

    public void testShowFeedbackModes() {
        test(
                (a) -> assertCommandOutputContains(a, "/set feedback", "normal")
        );
    }

    public void testSetNewModeQuiet() {
        try {
            test(
                    (a) -> assertCommandOutputStartsWith(a, "/set mode nmq -quiet normal", "|  Created new feedback mode: nmq"),
                    (a) -> assertCommand(a, "/set feedback nmq", ""),
                    (a) -> assertCommand(a, "/se mo nmq2 -q nor", ""),
                    (a) -> assertCommand(a, "/se fee nmq2", ""),
                    (a) -> assertCommand(a, "/set mode nmc -command normal", ""),
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback nmc", "|  Feedback mode: nmc"),
                    (a) -> assertCommandOutputStartsWith(a, "/set mode nm -command",
                            "|  Created new feedback mode: nm"),
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback nm", "|  Feedback mode: nm"),
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
            );
        } finally {
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
            });
        }
    }

    public void testSetError() {
        try {
            test(
                    (a) -> assertCommandOutputStartsWith(a, "/set mode tee -command foo",
                            "|  Does not match any current feedback mode: foo"),
                    (a) -> assertCommandOutputStartsWith(a, "/set mode tee -quiet flurb",
                            "|  Does not match any current feedback mode: flurb"),
                    (a) -> assertCommandOutputStartsWith(a, "/set mode -command tee",
                            "|  Created new feedback mode: tee"),
                    (a) -> assertCommandOutputStartsWith(a, "/set mode verbose -command",
                            "|  Mode to be created already exists: verbose"),
                    (a) -> assertCommandOutputStartsWith(a, "/set mode te -command normal",
                            "|  Created new feedback mode: te"),
                    (a) -> assertCommand(a, "/set format te errorpre 'ERROR: '", ""),
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback te",
                            ""),
                    (a) -> assertCommandOutputStartsWith(a, "/set xyz",
                            "ERROR: Invalid '/set' argument: xyz"),
                    (a) -> assertCommandOutputStartsWith(a, "/set f",
                            "ERROR: Ambiguous sub-command argument to '/set': f"),
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback",
                            "|  /set feedback te"),
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback xyz",
                            "ERROR: Does not match any current feedback mode"),
                    (a) -> assertCommandOutputStartsWith(a, "/set feed",
                            "|  /set feedback te"),
                    (a) -> assertCommandOutputStartsWith(a, "/set format xyz",
                            "ERROR: Does not match any current feedback mode"),
                    (a) -> assertCommandOutputStartsWith(a, "/set format t",
                            "ERROR: Matches more then one current feedback mode: t"),
                    (a) -> assertCommandOutputStartsWith(a, "/set format qqq",
                            "ERROR: Does not match any current feedback mode: qqq"),
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld",
                            "ERROR: Expected a field name:"),
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld aaa",
                            "ERROR: Format 'aaa' must be quoted"),
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' frog",
                            "ERROR: Not a valid selector"),
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import-frog",
                            "ERROR: Not a valid selector"),
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import-import",
                            "ERROR: Selector kind in multiple sections of"),
                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import,added",
                            "ERROR: Different selector kinds in same sections of"),
                    (a) -> assertCommandOutputStartsWith(a, "/set trunc te 20x",
                            "ERROR: Truncation length must be an integer: 20x"),
                    (a) -> assertCommandOutputStartsWith(a, "/set trunc qaz",
                            "ERROR: Does not match any current feedback mode: qaz -- /set trunc qaz"),
                    (a) -> assertCommandOutputStartsWith(a, "/set truncation te 111 import,added",
                            "ERROR: Different selector kinds in same sections of"),
                    (a) -> assertCommandOutputContains(a, "/set mode",
                            "|  /set truncation verbose"),
                    (a) -> assertCommandOutputStartsWith(a, "/set mode -command",
                            "ERROR: Missing the feedback mode"),
                    (a) -> assertCommandOutputStartsWith(a, "/set mode x -quiet y",
                            "ERROR: Does not match any current feedback mode"),
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt",
                            "|  /set prompt"),
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te",
                            "|  /set prompt te "),
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te aaa xyz",
                            "ERROR: Format 'aaa' must be quoted"),
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te 'aaa' xyz",
                            "ERROR: Format 'xyz' must be quoted"),
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te aaa",
                            "ERROR: Format 'aaa' must be quoted"),
                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te 'aaa'",
                            "ERROR: Continuation prompt required"),
                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal",
                            "|  Feedback mode: normal")
            );
        } finally {
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
            });
        }
    }

    public void testSetHelp() {
        try {
            test(
                    (a) -> assertCommandOutputContains(a, "/help /set", "command to launch"),
                    (a) -> assertCommandOutputContains(a, "/help /set format", "display"),
                    (a) -> assertCommandOutputContains(a, "/hel /se for", "vardecl"),
                    (a) -> assertCommandOutputContains(a, "/help /set editor", "temporary file")
            );
        } finally {
            assertCommandCheckOutput(false, "/set feedback normal", s -> {
            });
        }
    }
}