0
0
mirror of https://github.com/vim/vim.git synced 2025-10-04 05:25:06 -04:00

patch 8.2.0316: ex_getln.c code has insufficient test coverage

Problem:    ex_getln.c code has insufficient test coverage.
Solution:   Add more tests. Fix a problem. (Yegappan Lakshmanan, closes #5693)
This commit is contained in:
Bram Moolenaar
2020-02-25 21:47:45 +01:00
parent c593bec412
commit 8d588ccee5
6 changed files with 163 additions and 1 deletions

View File

@@ -1141,6 +1141,30 @@ func Test_col()
bw!
endfunc
" Test for input()
func Test_input_func()
" Test for prompt with multiple lines
redir => v
call feedkeys(":let c = input(\"A\\nB\\nC\\n? \")\<CR>B\<CR>", 'xt')
redir END
call assert_equal("B", c)
call assert_equal(['A', 'B', 'C'], split(v, "\n"))
" Test for default value
call feedkeys(":let c = input('color? ', 'red')\<CR>\<CR>", 'xt')
call assert_equal('red', c)
" Test for completion at the input prompt
func! Tcomplete(arglead, cmdline, pos)
return "item1\nitem2\nitem3"
endfunc
call feedkeys(":let c = input('Q? ', '' , 'custom,Tcomplete')\<CR>"
\ .. "\<C-A>\<CR>", 'xt')
delfunc Tcomplete
call assert_equal('item1 item2 item3', c)
endfunc
" Test for inputlist()
func Test_inputlist()
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<cr>", 'tx')
call assert_equal(1, c)
@@ -2034,3 +2058,5 @@ func Test_echoraw()
call StopVimInTerminal(buf)
call delete('XTest_echoraw')
endfunc
" vim: shiftwidth=2 sts=2 expandtab