diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-07-13 21:21:14 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-07-14 15:40:07 +0800 |
commit | bf96b9f11d1f960006a1b5d5d363bbf804fe84e9 (patch) | |
tree | 3652580ef991d68512e48a93017f29a413af93a9 | |
parent | c467df997eadc077003ff27908c0782b27ff6b97 (diff) | |
download | rneovim-bf96b9f11d1f960006a1b5d5d363bbf804fe84e9.tar.gz rneovim-bf96b9f11d1f960006a1b5d5d363bbf804fe84e9.tar.bz2 rneovim-bf96b9f11d1f960006a1b5d5d363bbf804fe84e9.zip |
vim-patch:8.2.0347: various code not covered by tests
Problem: Various code not covered by tests.
Solution: Add more test coverage. (Yegappan Lakshmanan, closes vim/vim#5720)
https://github.com/vim/vim/commit/91ffc8a5f5c7b1c6979b3352a12ed779d11173a9
Test_Ex_echo_backslash() is not applicable to Vim enhanced Ex mode.
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 52 | ||||
-rw-r--r-- | src/nvim/testdir/test_digraph.vim | 10 | ||||
-rw-r--r-- | src/nvim/testdir/test_ex_mode.vim | 15 | ||||
-rw-r--r-- | src/nvim/testdir/test_history.vim | 40 |
4 files changed, 111 insertions, 6 deletions
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index b5ee5e802d..02f08ab20f 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -603,12 +603,22 @@ func Test_cmdline_paste() call feedkeys(":\"one\<C-R>\<C-X>two\<CR>", 'xt') call assert_equal('"onetwo', @:) + " Test for pasting register containing CTRL-H using CTRL-R and CTRL-R CTRL-R let @a = "xy\<C-H>z" call feedkeys(":\"\<C-R>a\<CR>", 'xt') call assert_equal('"xz', @:) + call feedkeys(":\"\<C-R>\<C-R>a\<CR>", 'xt') + call assert_equal("\"xy\<C-H>z", @:) call feedkeys(":\"\<C-R>\<C-O>a\<CR>", 'xt') call assert_equal("\"xy\<C-H>z", @:) + " Test for pasting register containing CTRL-V using CTRL-R and CTRL-R CTRL-R + let @a = "xy\<C-V>z" + call feedkeys(":\"\<C-R>=@a\<CR>\<cr>", 'xt') + call assert_equal('"xyz', @:) + call feedkeys(":\"\<C-R>\<C-R>=@a\<CR>\<cr>", 'xt') + call assert_equal("\"xy\<C-V>z", @:) + call assert_beeps('call feedkeys(":\<C-R>=\<C-R>=\<Esc>", "xt")') bwipe! @@ -1558,7 +1568,7 @@ endfunc func Test_cmdline_edit() let str = ":one two\<C-U>" let str ..= "one two\<C-W>\<C-W>" - let str ..= "one\<BS>\<C-H>\<Del>" + let str ..= "four\<BS>\<C-H>\<Del>\<kDel>" let str ..= "\<Left>five\<Right>" let str ..= "\<Home>two " let str ..= "\<C-Left>one " @@ -1577,7 +1587,7 @@ func Test_cmdline_edit_rightleft() set rightleftcmd=search let str = "/one two\<C-U>" let str ..= "one two\<C-W>\<C-W>" - let str ..= "one\<BS>\<C-H>\<Del>" + let str ..= "four\<BS>\<C-H>\<Del>\<kDel>" let str ..= "\<Right>five\<Left>" let str ..= "\<Home>two " let str ..= "\<C-Right>one " @@ -1638,6 +1648,44 @@ func Test_cmdline_inputmethod() %bwipe! endfunc +" Test for opening the command-line window when too many windows are present +func Test_cmdwin_fail_to_open() + " Open as many windows as possible + for i in range(100) + try + new + catch /E36:/ + break + endtry + endfor + call assert_beeps('call feedkeys("q:\<CR>", "xt")') + only +endfunc + +" Test for recursively getting multiple command line inputs +func Test_cmdwin_multi_input() + call feedkeys(":\<C-R>=input('P: ')\<CR>\"cyan\<CR>\<CR>", 'xt') + call assert_equal('"cyan', @:) +endfunc + +" Test for using CTRL-_ in the command line with 'allowrevins' +func Test_cmdline_revins() + CheckNotMSWindows + CheckFeature rightleft + call feedkeys(":\"abc\<c-_>\<cr>", 'xt') + call assert_equal("\"abc\<c-_>", @:) + set allowrevins + call feedkeys(":\"abc\<c-_>xyz\<c-_>\<CR>", 'xt') + call assert_equal('"abcñèæ', @:) + set allowrevins& +endfunc + +" Test for typing UTF-8 composing characters in the command line +func Test_cmdline_composing_chars() + call feedkeys(":\"\<C-V>u3046\<C-V>u3099\<CR>", 'xt') + call assert_equal('"ゔ', @:) +endfunc + " Test for normal mode commands not supported in the cmd window func Test_cmdwin_blocked_commands() call assert_fails('call feedkeys("q:\<C-T>\<CR>", "xt")', 'E11:') diff --git a/src/nvim/testdir/test_digraph.vim b/src/nvim/testdir/test_digraph.vim index 7b6bc940d3..acc34e5e7c 100644 --- a/src/nvim/testdir/test_digraph.vim +++ b/src/nvim/testdir/test_digraph.vim @@ -466,10 +466,12 @@ endfunc func Test_digraph_cmndline() " Create digraph on commandline - " This is a hack, to let Vim create the digraph in commandline mode - let s = '' - exe "sil! norm! :let s.='\<c-k>Eu'\<cr>" - call assert_equal("€", s) + call feedkeys(":\"\<c-k>Eu\<cr>", 'xt') + call assert_equal('"€', @:) + + " Canceling a CTRL-K on the cmdline + call feedkeys(":\"a\<c-k>\<esc>b\<cr>", 'xt') + call assert_equal('"ab', @:) endfunc func Test_show_digraph() diff --git a/src/nvim/testdir/test_ex_mode.vim b/src/nvim/testdir/test_ex_mode.vim index 8a8203b40b..b478332c79 100644 --- a/src/nvim/testdir/test_ex_mode.vim +++ b/src/nvim/testdir/test_ex_mode.vim @@ -151,6 +151,21 @@ func Test_Ex_append() close! endfunc +" In Ex-mode, backslashes at the end of a command should be halved. +func Test_Ex_echo_backslash() + throw 'Skipped: Nvim only supports Vim Ex mode' + " This test works only when the language is English + if v:lang != "C" && v:lang !~ '^[Ee]n' + return + endif + let bsl = '\\\\' + let bsl2 = '\\\' + call assert_fails('call feedkeys("Qecho " .. bsl .. "\nvisual\n", "xt")', + \ "E15: Invalid expression: \\\\") + call assert_fails('call feedkeys("Qecho " .. bsl2 .. "\nm\nvisual\n", "xt")', + \ "E15: Invalid expression: \\\nm") +endfunc + func Test_ex_mode_errors() " Not allowed to enter ex mode when text is locked au InsertCharPre <buffer> normal! gQ<CR> diff --git a/src/nvim/testdir/test_history.vim b/src/nvim/testdir/test_history.vim index 0312b5f579..feb521e232 100644 --- a/src/nvim/testdir/test_history.vim +++ b/src/nvim/testdir/test_history.vim @@ -176,12 +176,52 @@ func Test_history_search() cunmap <F2> delfunc SavePat + " Search for a pattern that is not present in the history + call assert_beeps('call feedkeys("/a1b2\<Up>\<CR>", "xt")') + " Recall patterns with 'history' set to 0 set history=0 let @/ = 'abc' let cmd = 'call feedkeys("/\<Up>\<Down>\<S-Up>\<S-Down>\<CR>", "xt")' call assert_fails(cmd, 'E486:') set history& + + " Recall patterns till the end of history + set history=4 + call histadd('/', 'pat') + call histdel('/') + call histadd('/', 'pat1') + call histadd('/', 'pat2') + call assert_beeps('call feedkeys("/\<Up>\<Up>\<Up>\<C-U>\<cr>", "xt")') + call assert_beeps('call feedkeys("/\<Down><cr>", "xt")') + + " Test for wrapping around the history list + for i in range(3, 7) + call histadd('/', 'pat' .. i) + endfor + let upcmd = "\<up>\<up>\<up>\<up>\<up>" + let downcmd = "\<down>\<down>\<down>\<down>\<down>" + try + call feedkeys("/" .. upcmd .. "\<cr>", 'xt') + catch /E486:/ + endtry + call assert_equal('pat4', @/) + try + call feedkeys("/" .. upcmd .. downcmd .. "\<cr>", 'xt') + catch /E486:/ + endtry + call assert_equal('pat4', @/) + + " Test for changing the search command separator in the history + call assert_fails('call feedkeys("/def/\<cr>", "xt")', 'E486:') + call assert_fails('call feedkeys("?\<up>\<cr>", "xt")', 'E486:') + call assert_equal('def?', histget('/', -1)) + + call assert_fails('call feedkeys("/ghi?\<cr>", "xt")', 'E486:') + call assert_fails('call feedkeys("?\<up>\<cr>", "xt")', 'E486:') + call assert_equal('ghi\?', histget('/', -1)) + + set history& endfunc " Test for making sure the key value is not stored in history |