File: ToolCommandOptionTest.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 (533 lines) | stat: -rw-r--r-- 29,242 bytes parent folder | download | duplicates (2)
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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
/*
 * 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 8157395 8157393 8157517 8158738 8167128 8163840 8167637 8170368 8172102 8172179
 * @summary Tests of jshell comand options, and undoing operations
 * @modules jdk.jshell/jdk.internal.jshell.tool
 *          jdk.compiler/com.sun.tools.javac.api
 *          jdk.compiler/com.sun.tools.javac.main
 * @library /tools/lib
 * @build ToolCommandOptionTest ReplToolTesting
 * @run testng ToolCommandOptionTest
 */
import java.nio.file.Path;
import org.testng.annotations.Test;
import static org.testng.Assert.assertFalse;

@Test
public class ToolCommandOptionTest extends ReplToolTesting {

    public void listTest() {
        test(
                (a) -> assertCommand(a, "int x;",
                        "x ==> 0"),
                (a) -> assertCommand(a, "/li",
                        "1 : int x;"),
                (a) -> assertCommandOutputStartsWith(a, "/lis -st",
                        "s1 : import"),
                (a) -> assertCommandOutputStartsWith(a, "/list -all",
                        "s1 : import"),
                (a) -> assertCommandOutputContains(a, "/list -all",
                        "1 : int x;"),
                (a) -> assertCommandOutputContains(a, "/list -history",
                        "int x;"),
                (a) -> assertCommandOutputContains(a, "/li -h",
                        "/lis -st"),
                (a) -> assertCommand(a, "/list -furball",
                        "|  Unknown option: -furball -- /list -furball"),
                (a) -> assertCommand(a, "/list x",
                        "1 : int x;"),
                (a) -> assertCommand(a, "/li x -start",
                        "|  Options and snippets must not both be used: /list x -start"),
                (a) -> assertCommand(a, "/l -st -al",
                        "|  Conflicting options -- /list -st -al")
        );
    }

    public void typesTest() {
        test(
                (a) -> assertCommand(a, "int x",
                        "x ==> 0"),
                (a) -> assertCommand(a, "/types x",
                        "|  This command does not accept the snippet 'x' : int x;"),
                (a) -> assertCommand(a, "class C {}",
                        "|  created class C"),
                (a) -> assertCommand(a, "/ty",
                        "|    class C"),
                (a) -> assertCommand(a, "/ty -st",
                        ""),
                (a) -> assertCommand(a, "/types -all",
                        "|    class C"),
                (a) -> assertCommand(a, "/types -furball",
                        "|  Unknown option: -furball -- /types -furball"),
                (a) -> assertCommand(a, "/types C",
                        "|    class C"),
                (a) -> assertCommand(a, "/types C -start",
                        "|  Options and snippets must not both be used: /types C -start"),
                (a) -> assertCommand(a, "/ty -st -al",
                        "|  Conflicting options -- /types -st -al")
        );
    }

    public void dropTest() {
        test(false, new String[]{"--no-startup"},
                (a) -> assertCommand(a, "int x = 5;",
                        "x ==> 5"),
                (a) -> assertCommand(a, "x",
                        "x ==> 5"),
                (a) -> assertCommand(a, "long y;",
                        "y ==> 0"),
                (a) -> assertCommand(a, "/drop -furball",
                        "|  Unknown option: -furball -- /drop -furball"),
                (a) -> assertCommand(a, "/drop -all",
                        "|  Unknown option: -all -- /drop -all"),
                (a) -> assertCommandOutputStartsWith(a, "/drop z",
                        "|  No such snippet: z"),
                (a) -> assertCommand(a, "/drop 2",
                        ""),
                (a) -> assertCommandOutputStartsWith(a, "23qwl",
                        "|  Error:"),
                (a) -> assertCommandOutputStartsWith(a, "/drop e1",
                        "|  This command does not accept the snippet 'e1' : 23qwl"),
                (a) -> assertCommand(a, "/dr x y",
                        "|  dropped variable x\n" +
                        "|  dropped variable y"),
                (a) -> assertCommand(a, "/list",
                        "")
        );
    }

    public void setEditorTest() {
        test(
                (a) -> assertCommand(a, "/set editor -furball",
                        "|  Unknown option: -furball -- /set editor -furball"),
                (a) -> assertCommand(a, "/set editor -furball prog",
                        "|  Unknown option: -furball -- /set editor -furball prog"),
                (a) -> assertCommand(a, "/set editor -furball -mattress",
                        "|  Unknown option: -furball -mattress -- /set editor -furball -mattress"),
                (a) -> assertCommand(a, "/set editor -default prog",
                        "|  Specify -default option, -delete option, or program -- /set editor -default prog"),
                (a) -> assertCommand(a, "/set editor prog",
                        "|  Editor set to: prog"),
                (a) -> assertCommand(a, "/set editor prog -default",
                        "|  Editor set to: prog -default"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor prog -default"),
                (a) -> assertCommand(a, "/se ed prog -furball",
                        "|  Editor set to: prog -furball"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor prog -furball"),
                (a) -> assertCommand(a, "/se ed -delete",
                        "|  Editor set to: -default"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor -default"),
                (a) -> assertCommand(a, "/set editor prog arg1 -furball arg3 -default arg4",
                        "|  Editor set to: prog arg1 -furball arg3 -default arg4"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor prog arg1 -furball arg3 -default arg4"),
                (a) -> assertCommand(a, "/set editor -default",
                        "|  Editor set to: -default"),
                (a) -> assertCommand(a, "/se edi -def",
                        "|  Editor set to: -default"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor -default")
        );
    }

    public void retainEditorTest() {
        test(
                (a) -> assertCommand(a, "/set editor -retain -furball",
                        "|  Unknown option: -furball -- /set editor -retain -furball"),
                (a) -> assertCommand(a, "/set editor -retain -furball prog",
                        "|  Unknown option: -furball -- /set editor -retain -furball prog"),
                (a) -> assertCommand(a, "/set editor -retain -furball -mattress",
                        "|  Unknown option: -furball -mattress -- /set editor -retain -furball -mattress"),
                (a) -> assertCommand(a, "/set editor -retain -default prog",
                        "|  Specify -default option, -delete option, or program -- /set editor -retain -default prog"),
                (a) -> assertCommand(a, "/set editor -retain -wait",
                        "|  -wait applies to external editors"),
                (a) -> assertCommand(a, "/set editor -retain -default -wait",
                        "|  -wait applies to external editors"),
                (a) -> assertCommand(a, "/set editor -retain prog",
                        "|  Editor set to: prog\n" +
                        "|  Editor setting retained: prog"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor -retain prog"),
                (a) -> assertCommand(a, "/se ed other",
                        "|  Editor set to: other"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor -retain prog\n" +
                        "|  /set editor other"),
                (a) -> assertCommand(a, "/se ed -delete",
                        "|  Editor set to: prog"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor -retain prog"),
                (a) -> assertCommand(a, "/set editor -retain prog -default",
                        "|  Editor set to: prog -default\n" +
                        "|  Editor setting retained: prog -default"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor -retain prog -default"),
                (a) -> assertCommand(a, "/se ed -retain prog -furball",
                        "|  Editor set to: prog -furball\n" +
                        "|  Editor setting retained: prog -furball"),
                (a) -> assertCommand(a, "/set editor -retain prog arg1 -furball arg3 -default arg4",
                        "|  Editor set to: prog arg1 -furball arg3 -default arg4\n" +
                        "|  Editor setting retained: prog arg1 -furball arg3 -default arg4"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor -retain prog arg1 -furball arg3 -default arg4"),
                (a) -> assertCommand(a, "/set editor -retain -default",
                        "|  Editor set to: -default\n" +
                        "|  Editor setting retained: -default"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor -retain -default"),
                (a) -> assertCommand(a, "/se e -ret -def",
                        "|  Editor set to: -default\n" +
                        "|  Editor setting retained: -default"),
                (a) -> assertCommand(a, "/set editor -retain",
                        "|  Editor setting retained: -default")
        );
    }

    public void setEditorEnvTest() {
        setEnvVar("EDITOR", "best one");
        setEditorEnvSubtest();
        setEnvVar("EDITOR", "not this");
        setEnvVar("VISUAL", "best one");
        setEditorEnvSubtest();
        setEnvVar("VISUAL", "not this");
        setEnvVar("JSHELLEDITOR", "best one");
        setEditorEnvSubtest();
    }

    private void setEditorEnvSubtest() {
        test(
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor best one"),
                (a) -> assertCommand(a, "/set editor prog",
                        "|  Editor set to: prog"),
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor prog"),
                (a) -> assertCommand(a, "/set editor -delete",
                        "|  Editor set to: best one"),
                (a) -> assertCommand(a, "/set editor -retain stored editor",
                        "|  Editor set to: stored editor\n" +
                        "|  Editor setting retained: stored editor")
        );
        test(
                (a) -> assertCommand(a, "/set editor",
                        "|  /set editor -retain stored editor"),
                (a) -> assertCommand(a, "/set editor -delete -retain",
                        "|  Editor set to: best one")
        );
    }

    public void setStartTest() {
        Compiler compiler = new Compiler();
        Path startup = compiler.getPath("StartTest/startup.txt");
        compiler.writeToFile(startup, "int iAmHere = 1234;");
        test(
                (a) -> assertCommand(a, "/set start -furball",
                        "|  Unknown option: -furball -- /set start -furball"),
                (a) -> assertCommand(a, "/set start -furball pyle",
                        "|  Unknown option: -furball -- /set start -furball pyle"),
                (a) -> assertCommand(a, "/se st pyle -furball",
                        "|  Unknown option: -furball -- /set st pyle -furball"),
                (a) -> assertCommand(a, "/set start -furball -mattress",
                        "|  Unknown option: -furball -mattress -- /set start -furball -mattress"),
                (a) -> assertCommand(a, "/set start foo -default",
                        "|  Specify no more than one of -default, -none, or a startup file name -- /set start foo -default"),
                (a) -> assertCommand(a, "/set start frfg",
                        "|  File 'frfg' for '/set start' is not found."),
                (a) -> assertCommand(a, "/set start DEFAULT frfg",
                        "|  File 'frfg' for '/set start' is not found."),
                (a) -> assertCommand(a, "/set start -default",
                        ""),
                (a) -> assertCommand(a, "/set start",
                        "|  /set start -default"),
                (a) -> assertCommand(a, "/set start DEFAULT",
                        ""),
                (a) -> assertCommand(a, "/set start",
                        "|  /set start -default"),
                (a) -> assertCommand(a, "/set start DEFAULT PRINTING",
                        ""),
                (a) -> assertCommandOutputContains(a, "/set start",
                        "/set start DEFAULT PRINTING", "void println", "import java.util.*"),
                (a) -> assertCommand(a, "/set start " + startup.toString(),
                        ""),
                (a) -> assertCommandOutputContains(a, "/set start",
                        "|  /set start " + startup + "\n" +
                        "|  ---- " + startup + " @ ", " ----\n" +
                        "|  int iAmHere = 1234;\n"),
                (a) -> assertCommand(a, "/se sta -no",
                        ""),
                (a) -> assertCommand(a, "/set start",
                        "|  /set start -none")
        );
    }

    public void retainStartTest() {
        Compiler compiler = new Compiler();
        Path startup = compiler.getPath("StartTest/startup.txt");
        compiler.writeToFile(startup, "int iAmHere = 1234;");
        test(
                (a) -> assertCommand(a, "/set start -retain -furball",
                        "|  Unknown option: -furball -- /set start -retain -furball"),
                (a) -> assertCommand(a, "/set start -retain -furball pyle",
                        "|  Unknown option: -furball -- /set start -retain -furball pyle"),
                (a) -> assertCommand(a, "/se st -re pyle -furball",
                        "|  Unknown option: -furball -- /set st -re pyle -furball"),
                (a) -> assertCommand(a, "/set start -retain -furball -mattress",
                        "|  Unknown option: -furball -mattress -- /set start -retain -furball -mattress"),
                (a) -> assertCommand(a, "/set start -retain foo -default",
                        "|  Specify no more than one of -default, -none, or a startup file name -- /set start -retain foo -default"),
                (a) -> assertCommand(a, "/set start -retain -default foo",
                        "|  Specify no more than one of -default, -none, or a startup file name -- /set start -retain -default foo"),
                (a) -> assertCommand(a, "/set start -retain frfg",
                        "|  File 'frfg' for '/set start' is not found."),
                (a) -> assertCommand(a, "/set start -retain -default",
                        ""),
                (a) -> assertCommand(a, "/set start",
                        "|  /set start -retain -default"),
                (a) -> assertCommand(a, "/set sta -no",
                        ""),
                (a) -> assertCommand(a, "/set start",
                        "|  /set start -retain -default\n" +
                        "|  /set start -none"),
                (a) -> assertCommand(a, "/se st -ret",
                        ""),
                (a) -> assertCommand(a, "/se sta",
                        "|  /set start -retain -none"),
                (a) -> assertCommand(a, "/set start -retain " + startup.toString(),
                        ""),
                (a) -> assertCommand(a, "/set start DEFAULT PRINTING",
                        ""),
                (a) -> assertCommandOutputStartsWith(a, "/set start",
                        "|  /set start -retain " + startup.toString() + "\n" +
                        "|  /set start DEFAULT PRINTING\n" +
                        "|  ---- " + startup.toString() + " @ "),
                (a) -> assertCommandOutputContains(a, "/set start",
                        "|  ---- DEFAULT ----\n",
                        "|  ---- PRINTING ----\n",
                        "|  int iAmHere = 1234;\n",
                        "|  void println(String s)",
                        "|  import java.io.*;")
        );
    }

    public void setModeTest() {
        test(
                (a) -> assertCommandOutputContains(a, "/set mode",
                        "|  /set format verbose unresolved"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode *",
                        "|  Expected a feedback mode name: *"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -quiet",
                        "|  Missing the feedback mode"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -quiet *",
                        "|  Expected a feedback mode name: *"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode amode normal thing",
                        "|  Unexpected arguments at end of command: thing"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode",
                        "|  To create a new mode either the -command or the -quiet option must be used"),
                (a) -> assertCommand(a, "/set mode mymode -command",
                        "|  Created new feedback mode: mymode"),
                (a) -> assertCommand(a, "/set mode mymode -delete",
                        ""),
                (a) -> assertCommand(a, "/set mode mymode normal -command",
                        "|  Created new feedback mode: mymode"),
                (a) -> assertCommand(a, "/set mode -del mymode",
                        ""),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -command -quiet",
                        "|  Conflicting options"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -delete -quiet",
                        "|  Conflicting options"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -command -delete",
                        "|  Conflicting options"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -d",
                        "|  No feedback mode named: mymode"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode normal -c",
                        "|  Mode to be created already exists: normal"),
                (a) -> assertCommand(a, "/se mo -c mymode",
                        "|  Created new feedback mode: mymode"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode",
                        "|  /set mode mymode -command"),
                (a) -> assertCommand(a, "/set feedback mymode",
                        "|  Feedback mode: mymode"),
                (a) -> assertCommand(a, "/se fe",
                        "|  /set feedback mymode\n" +
                        "|  \n" +
                        "|  Available feedback modes:\n" +
                        "|     concise\n" +
                        "|     mymode\n" +
                        "|     normal\n" +
                        "|     silent\n" +
                        "|     verbose"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -delete",
                        "|  The current feedback mode 'mymode' cannot be deleted"),
                (a) -> assertCommand(a, "/set feedback no",
                        "|  Feedback mode: normal"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -delete",
                        ""),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode",
                        "|  To create a new mode either the -command or the -quiet option must be used -- \n" +
                        "|  Does not match any current feedback mode: mymode -- /set mode mymode\n" +
                        "|  Available feedback modes:"),
                (a) -> assertCommandCheckOutput(a, "/set feedback",
                        (s) -> assertFalse(s.contains("mymode"), "Didn't delete: " + s))
        );
    }

    public void setModeSmashTest() {
        test(
                (a) -> assertCommand(a, "/set mode mymode -command",
                        "|  Created new feedback mode: mymode"),
                (a) -> assertCommand(a, "/set feedback mymode",
                        "|  Feedback mode: mymode"),
                (a) -> assertCommand(a, "/set format mymode display 'blurb'",
                        ""),
                (a) -> assertCommand(a, "45",
                        "blurb"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode normal",
                        "|  To create a new mode either the -command or the -quiet option must be used"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -command normal",
                        "|  Mode to be created already exists: mymode"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode mymode -delete",
                        "|  The current feedback mode 'mymode' cannot be deleted, use '/set feedback' first"),
                (a) -> assertCommand(a, "/set feedback normal",
                        "|  Feedback mode: normal"),
                (a) -> assertCommand(a, "/set mode mymode -delete",
                        ""),
                (a) -> assertCommand(a, "/set mode mymode -command normal",
                        "|  Created new feedback mode: mymode"),
                (a) -> assertCommand(a, "/set feedback mymode",
                        "|  Feedback mode: mymode"),
                (a) -> assertCommandOutputContains(a, "45",
                        " ==> 45")
        );
    }

    public void retainModeTest() {
        test(
                (a) -> assertCommandOutputStartsWith(a, "/set mode -retain",
                        "|  Missing the feedback mode"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -retain *",
                        "|  Expected a feedback mode name: *"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -retain amode normal",
                        "|  Unexpected arguments at end of command: normal"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -retain mymode",
                        "|  No feedback mode named: mymode"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -retain mymode -delete",
                        "|  No feedback mode named: mymode"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -retain -d mymode",
                        "|  No feedback mode named: mymode"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -retain normal",
                        "|  Not valid with a predefined mode: normal"),
                (a) -> assertCommand(a, "/set mode mymode verbose -command",
                        "|  Created new feedback mode: mymode"),
                (a) -> assertCommand(a, "/set mode -retain mymode",
                        ""),
                (a) -> assertCommand(a, "/set mode mymode -delete",
                        ""),
                (a) -> assertCommand(a, "/set mode -retain mymode -delete",
                        ""),
                (a) -> assertCommand(a, "/set mode kmode normal -command",
                        "|  Created new feedback mode: kmode"),
                (a) -> assertCommand(a, "/set mode -retain kmode",
                        ""),
                (a) -> assertCommand(a, "/set mode kmode -delete",
                        ""),
                (a) -> assertCommand(a, "/set mode tmode normal -command",
                        "|  Created new feedback mode: tmode"),
                (a) -> assertCommandOutputStartsWith(a, "/set feedback -retain tmode",
                        "|  '/set feedback -retain <mode>' requires that <mode> is predefined or has been retained with '/set mode -retain'"),
                (a) -> assertCommand(a, "/set format tmode display 'YES'",
                        ""),
                (a) -> assertCommand(a, "/set feedback tmode",
                        "|  Feedback mode: tmode"),
                (a) -> assertCommand(a, "45",
                        "YES"),
                (a) -> assertCommand(a, "/set mode -retain tmode",
                        ""),
                (a) -> assertCommand(a, "/set feedback -retain tmode",
                        "|  Feedback mode: tmode"),
                (a) -> assertCommand(a, "/set format tmode display 'blurb'",
                        ""),
                (a) -> assertCommand(a, "/set format tmode display",
                        "|  /set format tmode display \"blurb\""),
                (a) -> assertCommandOutputContains(a, "/set mode tmode",
                        "|  /set format tmode display \"YES\""),
                (a) -> assertCommand(a, "45",
                        "blurb")
        );
        test(
                (a) -> assertCommand(a, "/set format tmode display",
                        "|  /set format tmode display \"YES\""),
                (a) -> assertCommandOutputContains(a, "/set mode tmode",
                        "|  /set format tmode display \"YES\""),
                (a) -> assertCommand(a, "45",
                        "YES"),
                (a) -> assertCommand(a, "/set feedback kmode",
                        "|  Feedback mode: kmode"),
                (a) -> assertCommand(a, "/set feedback",
                        "|  /set feedback -retain tmode\n" +
                        "|  /set feedback kmode\n" +
                        "|  \n" +
                        "|  Retained feedback modes:\n" +
                        "|     kmode\n" +
                        "|     tmode\n" +
                        "|  Available feedback modes:\n" +
                        "|     concise\n" +
                        "|     kmode\n" +
                        "|     normal\n" +
                        "|     silent\n" +
                        "|     tmode\n" +
                        "|     verbose"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -retain kmode -delete",
                        "|  The current feedback mode 'kmode' cannot be deleted"),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -retain tmode -delete",
                        "|  The retained feedback mode 'tmode' cannot be deleted"),
                (a) -> assertCommand(a, "/set feedback -retain normal",
                        "|  Feedback mode: normal"),
                (a) -> assertCommand(a, "/set mode -retain tmode -delete",
                        ""),
                (a) -> assertCommandOutputStartsWith(a, "/set mode -retain kmode -delete",
                        "")
        );
        test(
                (a) -> assertCommandOutputStartsWith(a, "/set feedback tmode",
                        "|  Does not match any current feedback mode: tmode"),
                (a) -> assertCommandOutputStartsWith(a, "/set feedback kmode",
                        "|  Does not match any current feedback mode: kmode"),
                (a) -> assertCommandOutputStartsWith(a, "/set feedback mymode",
                        "|  Does not match any current feedback mode: mymode"),
                (a) -> assertCommandCheckOutput(a, "/set feedback",
                        (s) -> assertFalse(s.contains("mymode"), "Didn't delete mymode: " + s)),
                (a) -> assertCommandCheckOutput(a, "/set feedback",
                        (s) -> assertFalse(s.contains("kmode"), "Didn't delete kmode: " + s)),
                (a) -> assertCommandCheckOutput(a, "/set feedback",
                        (s) -> assertFalse(s.contains("tmode"), "Didn't delete tmode: " + s))
        );
    }

}