forked from aniani/vim
patch 8.1.2066: no tests for state()
Problem: No tests for state(). Solution: Add tests. Clean up some feature checks. Make "a" flag work.
This commit is contained in:
parent
910c378d93
commit
c258549032
@ -1297,7 +1297,7 @@ f_state(typval_T *argvars, typval_T *rettv)
|
|||||||
may_add_state_char(&ga, include, 'o');
|
may_add_state_char(&ga, include, 'o');
|
||||||
if (autocmd_busy)
|
if (autocmd_busy)
|
||||||
may_add_state_char(&ga, include, 'x');
|
may_add_state_char(&ga, include, 'x');
|
||||||
if (!ctrl_x_mode_none())
|
if (ins_compl_active())
|
||||||
may_add_state_char(&ga, include, 'a');
|
may_add_state_char(&ga, include, 'a');
|
||||||
|
|
||||||
# ifdef FEAT_JOB_CHANNEL
|
# ifdef FEAT_JOB_CHANNEL
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
" Tests for various functions.
|
" Tests for various functions.
|
||||||
source shared.vim
|
source shared.vim
|
||||||
source check.vim
|
source check.vim
|
||||||
|
source term_util.vim
|
||||||
|
|
||||||
" Must be done first, since the alternate buffer must be unset.
|
" Must be done first, since the alternate buffer must be unset.
|
||||||
func Test_00_bufexists()
|
func Test_00_bufexists()
|
||||||
@ -1659,3 +1660,62 @@ func Test_bufadd_bufload()
|
|||||||
call assert_equal(0, bufexists('someName'))
|
call assert_equal(0, bufexists('someName'))
|
||||||
call delete('XotherName')
|
call delete('XotherName')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_state()
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
call setline(1, ['one', 'two', 'three'])
|
||||||
|
map ;; gg
|
||||||
|
func RunTimer()
|
||||||
|
call timer_start(10, {id -> execute('let g:state = state()') .. execute('let g:mode = mode()')})
|
||||||
|
endfunc
|
||||||
|
au Filetype foobar let g:state = state()|let g:mode = mode()
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XState')
|
||||||
|
let buf = RunVimInTerminal('-S XState', #{rows: 6})
|
||||||
|
|
||||||
|
" Using a ":" command Vim is busy, thus "S" is returned
|
||||||
|
call term_sendkeys(buf, ":echo 'state: ' .. state() .. '; mode: ' .. mode()\<CR>")
|
||||||
|
call WaitForAssert({-> assert_match('state: S; mode: n', term_getline(buf, 6))}, 1000)
|
||||||
|
call term_sendkeys(buf, ":\<CR>")
|
||||||
|
|
||||||
|
" Using a timer callback
|
||||||
|
call term_sendkeys(buf, ":call RunTimer()\<CR>")
|
||||||
|
call term_wait(buf, 50)
|
||||||
|
let getstate = ":echo 'state: ' .. g:state .. '; mode: ' .. g:mode\<CR>"
|
||||||
|
call term_sendkeys(buf, getstate)
|
||||||
|
call WaitForAssert({-> assert_match('state: c; mode: n', term_getline(buf, 6))}, 1000)
|
||||||
|
|
||||||
|
" Halfway a mapping
|
||||||
|
call term_sendkeys(buf, ":call RunTimer()\<CR>;")
|
||||||
|
call term_wait(buf, 50)
|
||||||
|
call term_sendkeys(buf, ";")
|
||||||
|
call term_sendkeys(buf, getstate)
|
||||||
|
call WaitForAssert({-> assert_match('state: mSc; mode: n', term_getline(buf, 6))}, 1000)
|
||||||
|
|
||||||
|
" Insert mode completion
|
||||||
|
call term_sendkeys(buf, ":call RunTimer()\<CR>Got\<C-N>")
|
||||||
|
call term_wait(buf, 50)
|
||||||
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
|
call term_sendkeys(buf, getstate)
|
||||||
|
call WaitForAssert({-> assert_match('state: aSc; mode: i', term_getline(buf, 6))}, 1000)
|
||||||
|
|
||||||
|
" Autocommand executing
|
||||||
|
call term_sendkeys(buf, ":set filetype=foobar\<CR>")
|
||||||
|
call term_wait(buf, 50)
|
||||||
|
call term_sendkeys(buf, getstate)
|
||||||
|
call WaitForAssert({-> assert_match('state: xS; mode: n', term_getline(buf, 6))}, 1000)
|
||||||
|
|
||||||
|
" Todo: "w" - waiting for ch_evalexpr()
|
||||||
|
|
||||||
|
" messages scrolled
|
||||||
|
call term_sendkeys(buf, ":call RunTimer()\<CR>:echo \"one\\ntwo\\nthree\"\<CR>")
|
||||||
|
call term_wait(buf, 50)
|
||||||
|
call term_sendkeys(buf, "\<CR>")
|
||||||
|
call term_sendkeys(buf, getstate)
|
||||||
|
call WaitForAssert({-> assert_match('state: Scs; mode: r', term_getline(buf, 6))}, 1000)
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('XState')
|
||||||
|
endfunc
|
||||||
|
@ -1033,9 +1033,7 @@ endfunc
|
|||||||
" Run Vim in a terminal, then start a terminal in that Vim without a kill
|
" Run Vim in a terminal, then start a terminal in that Vim without a kill
|
||||||
" argument, check that :confirm qall works.
|
" argument, check that :confirm qall works.
|
||||||
func Test_terminal_qall_prompt()
|
func Test_terminal_qall_prompt()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
let buf = RunVimInTerminal('', {})
|
let buf = RunVimInTerminal('', {})
|
||||||
|
|
||||||
" Open a terminal window and wait for the prompt to appear
|
" Open a terminal window and wait for the prompt to appear
|
||||||
@ -1094,9 +1092,7 @@ func Check_dump01(off)
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_dumpwrite_composing()
|
func Test_terminal_dumpwrite_composing()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
let save_enc = &encoding
|
let save_enc = &encoding
|
||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
call assert_equal(1, winnr('$'))
|
call assert_equal(1, winnr('$'))
|
||||||
@ -1219,9 +1215,7 @@ func Api_drop_common(options)
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_drop_newwin()
|
func Test_terminal_api_drop_newwin()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
let buf = Api_drop_common('')
|
let buf = Api_drop_common('')
|
||||||
call assert_equal(0, &bin)
|
call assert_equal(0, &bin)
|
||||||
call assert_equal('', &fenc)
|
call assert_equal('', &fenc)
|
||||||
@ -1232,9 +1226,7 @@ func Test_terminal_api_drop_newwin()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_drop_newwin_bin()
|
func Test_terminal_api_drop_newwin_bin()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
let buf = Api_drop_common(',{"bin":1}')
|
let buf = Api_drop_common(',{"bin":1}')
|
||||||
call assert_equal(1, &bin)
|
call assert_equal(1, &bin)
|
||||||
|
|
||||||
@ -1244,9 +1236,7 @@ func Test_terminal_api_drop_newwin_bin()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_drop_newwin_binary()
|
func Test_terminal_api_drop_newwin_binary()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
let buf = Api_drop_common(',{"binary":1}')
|
let buf = Api_drop_common(',{"binary":1}')
|
||||||
call assert_equal(1, &bin)
|
call assert_equal(1, &bin)
|
||||||
|
|
||||||
@ -1256,9 +1246,7 @@ func Test_terminal_api_drop_newwin_binary()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_drop_newwin_nobin()
|
func Test_terminal_api_drop_newwin_nobin()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
set binary
|
set binary
|
||||||
let buf = Api_drop_common(',{"nobin":1}')
|
let buf = Api_drop_common(',{"nobin":1}')
|
||||||
call assert_equal(0, &bin)
|
call assert_equal(0, &bin)
|
||||||
@ -1270,9 +1258,7 @@ func Test_terminal_api_drop_newwin_nobin()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_drop_newwin_nobinary()
|
func Test_terminal_api_drop_newwin_nobinary()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
set binary
|
set binary
|
||||||
let buf = Api_drop_common(',{"nobinary":1}')
|
let buf = Api_drop_common(',{"nobinary":1}')
|
||||||
call assert_equal(0, &bin)
|
call assert_equal(0, &bin)
|
||||||
@ -1284,9 +1270,7 @@ func Test_terminal_api_drop_newwin_nobinary()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_drop_newwin_ff()
|
func Test_terminal_api_drop_newwin_ff()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
let buf = Api_drop_common(',{"ff":"dos"}')
|
let buf = Api_drop_common(',{"ff":"dos"}')
|
||||||
call assert_equal("dos", &ff)
|
call assert_equal("dos", &ff)
|
||||||
|
|
||||||
@ -1296,9 +1280,7 @@ func Test_terminal_api_drop_newwin_ff()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_drop_newwin_fileformat()
|
func Test_terminal_api_drop_newwin_fileformat()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
let buf = Api_drop_common(',{"fileformat":"dos"}')
|
let buf = Api_drop_common(',{"fileformat":"dos"}')
|
||||||
call assert_equal("dos", &ff)
|
call assert_equal("dos", &ff)
|
||||||
|
|
||||||
@ -1308,9 +1290,7 @@ func Test_terminal_api_drop_newwin_fileformat()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_drop_newwin_enc()
|
func Test_terminal_api_drop_newwin_enc()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
let buf = Api_drop_common(',{"enc":"utf-16"}')
|
let buf = Api_drop_common(',{"enc":"utf-16"}')
|
||||||
call assert_equal("utf-16", &fenc)
|
call assert_equal("utf-16", &fenc)
|
||||||
|
|
||||||
@ -1320,9 +1300,7 @@ func Test_terminal_api_drop_newwin_enc()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_drop_newwin_encoding()
|
func Test_terminal_api_drop_newwin_encoding()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
let buf = Api_drop_common(',{"encoding":"utf-16"}')
|
let buf = Api_drop_common(',{"encoding":"utf-16"}')
|
||||||
call assert_equal("utf-16", &fenc)
|
call assert_equal("utf-16", &fenc)
|
||||||
|
|
||||||
@ -1332,9 +1310,7 @@ func Test_terminal_api_drop_newwin_encoding()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_drop_oldwin()
|
func Test_terminal_api_drop_oldwin()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
let firstwinid = win_getid()
|
let firstwinid = win_getid()
|
||||||
split Xtextfile
|
split Xtextfile
|
||||||
let textfile_winid = win_getid()
|
let textfile_winid = win_getid()
|
||||||
@ -1375,9 +1351,7 @@ func WriteApiCall(funcname)
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_call()
|
func Test_terminal_api_call()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
|
|
||||||
call WriteApiCall('Tapi_TryThis')
|
call WriteApiCall('Tapi_TryThis')
|
||||||
let buf = RunVimInTerminal('-S Xscript', {})
|
let buf = RunVimInTerminal('-S Xscript', {})
|
||||||
@ -1392,9 +1366,7 @@ func Test_terminal_api_call()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_call_fails()
|
func Test_terminal_api_call_fails()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
|
|
||||||
call WriteApiCall('TryThis')
|
call WriteApiCall('TryThis')
|
||||||
call ch_logfile('Xlog', 'w')
|
call ch_logfile('Xlog', 'w')
|
||||||
@ -1418,9 +1390,7 @@ func Tapi_Delete(bufnum, arg)
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_api_call_fail_delete()
|
func Test_terminal_api_call_fail_delete()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
|
|
||||||
call WriteApiCall('Tapi_Delete')
|
call WriteApiCall('Tapi_Delete')
|
||||||
let buf = RunVimInTerminal('-S Xscript', {})
|
let buf = RunVimInTerminal('-S Xscript', {})
|
||||||
@ -1513,9 +1483,7 @@ func Test_terminal_ansicolors_func()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_all_ansi_colors()
|
func Test_terminal_all_ansi_colors()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Use all the ANSI colors.
|
" Use all the ANSI colors.
|
||||||
call writefile([
|
call writefile([
|
||||||
@ -1570,9 +1538,7 @@ func Test_terminal_all_ansi_colors()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_termwinsize_option_fixed()
|
func Test_terminal_termwinsize_option_fixed()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
set termwinsize=6x40
|
set termwinsize=6x40
|
||||||
let text = []
|
let text = []
|
||||||
for n in range(10)
|
for n in range(10)
|
||||||
@ -2034,9 +2000,7 @@ func Test_terminal_statusline()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_getwinpos()
|
func Test_terminal_getwinpos()
|
||||||
if !CanRunVimInTerminal()
|
CheckRunVimInTerminal
|
||||||
throw 'Skipped: cannot run Vim in a terminal window'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" split, go to the bottom-right window
|
" split, go to the bottom-right window
|
||||||
split
|
split
|
||||||
|
@ -757,6 +757,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2066,
|
||||||
/**/
|
/**/
|
||||||
2065,
|
2065,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user