comparison src/testdir/test_autocmd.vim @ 18144:95719bfeced2 v8.1.2067

patch 8.1.2067: no tests for SafeState and SafeStateAgain Commit: https://github.com/vim/vim/commit/cadbe1b1fbdf7d7740ae617710e0f6862fdee598 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 22 21:50:09 2019 +0200 patch 8.1.2067: no tests for SafeState and SafeStateAgain Problem: No tests for SafeState and SafeStateAgain. Solution: Add tests.
author Bram Moolenaar <Bram@vim.org>
date Sun, 22 Sep 2019 22:00:03 +0200
parents 9606c0adc148
children 591db862249a
comparison
equal deleted inserted replaced
18143:2416e1a887ca 18144:95719bfeced2
1 " Tests for autocommands 1 " Tests for autocommands
2 2
3 source shared.vim 3 source shared.vim
4 source check.vim 4 source check.vim
5 source term_util.vim
5 6
6 func s:cleanup_buffers() abort 7 func s:cleanup_buffers() abort
7 for bnr in range(1, bufnr('$')) 8 for bnr in range(1, bufnr('$'))
8 if bufloaded(bnr) && bufnr('%') != bnr 9 if bufloaded(bnr) && bufnr('%') != bnr
9 execute 'bd! ' . bnr 10 execute 'bd! ' . bnr
2223 call assert_false(filereadable('Xthefile')) 2224 call assert_false(filereadable('Xthefile'))
2224 2225
2225 bwipe! 2226 bwipe!
2226 au! throwing 2227 au! throwing
2227 endfunc 2228 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