Mercurial > vim
diff src/testdir/test_functions.vim @ 19517:738a4fe2c8c5 v8.2.0316
patch 8.2.0316: ex_getln.c code has insufficient test coverage
Commit: https://github.com/vim/vim/commit/8d588ccee57390aa01c2395fc599bbe6506ee13a
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 25 21:47:45 2020 +0100
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 https://github.com/vim/vim/issues/5693)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 25 Feb 2020 22:00:04 +0100 |
parents | bd9069d21c5d |
children | bab20768e1fd |
line wrap: on
line diff
--- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -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