From 3e79afec5485b17fe8e91658cc1de6fab6ec55f1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 13:13:48 +0800 Subject: [PATCH] vim-patch:8.1.2067: no tests for SafeState and SafeStateAgain Problem: No tests for SafeState and SafeStateAgain. Solution: Add tests. https://github.com/vim/vim/commit/cadbe1b1fbdf7d7740ae617710e0f6862fdee598 This test is quite useless. Don't port to Lua. Co-authored-by: Bram Moolenaar --- test/old/testdir/test_autocmd.vim | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim index c44988321f..c279073e08 100644 --- a/test/old/testdir/test_autocmd.vim +++ b/test/old/testdir/test_autocmd.vim @@ -2959,6 +2959,36 @@ func Test_autocmd_in_try_block() au! BufEnter 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\") + call WaitForAssert({-> assert_match('^2 ', term_getline(buf, 6))}, 1000) + + call term_sendkeys(buf, ":echo g:again\") + call WaitForAssert({-> assert_match('^xxxx', term_getline(buf, 6))}, 1000) + + call term_sendkeys(buf, ":let g:again = ''\:call CallTimer()\") + call term_wait(buf) + call term_sendkeys(buf, ":echo g:again\") + call WaitForAssert({-> assert_match('xtx', term_getline(buf, 6))}, 1000) + + call StopVimInTerminal(buf) + call delete('XSafeState') +endfunc + func Test_autocmd_CmdWinEnter() CheckRunVimInTerminal " There is not cmdwin switch, so