Skip to content

Commit cadbe1b

Browse files
committed
patch 8.1.2067: no tests for SafeState and SafeStateAgain
Problem: No tests for SafeState and SafeStateAgain. Solution: Add tests.
1 parent c258549 commit cadbe1b

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/testdir/test_autocmd.vim

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
source shared.vim
44
source check.vim
5+
source term_util.vim
56

67
func s:cleanup_buffers() abort
78
for bnr in range(1, bufnr('$'))
@@ -2225,3 +2226,33 @@ func Test_throw_in_BufWritePre()
22252226
bwipe!
22262227
au! throwing
22272228
endfunc
2229+
2230+
func Test_autocmd_SafeState()
2231+
CheckRunVimInTerminal
2232+
2233+
let lines =<< trim END
2234+
let g:safe = 0
2235+
let g:again = ''
2236+
au SafeState * let g:safe += 1
2237+
au SafeStateAgain * let g:again ..= 'x'
2238+
func CallTimer()
2239+
call timer_start(10, {id -> execute('let g:again ..= "t"')})
2240+
endfunc
2241+
END
2242+
call writefile(lines, 'XSafeState')
2243+
let buf = RunVimInTerminal('-S XSafeState', #{rows: 6})
2244+
2245+
call term_sendkeys(buf, ":echo g:safe\<CR>")
2246+
call WaitForAssert({-> assert_match('^2 ', term_getline(buf, 6))}, 1000)
2247+
2248+
call term_sendkeys(buf, ":echo g:again\<CR>")
2249+
call WaitForAssert({-> assert_match('^xxxx', term_getline(buf, 6))}, 1000)
2250+
2251+
call term_sendkeys(buf, ":let g:again = ''\<CR>:call CallTimer()\<CR>")
2252+
call term_wait(buf)
2253+
call term_sendkeys(buf, ":echo g:again\<CR>")
2254+
call WaitForAssert({-> assert_match('xtx', term_getline(buf, 6))}, 1000)
2255+
2256+
call StopVimInTerminal(buf)
2257+
call delete('XSafeState')
2258+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ static char *(features[]) =
757757

758758
static int included_patches[] =
759759
{ /* Add new patch number below this line */
760+
/**/
761+
2067,
760762
/**/
761763
2066,
762764
/**/

0 commit comments

Comments
 (0)