From 2e790e9ad10bca3a64b20be75672a3c6a6f3d97c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 19 Jul 2022 20:55:13 +0800 Subject: vim-patch:8.2.0509: various code is not properly tested. Problem: various code is not properly tested. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#5871) https://github.com/vim/vim/commit/cde0ff39da2459b16007fef701ebaa449fb6fe9d Cherry-pick test_clientserver.vim change from patch 8.1.1826. Cherry-pick a comment from patch 8.2.0301. Omit test_viminfo.vim. --- src/nvim/testdir/test_functions.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/nvim/testdir/test_functions.vim') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 9b8d740efb..c11e7b4fea 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -547,6 +547,7 @@ func Save_mode() return '' endfunc +" Test for the mode() function func Test_mode() new call append(0, ["Blue Ball Black", "Brown Band Bowl", ""]) @@ -717,6 +718,8 @@ func Test_mode() call assert_equal('c-c', g:current_modes) call feedkeys("gQecho \=Save_mode()\\vi\", 'xt') call assert_equal('c-cv', g:current_modes) + " call feedkeys("Qcall Save_mode()\vi\", 'xt') + " call assert_equal('c-ce', g:current_modes) " How to test Ex mode? " Test mode in operatorfunc (it used to be Operator-pending). @@ -1262,6 +1265,23 @@ func Test_inputlist() call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\5q", 'tx') call assert_equal(0, c) + " Use backspace to delete characters in the prompt + call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\1\3\2\", 'tx') + call assert_equal(2, c) + + " Use mouse to make a selection + " call test_setmouse(&lines - 3, 2) + call nvim_input_mouse('left', 'press', '', 0, &lines - 4, 1) " set mouse position + call getchar() " discard mouse event but keep mouse position + call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\\", 'tx') + call assert_equal(1, c) + " Mouse click outside of the list + " call test_setmouse(&lines - 6, 2) + call nvim_input_mouse('left', 'press', '', 0, &lines - 7, 1) " set mouse position + call getchar() " discard mouse event but keep mouse position + call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\\", 'tx') + call assert_equal(-2, c) + call assert_fails('call inputlist("")', 'E686:') endfunc -- cgit