blob: 9b23a512e12c5deaaa8d4978f8228d3a1a247ae9 [file] [log] [blame]
Bram Moolenaar72defda2016-01-17 18:04:33 +01001" Test argument list commands
2
Bram Moolenaar494e9062020-05-31 21:28:02 +02003source check.vim
Bram Moolenaar9f6277b2020-02-11 22:04:02 +01004source shared.vim
5source term_util.vim
6
Bram Moolenaar72defda2016-01-17 18:04:33 +01007func Test_argidx()
8 args a b c
9 last
10 call assert_equal(2, argidx())
11 %argdelete
12 call assert_equal(0, argidx())
Bram Moolenaar69a92fb2017-03-09 15:58:30 +010013 " doing it again doesn't result in an error
14 %argdelete
15 call assert_equal(0, argidx())
16 call assert_fails('2argdelete', 'E16:')
Bram Moolenaar72defda2016-01-17 18:04:33 +010017
18 args a b c
19 call assert_equal(0, argidx())
20 next
21 call assert_equal(1, argidx())
22 next
23 call assert_equal(2, argidx())
24 1argdelete
25 call assert_equal(1, argidx())
26 1argdelete
27 call assert_equal(0, argidx())
28 1argdelete
29 call assert_equal(0, argidx())
30endfunc
Bram Moolenaara24f0a52016-01-17 19:39:00 +010031
32func Test_argadd()
33 %argdelete
34 argadd a b c
35 call assert_equal(0, argidx())
36
37 %argdelete
38 argadd a
39 call assert_equal(0, argidx())
40 argadd b c d
41 call assert_equal(0, argidx())
42
43 call Init_abc()
44 argadd x
45 call Assert_argc(['a', 'b', 'x', 'c'])
46 call assert_equal(1, argidx())
47
48 call Init_abc()
49 0argadd x
50 call Assert_argc(['x', 'a', 'b', 'c'])
51 call assert_equal(2, argidx())
52
53 call Init_abc()
54 1argadd x
55 call Assert_argc(['a', 'x', 'b', 'c'])
56 call assert_equal(2, argidx())
57
58 call Init_abc()
59 $argadd x
60 call Assert_argc(['a', 'b', 'c', 'x'])
61 call assert_equal(1, argidx())
62
63 call Init_abc()
64 $argadd x
65 +2argadd y
66 call Assert_argc(['a', 'b', 'c', 'x', 'y'])
67 call assert_equal(1, argidx())
Bram Moolenaar2faa29f2016-01-23 23:02:34 +010068
69 %argd
70 edit d
71 arga
Bram Moolenaar398ee732017-08-03 14:29:14 +020072 call assert_equal(1, len(argv()))
73 call assert_equal('d', get(argv(), 0, ''))
74
75 %argd
76 edit some\ file
77 arga
78 call assert_equal(1, len(argv()))
79 call assert_equal('some file', get(argv(), 0, ''))
Bram Moolenaar2faa29f2016-01-23 23:02:34 +010080
81 %argd
82 new
83 arga
Bram Moolenaar398ee732017-08-03 14:29:14 +020084 call assert_equal(0, len(argv()))
Bram Moolenaara24f0a52016-01-17 19:39:00 +010085endfunc
86
Bram Moolenaar32bbd002018-08-31 23:06:22 +020087func Test_argadd_empty_curbuf()
88 new
89 let curbuf = bufnr('%')
90 call writefile(['test', 'Xargadd'], 'Xargadd')
91 " must not re-use the current buffer.
92 argadd Xargadd
93 call assert_equal(curbuf, bufnr('%'))
94 call assert_equal('', bufname('%'))
Bram Moolenaar02b31112019-08-31 22:16:38 +020095 call assert_equal(1, '$'->line())
Bram Moolenaar32bbd002018-08-31 23:06:22 +020096 rew
Bram Moolenaar073e4b92019-08-18 23:01:56 +020097 call assert_notequal(curbuf, '%'->bufnr())
98 call assert_equal('Xargadd', '%'->bufname())
Bram Moolenaar32bbd002018-08-31 23:06:22 +020099 call assert_equal(2, line('$'))
100
Bram Moolenaard3398282018-09-24 21:32:11 +0200101 call delete('Xargadd')
Bram Moolenaar32bbd002018-08-31 23:06:22 +0200102 %argd
103 bwipe!
104endfunc
105
Bram Moolenaara24f0a52016-01-17 19:39:00 +0100106func Init_abc()
107 args a b c
108 next
109endfunc
110
111func Assert_argc(l)
112 call assert_equal(len(a:l), argc())
113 let i = 0
114 while i < len(a:l) && i < argc()
115 call assert_equal(a:l[i], argv(i))
116 let i += 1
117 endwhile
118endfunc
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100119
120" Test for [count]argument and [count]argdelete commands
121" Ported from the test_argument_count.in test script
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100122func Test_argument()
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100123 " Clean the argument list
124 arga a | %argd
125
126 let save_hidden = &hidden
127 set hidden
128
129 let g:buffers = []
130 augroup TEST
131 au BufEnter * call add(buffers, expand('%:t'))
132 augroup END
133
134 argadd a b c d
135 $argu
136 $-argu
137 -argu
138 1argu
139 +2argu
140
141 augroup TEST
142 au!
143 augroup END
144
145 call assert_equal(['d', 'c', 'b', 'a', 'c'], g:buffers)
146
Bram Moolenaar949f1982019-07-23 23:00:08 +0200147 call assert_equal("\na b [c] d ", execute(':args'))
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100148
149 .argd
150 call assert_equal(['a', 'b', 'd'], argv())
151
152 -argd
153 call assert_equal(['a', 'd'], argv())
154
155 $argd
156 call assert_equal(['a'], argv())
157
158 1arga c
159 1arga b
160 $argu
161 $arga x
162 call assert_equal(['a', 'b', 'c', 'x'], argv())
163
Bram Moolenaar30141702016-01-19 14:14:08 +0100164 0arga y
165 call assert_equal(['y', 'a', 'b', 'c', 'x'], argv())
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100166
167 %argd
168 call assert_equal([], argv())
169
170 arga a b c d e f
171 2,$-argd
172 call assert_equal(['a', 'f'], argv())
173
174 let &hidden = save_hidden
175
Bram Moolenaar9800bfe2019-07-27 21:23:45 +0200176 let save_columns = &columns
177 let &columns = 79
Bram Moolenaar71478202020-06-26 22:46:27 +0200178 try
179 exe 'args ' .. join(range(1, 81))
180 call assert_equal(join([
181 \ '',
182 \ '[1] 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 ',
183 \ '2 7 12 17 22 27 32 37 42 47 52 57 62 67 72 77 ',
184 \ '3 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 ',
185 \ '4 9 14 19 24 29 34 39 44 49 54 59 64 69 74 79 ',
186 \ '5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 ',
187 \ ], "\n"),
188 \ execute('args'))
Bram Moolenaar9800bfe2019-07-27 21:23:45 +0200189
Bram Moolenaar71478202020-06-26 22:46:27 +0200190 " No trailing newline with one item per row.
191 let long_arg = repeat('X', 81)
192 exe 'args ' .. long_arg
193 call assert_equal("\n[".long_arg.']', execute('args'))
194 finally
195 let &columns = save_columns
196 endtry
Bram Moolenaar9800bfe2019-07-27 21:23:45 +0200197
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100198 " Setting argument list should fail when the current buffer has unsaved
199 " changes
200 %argd
201 enew!
202 set modified
203 call assert_fails('args x y z', 'E37:')
204 args! x y z
205 call assert_equal(['x', 'y', 'z'], argv())
206 call assert_equal('x', expand('%:t'))
207
208 last | enew | argu
209 call assert_equal('z', expand('%:t'))
210
211 %argdelete
212 call assert_fails('argument', 'E163:')
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100213endfunc
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100214
Bram Moolenaar5d69da42018-04-20 22:01:41 +0200215func Test_list_arguments()
216 " Clean the argument list
217 arga a | %argd
218
219 " four args half the screen width makes two lines with two columns
220 let aarg = repeat('a', &columns / 2 - 4)
221 let barg = repeat('b', &columns / 2 - 4)
222 let carg = repeat('c', &columns / 2 - 4)
223 let darg = repeat('d', &columns / 2 - 4)
224 exe 'argadd ' aarg barg carg darg
225
226 redir => result
227 args
228 redir END
229 call assert_match('\[' . aarg . '] \+' . carg . '\n' . barg . ' \+' . darg, trim(result))
230
231 " if one arg is longer than half the screen make one column
232 exe 'argdel' aarg
233 let aarg = repeat('a', &columns / 2 + 2)
234 exe '0argadd' aarg
235 redir => result
236 args
237 redir END
238 call assert_match(aarg . '\n\[' . barg . ']\n' . carg . '\n' . darg, trim(result))
239
240 %argdelete
241endfunc
242
Bram Moolenaar2ac372c2018-12-28 19:06:47 +0100243func Test_args_with_quote()
Bram Moolenaar3de8c2d2018-12-28 19:29:35 +0100244 " Only on Unix can a file name include a double quote.
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +0200245 CheckUnix
246
247 args \"foobar
248 call assert_equal('"foobar', argv(0))
249 %argdelete
Bram Moolenaar2ac372c2018-12-28 19:06:47 +0100250endfunc
251
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100252" Test for 0argadd and 0argedit
253" Ported from the test_argument_0count.in test script
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100254func Test_zero_argadd()
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100255 " Clean the argument list
256 arga a | %argd
257
258 arga a b c d
259 2argu
260 0arga added
261 call assert_equal(['added', 'a', 'b', 'c', 'd'], argv())
262
263 2argu
264 arga third
265 call assert_equal(['added', 'a', 'third', 'b', 'c', 'd'], argv())
266
267 %argd
268 arga a b c d
269 2argu
270 0arge edited
271 call assert_equal(['edited', 'a', 'b', 'c', 'd'], argv())
272
273 2argu
274 arga third
275 call assert_equal(['edited', 'a', 'third', 'b', 'c', 'd'], argv())
Bram Moolenaar90305c62017-07-16 15:31:17 +0200276
277 2argu
278 argedit file\ with\ spaces another file
279 call assert_equal(['edited', 'a', 'file with spaces', 'another', 'file', 'third', 'b', 'c', 'd'], argv())
280 call assert_equal('file with spaces', expand('%'))
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100281endfunc
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100282
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100283func Reset_arglist()
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100284 args a | %argd
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100285endfunc
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100286
287" Test for argc()
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100288func Test_argc()
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100289 call Reset_arglist()
290 call assert_equal(0, argc())
291 argadd a b
292 call assert_equal(2, argc())
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100293endfunc
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100294
295" Test for arglistid()
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100296func Test_arglistid()
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100297 call Reset_arglist()
298 arga a b
299 call assert_equal(0, arglistid())
300 split
301 arglocal
302 call assert_equal(1, arglistid())
303 tabnew | tabfirst
304 call assert_equal(0, arglistid(2))
305 call assert_equal(1, arglistid(1, 1))
306 call assert_equal(0, arglistid(2, 1))
307 call assert_equal(1, arglistid(1, 2))
308 tabonly | only | enew!
309 argglobal
310 call assert_equal(0, arglistid())
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100311endfunc
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100312
Bram Moolenaare6e39892018-10-25 12:32:11 +0200313" Tests for argv() and argc()
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100314func Test_argv()
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100315 call Reset_arglist()
316 call assert_equal([], argv())
317 call assert_equal("", argv(2))
Bram Moolenaare6e39892018-10-25 12:32:11 +0200318 call assert_equal(0, argc())
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100319 argadd a b c d
Bram Moolenaare6e39892018-10-25 12:32:11 +0200320 call assert_equal(4, argc())
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100321 call assert_equal('c', argv(2))
Bram Moolenaare6e39892018-10-25 12:32:11 +0200322
323 let w1_id = win_getid()
324 split
325 let w2_id = win_getid()
326 arglocal
327 args e f g
328 tabnew
329 let w3_id = win_getid()
330 split
331 let w4_id = win_getid()
332 argglobal
333 tabfirst
334 call assert_equal(4, argc(w1_id))
335 call assert_equal('b', argv(1, w1_id))
336 call assert_equal(['a', 'b', 'c', 'd'], argv(-1, w1_id))
337
338 call assert_equal(3, argc(w2_id))
339 call assert_equal('f', argv(1, w2_id))
340 call assert_equal(['e', 'f', 'g'], argv(-1, w2_id))
341
342 call assert_equal(3, argc(w3_id))
343 call assert_equal('e', argv(0, w3_id))
344 call assert_equal(['e', 'f', 'g'], argv(-1, w3_id))
345
346 call assert_equal(4, argc(w4_id))
347 call assert_equal('c', argv(2, w4_id))
348 call assert_equal(['a', 'b', 'c', 'd'], argv(-1, w4_id))
349
350 call assert_equal(4, argc(-1))
351 call assert_equal(3, argc())
352 call assert_equal('d', argv(3, -1))
353 call assert_equal(['a', 'b', 'c', 'd'], argv(-1, -1))
354 tabonly | only | enew!
355 " Negative test cases
356 call assert_equal(-1, argc(100))
357 call assert_equal('', argv(1, 100))
358 call assert_equal([], argv(-1, 100))
359 call assert_equal('', argv(10, -1))
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100360endfunc
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100361
362" Test for the :argedit command
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100363func Test_argedit()
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100364 call Reset_arglist()
365 argedit a
366 call assert_equal(['a'], argv())
367 call assert_equal('a', expand('%:t'))
368 argedit b
369 call assert_equal(['a', 'b'], argv())
370 call assert_equal('b', expand('%:t'))
371 argedit a
Bram Moolenaar90305c62017-07-16 15:31:17 +0200372 call assert_equal(['a', 'b', 'a'], argv())
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100373 call assert_equal('a', expand('%:t'))
Bram Moolenaar9b50bba2017-07-16 16:42:13 +0200374 " When file name case is ignored, an existing buffer with only case
Bram Moolenaarcf1ba352017-10-27 00:55:04 +0200375 " difference is re-used.
Bram Moolenaar90305c62017-07-16 15:31:17 +0200376 argedit C D
377 call assert_equal('C', expand('%:t'))
378 call assert_equal(['a', 'b', 'a', 'C', 'D'], argv())
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100379 argedit c
Bram Moolenaar9b50bba2017-07-16 16:42:13 +0200380 if has('fname_case')
381 call assert_equal(['a', 'b', 'a', 'C', 'c', 'D'], argv())
382 else
383 call assert_equal(['a', 'b', 'a', 'C', 'C', 'D'], argv())
384 endif
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100385 0argedit x
Bram Moolenaar9b50bba2017-07-16 16:42:13 +0200386 if has('fname_case')
387 call assert_equal(['x', 'a', 'b', 'a', 'C', 'c', 'D'], argv())
388 else
389 call assert_equal(['x', 'a', 'b', 'a', 'C', 'C', 'D'], argv())
390 endif
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100391 enew! | set modified
392 call assert_fails('argedit y', 'E37:')
393 argedit! y
Bram Moolenaar9b50bba2017-07-16 16:42:13 +0200394 if has('fname_case')
395 call assert_equal(['x', 'y', 'y', 'a', 'b', 'a', 'C', 'c', 'D'], argv())
396 else
397 call assert_equal(['x', 'y', 'y', 'a', 'b', 'a', 'C', 'C', 'D'], argv())
398 endif
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100399 %argd
Bram Moolenaar9b50bba2017-07-16 16:42:13 +0200400 bwipe! C
401 bwipe! D
Bram Moolenaar46a53df2018-04-24 21:58:51 +0200402
403 " :argedit reuses the current buffer if it is empty
404 %argd
405 " make sure to use a new buffer number for x when it is loaded
406 bw! x
407 new
Bram Moolenaara8eee212019-08-24 22:14:58 +0200408 let a = bufnr()
Bram Moolenaar46a53df2018-04-24 21:58:51 +0200409 argedit x
Bram Moolenaara8eee212019-08-24 22:14:58 +0200410 call assert_equal(a, bufnr())
411 call assert_equal('x', bufname())
Bram Moolenaar46a53df2018-04-24 21:58:51 +0200412 %argd
413 bw! x
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100414endfunc
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100415
416" Test for the :argdelete command
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100417func Test_argdelete()
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100418 call Reset_arglist()
419 args aa a aaa b bb
420 argdelete a*
421 call assert_equal(['b', 'bb'], argv())
422 call assert_equal('aa', expand('%:t'))
423 last
424 argdelete %
425 call assert_equal(['b'], argv())
Bram Moolenaar7b221172020-08-17 19:34:10 +0200426 call assert_fails('argdelete', 'E610:')
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100427 call assert_fails('1,100argdelete', 'E16:')
Bram Moolenaar7b221172020-08-17 19:34:10 +0200428
429 call Reset_arglist()
430 args a b c d
431 next
432 argdel
433 call Assert_argc(['a', 'c', 'd'])
434 %argdel
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100435endfunc
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100436
Bram Moolenaarb513d302018-12-02 14:55:08 +0100437func Test_argdelete_completion()
438 args foo bar
439
440 call feedkeys(":argdelete \<C-A>\<C-B>\"\<CR>", 'tx')
441 call assert_equal('"argdelete bar foo', @:)
442
443 call feedkeys(":argdelete x \<C-A>\<C-B>\"\<CR>", 'tx')
444 call assert_equal('"argdelete x bar foo', @:)
445
446 %argd
447endfunc
448
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100449" Tests for the :next, :prev, :first, :last, :rewind commands
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100450func Test_argpos()
Bram Moolenaar99dbe292016-01-19 13:07:23 +0100451 call Reset_arglist()
452 args a b c d
453 last
454 call assert_equal(3, argidx())
455 call assert_fails('next', 'E165:')
456 prev
457 call assert_equal(2, argidx())
458 Next
459 call assert_equal(1, argidx())
460 first
461 call assert_equal(0, argidx())
462 call assert_fails('prev', 'E164:')
463 3next
464 call assert_equal(3, argidx())
465 rewind
466 call assert_equal(0, argidx())
467 %argd
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100468endfunc
Bram Moolenaar53f16732016-09-07 20:46:39 +0200469
470" Test for autocommand that redefines the argument list, when doing ":all".
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100471func Test_arglist_autocmd()
Bram Moolenaar53f16732016-09-07 20:46:39 +0200472 autocmd BufReadPost Xxx2 next Xxx2 Xxx1
473 call writefile(['test file Xxx1'], 'Xxx1')
474 call writefile(['test file Xxx2'], 'Xxx2')
475 call writefile(['test file Xxx3'], 'Xxx3')
476
477 new
478 " redefine arglist; go to Xxx1
479 next! Xxx1 Xxx2 Xxx3
480 " open window for all args
481 all
482 call assert_equal('test file Xxx1', getline(1))
483 wincmd w
484 wincmd w
485 call assert_equal('test file Xxx1', getline(1))
486 " should now be in Xxx2
487 rewind
488 call assert_equal('test file Xxx2', getline(1))
489
490 autocmd! BufReadPost Xxx2
491 enew! | only
492 call delete('Xxx1')
493 call delete('Xxx2')
494 call delete('Xxx3')
495 argdelete Xxx*
496 bwipe! Xxx1 Xxx2 Xxx3
Bram Moolenaar8c34aa02017-03-16 22:52:32 +0100497endfunc
498
499func Test_arg_all_expand()
500 call writefile(['test file Xxx1'], 'Xx x')
501 next notexist Xx\ x runtest.vim
502 call assert_equal('notexist Xx\ x runtest.vim', expand('##'))
503 call delete('Xx x')
504endfunc
Bram Moolenaare961cba2018-09-18 21:51:47 +0200505
506func Test_large_arg()
507 " Argument longer or equal to the number of columns used to cause
508 " access to invalid memory.
509 exe 'argadd ' .repeat('x', &columns)
510 args
511endfunc
Bram Moolenaar72e1b392019-08-03 13:50:08 +0200512
513func Test_argdo()
514 next! Xa.c Xb.c Xc.c
515 new
516 let l = []
517 argdo call add(l, expand('%'))
518 call assert_equal(['Xa.c', 'Xb.c', 'Xc.c'], l)
519 bwipe Xa.c Xb.c Xc.c
520endfunc
Bram Moolenaar9f6277b2020-02-11 22:04:02 +0100521
522" Test for quiting Vim with unedited files in the argument list
523func Test_quit_with_arglist()
Bram Moolenaar494e9062020-05-31 21:28:02 +0200524 CheckRunVimInTerminal
Bram Moolenaar9f6277b2020-02-11 22:04:02 +0100525 let buf = RunVimInTerminal('', {'rows': 6})
Bram Moolenaar818fc9a2020-02-21 17:54:45 +0100526 call term_sendkeys(buf, ":set nomore\n")
Bram Moolenaar9f6277b2020-02-11 22:04:02 +0100527 call term_sendkeys(buf, ":args a b c\n")
528 call term_sendkeys(buf, ":quit\n")
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +0200529 call TermWait(buf)
Bram Moolenaar9f6277b2020-02-11 22:04:02 +0100530 call WaitForAssert({-> assert_match('^E173:', term_getline(buf, 6))})
531 call StopVimInTerminal(buf)
Bram Moolenaar406cd902020-02-18 21:54:41 +0100532
533 " Try :confirm quit with unedited files in arglist
534 let buf = RunVimInTerminal('', {'rows': 6})
535 call term_sendkeys(buf, ":set nomore\n")
536 call term_sendkeys(buf, ":args a b c\n")
537 call term_sendkeys(buf, ":confirm quit\n")
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +0200538 call TermWait(buf)
Bram Moolenaar406cd902020-02-18 21:54:41 +0100539 call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$',
540 \ term_getline(buf, 6))})
541 call term_sendkeys(buf, "N")
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +0200542 call TermWait(buf)
Bram Moolenaar406cd902020-02-18 21:54:41 +0100543 call term_sendkeys(buf, ":confirm quit\n")
544 call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$',
545 \ term_getline(buf, 6))})
546 call term_sendkeys(buf, "Y")
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +0200547 call TermWait(buf)
Bram Moolenaar818fc9a2020-02-21 17:54:45 +0100548 call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))})
549 only!
Bram Moolenaar1671f442020-03-10 07:48:13 +0100550 " When this test fails, swap files are left behind which breaks subsequent
551 " tests
552 call delete('.a.swp')
553 call delete('.b.swp')
554 call delete('.c.swp')
Bram Moolenaar9f6277b2020-02-11 22:04:02 +0100555endfunc
556
557" vim: shiftwidth=2 sts=2 expandtab