From 26b54d5c169d7d4afeb5433355b29eee78c12add Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 17 Sep 2022 09:40:19 +0800 Subject: test(old): add a function roughly equivalent to test_setmouse() (#20224) Mouse movement events usually have no effect, so passing "move" to nvim_input_mouse() works in most cases. --- src/nvim/testdir/test_mapping.vim | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/nvim/testdir/test_mapping.vim') diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index e1d0b9a9ba..72c84b5356 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -1006,15 +1006,14 @@ func Test_plug_remap() endfunc func Test_mouse_drag_mapped_start_select() - CheckFunction test_setmouse set mouse=a set selectmode=key,mouse func ClickExpr() - call test_setmouse(1, 1) + call Ntest_setmouse(1, 1) return "\" endfunc func DragExpr() - call test_setmouse(1, 2) + call Ntest_setmouse(1, 2) return "\" endfunc nnoremap ClickExpr() @@ -1036,14 +1035,13 @@ endfunc " Test for mapping in Insert mode func Test_mouse_drag_insert_map() - CheckFunction test_setmouse set mouse=a func ClickExpr() - call test_setmouse(1, 1) + call Ntest_setmouse(1, 1) return "\" endfunc func DragExpr() - call test_setmouse(1, 2) + call Ntest_setmouse(1, 2) return "\" endfunc inoremap ClickExpr() -- cgit From 37a71d1f28e5d7fd13f0ede69b4d2558157a9e4b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 21 Sep 2022 11:06:39 +0800 Subject: vim-patch:9.0.0018: going over the end of the typahead (#20269) Problem: Going over the end of the typahead. Solution: Put a NUL after the typeahead. https://github.com/vim/vim/commit/27efc62f5d86afcb2ecb7565587fe8dea4b036fe check_termcode() is N/A. --- src/nvim/testdir/test_mapping.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/testdir/test_mapping.vim') diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 72c84b5356..d7bd53e421 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -1127,4 +1127,14 @@ func Test_map_after_timed_out_nop() call delete('Xtest_map_after_timed_out_nop') endfunc +func Test_using_past_typeahead() + nnoremap :00 0 + exe "norm :set \x80\xfb0=0\" + exe "sil norm :0\x0f\\" + + exe "norm :set \x80\xfb0=\" + nunmap :00 +endfunc + + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 88099c11223398b2e7eb96eaa9385d24046db994 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 22 Sep 2022 11:17:41 +0800 Subject: vim-patch:8.2.2994: various code is not fully tested Problem: Various code is not fully tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#8378) https://github.com/vim/vim/commit/2d6d718dde7163c971d37b8f4f1ed8f2d25de130 Nvim does not support encoding=latin1 or compatible mode. The two paste tests are applicable. --- src/nvim/testdir/test_mapping.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/nvim/testdir/test_mapping.vim') diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index d7bd53e421..bde3624adf 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -975,6 +975,21 @@ func Test_abbreviate_multi_byte() bwipe! endfunc +" Test for abbreviations with 'latin1' encoding +func Test_abbreviate_latin1_encoding() + " set encoding=latin1 + call assert_fails('abbr ab#$c ABC', 'E474:') + new + iabbr #i #include + iabbr ## #enddef + exe "normal i#i\" + call assert_equal('#include', getline(1)) + exe "normal 0Di##\" + call assert_equal('#enddef', getline(1)) + %bw! + set encoding=utf-8 +endfunc ++ " Test for always being mapped, even when used with "noremap". func Test_plug_remap() let g:foo = 0 -- cgit From 157baef02636fed4a99ef401e470fee8c51ce852 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Oct 2022 21:53:11 +0800 Subject: vim-patch:8.1.1826: tests use hand coded feature and option checks Problem: Tests use hand coded feature and option checks. Solution: Use the commands from check.vim in more tests. https://github.com/vim/vim/commit/8c5a278fc508da6dfe50e69b6ee734451aa4eafb Omit Test_wincolor(): there are later patches that touch that function. Omit test_memory_usage.vim: a Lua test is used for that file. Cherry-pick Test_issue_3969() from patch 8.1.0969. Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_mapping.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_mapping.vim') diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index bde3624adf..2d8c45210b 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -395,7 +395,9 @@ func Test_motionforce_omap() endfunc func Test_error_in_map_expr() - if !has('terminal') || (has('win32') && has('gui_running')) + " Unlike CheckRunVimInTerminal this does work in a win32 console + CheckFeature terminal + if has('win32') && has('gui_running') throw 'Skipped: cannot run Vim in a terminal window' endif -- cgit From a600e73007a2cc9ced7eeaeb5f8c05ac454d080e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 1 Nov 2022 07:13:02 +0800 Subject: vim-patch:9.0.0822: crash when dragging the statusline with a mapping Problem: Crash when dragging the statusline with a mapping. Solution: Check for valid window pointer. (issue vim/vim#11427) https://github.com/vim/vim/commit/8ab9ca93eea32b318235384720200771863ecaee Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_mapping.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/nvim/testdir/test_mapping.vim') diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 2d8c45210b..a286774d56 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -1050,6 +1050,24 @@ func Test_mouse_drag_mapped_start_select() set mouse& endfunc +func Test_mouse_drag_statusline() + set laststatus=2 + set mouse=a + func ClickExpr() + call Ntest_setmouse(&lines - 1, 1) + return "\" + endfunc + func DragExpr() + call Ntest_setmouse(&lines - 2, 1) + return "\" + endfunc + nnoremap ClickExpr() + nnoremap DragExpr() + + " this was causing a crash in win_drag_status_line() + call feedkeys("\:tabnew\\", 'tx') +endfunc + " Test for mapping in Insert mode func Test_mouse_drag_insert_map() set mouse=a -- cgit From 39f85cdf6b40cbdd26256260d0d6d4e071b631a2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 1 Nov 2022 20:22:48 +0800 Subject: vim-patch:9.0.0824: crash when using win_move_separator() in other tab page Problem: Crash when using win_move_separator() in other tab page. Solution: Check for valid window in current tab page. (closes vim/vim#11479, closes vim/vim#11427) https://github.com/vim/vim/commit/873f41a0187e81a22aa4622fbf938de72a54abba --- src/nvim/testdir/test_mapping.vim | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/nvim/testdir/test_mapping.vim') diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index a286774d56..560883ba5d 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -1054,18 +1054,24 @@ func Test_mouse_drag_statusline() set laststatus=2 set mouse=a func ClickExpr() - call Ntest_setmouse(&lines - 1, 1) - return "\" + call Ntest_setmouse(&lines - 1, 1) + return "\" endfunc func DragExpr() - call Ntest_setmouse(&lines - 2, 1) - return "\" + call Ntest_setmouse(&lines - 2, 1) + return "\" endfunc nnoremap ClickExpr() nnoremap DragExpr() " this was causing a crash in win_drag_status_line() call feedkeys("\:tabnew\\", 'tx') + + nunmap + nunmap + delfunc ClickExpr + delfunc DragExpr + set laststatus& mouse& endfunc " Test for mapping in Insert mode -- cgit From 0d8e8d36ec7d3f4967f27389b4b94edf3ba57433 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 11 Nov 2022 17:50:52 +0800 Subject: vim-patch:8.2.1919: assert_fails() setting emsg_silent changes normal execution (#20998) Problem: Assert_fails() setting emsg_silent changes normal execution. Solution: Use a separate flag in_assert_fails. https://github.com/vim/vim/commit/28ee892ac4197421b3317f195512ca64cc56a5b4 Cherry-pick no_wait_return from patch 9.0.0846. Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_mapping.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_mapping.vim') diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 560883ba5d..522a51589f 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -779,7 +779,7 @@ func Test_expr_abbr() " invalid abbreviation abbr hte GetAbbr() call assert_fails('normal ihte ', 'E117:') - call assert_equal(' ', getline(1)) + call assert_equal('', getline(1)) unabbr hte close! -- cgit From 9be24110f68abc111c87c88d82f50f64a1d3ecdd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 24 Dec 2022 16:32:50 +0800 Subject: vim-patch:8.2.4139: using freed memory in expression abbreviation (#21522) Problem: Using freed memory if an expression abbreviation deletes the abbreviation. Solution: Do not access the pointer after evaluating the expression. https://github.com/vim/vim/commit/94075b2b0e8e3b75334799d2c082497fbf85ffa1 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_mapping.vim | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_mapping.vim') diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 522a51589f..5c5a65d4ca 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -767,6 +767,11 @@ func Test_mapcomplete() mapclear endfunc +func GetAbbrText() + unabbr hola + return 'hello' +endfunc + " Test for in abbreviation func Test_expr_abbr() new @@ -782,7 +787,14 @@ func Test_expr_abbr() call assert_equal('', getline(1)) unabbr hte - close! + " evaluating the expression deletes the abbreviation + abbr hola GetAbbrText() + call assert_equal('GetAbbrText()', maparg('hola', 'i', '1')) + call feedkeys("ahola \", 'xt') + call assert_equal('hello ', getline('.')) + call assert_equal('', maparg('hola', 'i', '1')) + + bwipe! endfunc " Test for storing mappings in different modes in a vimrc file -- cgit