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)
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index c748854..607e714 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1141,6 +1141,30 @@
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 @@
call StopVimInTerminal(buf)
call delete('XTest_echoraw')
endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab