]> granicus.if.org Git - vim/commitdiff
patch 8.2.0342: some code in ex_getln.c not covered by tests v8.2.0342
authorBram Moolenaar <Bram@vim.org>
Sun, 1 Mar 2020 15:53:09 +0000 (16:53 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 1 Mar 2020 15:53:09 +0000 (16:53 +0100)
Problem:    Some code in ex_getln.c not covered by tests.
Solution:   Add more tests. (Yegappan Lakshmanan, closes #5717)

src/testdir/test_cmdline.vim
src/testdir/test_ex_mode.vim
src/testdir/test_history.vim
src/testdir/test_iminsert.vim
src/version.c

index 8c580262ac7ae94156a8c3bb28ab7a3310962968..c32a3f03eb46f31831fc695d412359993862524f 100644 (file)
@@ -1188,6 +1188,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 ..= "\<Left>five\<Right>"
   let str ..= "\<Home>two "
   let str ..= "\<C-Left>one "
@@ -1206,6 +1207,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 ..= "\<Right>five\<Left>"
   let str ..= "\<Home>two "
   let str ..= "\<C-Right>one "
@@ -1233,4 +1235,37 @@ func Test_cmdline_expr()
   call assert_equal("\"e \<C-\>\<C-Y>", @:)
 endfunc
 
+" Test for 'imcmdline' and 'imsearch'
+" This test doesn't actually test the input method functionality.
+func Test_cmdline_inputmethod()
+  new
+  call setline(1, ['', 'abc', ''])
+  set imcmdline
+
+  call feedkeys(":\"abc\<CR>", 'xt')
+  call assert_equal("\"abc", @:)
+  call feedkeys(":\"\<C-^>abc\<C-^>\<CR>", 'xt')
+  call assert_equal("\"abc", @:)
+  call feedkeys("/abc\<CR>", 'xt')
+  call assert_equal([2, 1], [line('.'), col('.')])
+  call feedkeys("/\<C-^>abc\<C-^>\<CR>", 'xt')
+  call assert_equal([2, 1], [line('.'), col('.')])
+
+  set imsearch=2
+  call cursor(1, 1)
+  call feedkeys("/abc\<CR>", 'xt')
+  call assert_equal([2, 1], [line('.'), col('.')])
+  call cursor(1, 1)
+  call feedkeys("/\<C-^>abc\<C-^>\<CR>", 'xt')
+  call assert_equal([2, 1], [line('.'), col('.')])
+  set imdisable
+  call feedkeys("/\<C-^>abc\<C-^>\<CR>", 'xt')
+  call assert_equal([2, 1], [line('.'), col('.')])
+  set imdisable&
+  set imsearch&
+
+  set imcmdline&
+  %bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 91ba012e15866b88ceff775e78ab261881825491..e88bdf5302764f9db77fa098c27d579e0a4e308b 100644 (file)
@@ -49,6 +49,8 @@ func Test_ex_mode()
     call assert_equal(['  foo', '    foo'],       Ex("    foo\<C-d>"), e)
     call assert_equal(['foo', '    foo0'],        Ex("    foo0\<C-d>"), e)
     call assert_equal(['foo', '    foo^'],        Ex("    foo^\<C-d>"), e)
+    call assert_equal(['foo', 'foo'],
+          \ Ex("\<BS>\<C-H>\<Del>foo"), e)
   endfor
 
   set sw&
@@ -128,4 +130,13 @@ func Test_Ex_escape_enter()
   call assert_equal("a\rb", l)
 endfunc
 
+" Test for :append! command in Ex mode
+func Test_Ex_append()
+  new
+  call setline(1, "\t   abc")
+  call feedkeys("Qappend!\npqr\nxyz\n.\nvisual\n", 'xt')
+  call assert_equal(["\t   abc", "\t   pqr", "\t   xyz"], getline(1, '$'))
+  close!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 96006ac7e797117b5d14a65613c1424ef8d9ddce..0312b5f579eb90c9d13810b159cb9560414f0756 100644 (file)
@@ -114,6 +114,7 @@ function Test_Search_history_window()
   bwipe!
 endfunc
 
+" Test for :history command option completion
 function Test_history_completion()
   call feedkeys(":history \<C-A>\<C-B>\"\<CR>", 'tx')
   call assert_equal('"history / : = > ? @ all cmd debug expr input search', @:)
@@ -122,8 +123,9 @@ endfunc
 " Test for increasing the 'history' option value
 func Test_history_size()
   let save_histsz = &history
-  call histdel(':')
   set history=10
+  call histadd(':', 'ls')
+  call histdel(':')
   for i in range(1, 5)
     call histadd(':', 'cmd' .. i)
   endfor
@@ -173,6 +175,13 @@ func Test_history_search()
   call assert_equal(['pat2', 'pat1', ''], g:pat)
   cunmap <F2>
   delfunc SavePat
+
+  " 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&
 endfunc
 
 " Test for making sure the key value is not stored in history
index fb2ef053bdeb01e4b37a6e9d2bd254dbe2a847b3..1880662af26b4828e69cc7bf34a0fd7c11c71e78 100644 (file)
@@ -62,3 +62,5 @@ func Test_getimstatus()
   set imactivatefunc=
   set imstatusfunc=
 endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
index d927b4e8c1397c1f686e6889ce0aee45274bf94f..6ecd281ac7326755e4ba670c7e8c642f9a2aa7eb 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    342,
 /**/
     341,
 /**/