# HG changeset patch # User Bram Moolenaar # Date 1583179204 -3600 # Node ID 848dc460adf0d1fd9b6d5b8b90c4194ef1ced939 # Parent e84b346be7f2a8ba0461a80b7b84529e4caaa5cc patch 8.2.0347: various code not covered by tests Commit: https://github.com/vim/vim/commit/91ffc8a5f5c7b1c6979b3352a12ed779d11173a9 Author: Bram Moolenaar Date: Mon Mar 2 20:54:22 2020 +0100 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 https://github.com/vim/vim/issues/5720) diff --git a/src/testdir/gen_opt_test.vim b/src/testdir/gen_opt_test.vim --- a/src/testdir/gen_opt_test.vim +++ b/src/testdir/gen_opt_test.vim @@ -150,7 +150,7 @@ let test_values = { \ 'viminfo': [['', '''50', '"30'], ['xxx']], \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']], \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']], - \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx']], + \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx', 'a4', 'full,full,full,full,full']], \ 'wildoptions': [['', 'tagfile'], ['xxx']], \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']], \ diff --git a/src/testdir/test86.in b/src/testdir/test86.in --- a/src/testdir/test86.in +++ b/src/testdir/test86.in @@ -1156,7 +1156,7 @@ EOF :$put =string(pyeval('dd') is# pyeval('dd')) :$put =string(pyeval('df')) :delfunction Put -py << EOF +py << del DupDict del DupList del DupFun @@ -1164,7 +1164,7 @@ del dd del dl del dl2 del df -EOF +. :" :" Test chdir py << EOF diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -477,12 +477,22 @@ func Test_cmdline_paste() call feedkeys(":\"one\\two\", 'xt') call assert_equal('"onetwo', @:) + " Test for pasting register containing CTRL-H using CTRL-R and CTRL-R CTRL-R let @a = "xy\z" call feedkeys(":\"\a\", 'xt') call assert_equal('"xz', @:) + call feedkeys(":\"\\a\", 'xt') + call assert_equal("\"xy\z", @:) call feedkeys(":\"\\a\", 'xt') call assert_equal("\"xy\z", @:) + " Test for pasting register containing CTRL-V using CTRL-R and CTRL-R CTRL-R + let @a = "xy\z" + call feedkeys(":\"\=@a\\", 'xt') + call assert_equal('"xyz', @:) + call feedkeys(":\"\\=@a\\", 'xt') + call assert_equal("\"xy\z", @:) + call assert_beeps('call feedkeys(":\=\=\", "xt")') bwipe! @@ -1188,7 +1198,7 @@ endfunc func Test_cmdline_edit() let str = ":one two\" let str ..= "one two\\" - let str ..= "one\\\" + let str ..= "four\\\\" let str ..= "\five\" let str ..= "\two " let str ..= "\one " @@ -1207,7 +1217,7 @@ func Test_cmdline_edit_rightleft() set rightleftcmd=search let str = "/one two\" let str ..= "one two\\" - let str ..= "one\\\" + let str ..= "four\\\\" let str ..= "\five\" let str ..= "\two " let str ..= "\one " @@ -1268,4 +1278,42 @@ 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:\", "xt")') + only +endfunc + +" Test for recursively getting multiple command line inputs +func Test_cmdwin_multi_input() + call feedkeys(":\=input('P: ')\\"cyan\\", '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\\", 'xt') + call assert_equal("\"abc\", @:) + set allowrevins + call feedkeys(":\"abc\xyz\\", '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(":\"\u3046\u3099\", 'xt') + call assert_equal('"ゔ', @:) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim --- a/src/testdir/test_digraph.vim +++ b/src/testdir/test_digraph.vim @@ -451,10 +451,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.='\Eu'\" - call assert_equal("€", s) + call feedkeys(":\"\Eu\", 'xt') + call assert_equal('"€', @:) + + " Canceling a CTRL-K on the cmdline + call feedkeys(":\"a\\b\", 'xt') + call assert_equal('"ab', @:) endfunc func Test_show_digraph() diff --git a/src/testdir/test_ex_mode.vim b/src/testdir/test_ex_mode.vim --- a/src/testdir/test_ex_mode.vim +++ b/src/testdir/test_ex_mode.vim @@ -50,7 +50,11 @@ func Test_ex_mode() call assert_equal(['foo', ' foo0'], Ex(" foo0\"), e) call assert_equal(['foo', ' foo^'], Ex(" foo^\"), e) call assert_equal(['foo', 'foo'], - \ Ex("\\\foo"), e) + \ Ex("\\\\foo"), e) + " default wildchar interferes with this test + set wildchar= + call assert_equal(["a\tb", "a\tb"], Ex("a\t\t\b"), e) + set wildchar& endfor set sw& @@ -139,4 +143,18 @@ func Test_Ex_append() close! endfunc +" In Ex-mode, backslashes at the end of a command should be halved. +func Test_Ex_echo_backslash() + " 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 + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_history.vim b/src/testdir/test_history.vim --- a/src/testdir/test_history.vim +++ b/src/testdir/test_history.vim @@ -176,12 +176,52 @@ func Test_history_search() cunmap delfunc SavePat + " Search for a pattern that is not present in the history + call assert_beeps('call feedkeys("/a1b2\\", "xt")') + " Recall patterns with 'history' set to 0 set history=0 let @/ = 'abc' let cmd = 'call feedkeys("/\\\\\", "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("/\\\\\", "xt")') + call assert_beeps('call feedkeys("/\", "xt")') + + " Test for wrapping around the history list + for i in range(3, 7) + call histadd('/', 'pat' .. i) + endfor + let upcmd = "\\\\\" + let downcmd = "\\\\\" + try + call feedkeys("/" .. upcmd .. "\", 'xt') + catch /E486:/ + endtry + call assert_equal('pat4', @/) + try + call feedkeys("/" .. upcmd .. downcmd .. "\", 'xt') + catch /E486:/ + endtry + call assert_equal('pat4', @/) + + " Test for changing the search command separator in the history + call assert_fails('call feedkeys("/def/\", "xt")', 'E486:') + call assert_fails('call feedkeys("?\\", "xt")', 'E486:') + call assert_equal('def?', histget('/', -1)) + + call assert_fails('call feedkeys("/ghi?\", "xt")', 'E486:') + call assert_fails('call feedkeys("?\\", "xt")', 'E486:') + call assert_equal('ghi\?', histget('/', -1)) + + set history& endfunc " Test for making sure the key value is not stored in history diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 347, +/**/ 346, /**/ 345,