0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.0.0314: getcmd*() functions are not tested

Problem:    getcmdtype(), getcmdpos() and getcmdline() are not tested.
Solution:   Add tests. (Yegappan Lakshmanan)
This commit is contained in:
Bram Moolenaar
2017-02-06 22:22:17 +01:00
parent 6f785749db
commit 65189a1294
2 changed files with 34 additions and 0 deletions

View 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&

View File

@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
314,
/**/
313,
/**/