vim-patch:8.1.2067: no tests for SafeState and SafeStateAgain

Problem:    No tests for SafeState and SafeStateAgain.
Solution:   Add tests.

cadbe1b1fb

This test is quite useless. Don't port to Lua.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-08-21 13:13:48 +08:00
parent 6bf5b2428b
commit 3e79afec54

View File

@@ -2959,6 +2959,36 @@ func Test_autocmd_in_try_block()
au! BufEnter au! BufEnter
endfunc endfunc
func Test_autocmd_SafeState()
CheckRunVimInTerminal
let lines =<< trim END
let g:safe = 0
let g:again = ''
au SafeState * let g:safe += 1
au SafeStateAgain * let g:again ..= 'x'
func CallTimer()
call timer_start(10, {id -> execute('let g:again ..= "t"')})
endfunc
END
call writefile(lines, 'XSafeState')
let buf = RunVimInTerminal('-S XSafeState', #{rows: 6})
call term_sendkeys(buf, ":echo g:safe\<CR>")
call WaitForAssert({-> assert_match('^2 ', term_getline(buf, 6))}, 1000)
call term_sendkeys(buf, ":echo g:again\<CR>")
call WaitForAssert({-> assert_match('^xxxx', term_getline(buf, 6))}, 1000)
call term_sendkeys(buf, ":let g:again = ''\<CR>:call CallTimer()\<CR>")
call term_wait(buf)
call term_sendkeys(buf, ":echo g:again\<CR>")
call WaitForAssert({-> assert_match('xtx', term_getline(buf, 6))}, 1000)
call StopVimInTerminal(buf)
call delete('XSafeState')
endfunc
func Test_autocmd_CmdWinEnter() func Test_autocmd_CmdWinEnter()
CheckRunVimInTerminal CheckRunVimInTerminal
" There is not cmdwin switch, so " There is not cmdwin switch, so