]> granicus.if.org Git - vim/commitdiff
patch 8.0.0314: getcmd*() functions are not tested v8.0.0314
authorBram Moolenaar <Bram@vim.org>
Mon, 6 Feb 2017 21:22:17 +0000 (22:22 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 6 Feb 2017 21:22:17 +0000 (22:22 +0100)
Problem:    getcmdtype(), getcmdpos() and getcmdline() are not tested.
Solution:   Add tests. (Yegappan Lakshmanan)

src/testdir/test_cmdline.vim
src/version.c

index aa8fb13c6533b1ca8e1ac7b3c647cb922e12bdea..0a5c91009ca8afa3775bb1332daf85bbc7e36fd3 100644 (file)
@@ -330,4 +330,36 @@ func Test_cmdline_search_range()
   bwipe!
 endfunc
 
+" Tests for getcmdline(), getcmdpos() and getcmdtype()
+func Check_cmdline(cmdtype)
+  call assert_equal('MyCmd a', getcmdline())
+  call assert_equal(8, getcmdpos())
+  call assert_equal(a:cmdtype, getcmdtype())
+  return ''
+endfunc
+
+func Test_getcmdtype()
+  call feedkeys(":MyCmd a\<C-R>=Check_cmdline(':')\<CR>\<Esc>", "xt")
+
+  let cmdtype = ''
+  debuggreedy
+  call feedkeys(":debug echo 'test'\<CR>", "t")
+  call feedkeys("let cmdtype = \<C-R>=string(getcmdtype())\<CR>\<CR>", "t")
+  call feedkeys("cont\<CR>", "xt")
+  0debuggreedy
+  call assert_equal('>', cmdtype)
+
+  call feedkeys("/MyCmd a\<C-R>=Check_cmdline('/')\<CR>\<Esc>", "xt")
+  call feedkeys("?MyCmd a\<C-R>=Check_cmdline('?')\<CR>\<Esc>", "xt")
+
+  call feedkeys(":call input('Answer?')\<CR>", "t")
+  call feedkeys("MyCmd a\<C-R>=Check_cmdline('@')\<CR>\<Esc>", "xt")
+
+  call feedkeys(":insert\<CR>MyCmd a\<C-R>=Check_cmdline('-')\<CR>\<Esc>", "xt")
+
+  cnoremap <expr> <F6> Check_cmdline('=')
+  call feedkeys("a\<C-R>=MyCmd a\<F6>\<Esc>\<Esc>", "xt")
+  cunmap <F6>
+endfunc
+
 set cpo&
index 261a55d22d1e7f837f1a714022f713b2102fd62d..4da417b925b195756f0d906910ee859c5e2d7e57 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    314,
 /**/
     313,
 /**/