comparison src/testdir/test_timers.vim @ 19289:2f0f308c069c v8.2.0203

patch 8.2.0203: :helptags and some other functionality not tested Commit: https://github.com/vim/vim/commit/e20b9ececa37a81c0340a78f61e57fa1bf46b06d Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 3 21:40:04 2020 +0100 patch 8.2.0203: :helptags and some other functionality not tested Problem: :helptags and some other functionality not tested. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5567)
author Bram Moolenaar <Bram@vim.org>
date Mon, 03 Feb 2020 21:45:03 +0100
parents 2a017e9dc6da
children fe827d6267c2
comparison
equal deleted inserted replaced
19288:f061872089a9 19289:2f0f308c069c
108 endfor 108 endfor
109 call assert_equal(1, found) 109 call assert_equal(1, found)
110 110
111 call timer_stop(id) 111 call timer_stop(id)
112 call assert_equal([], timer_info(id)) 112 call assert_equal([], timer_info(id))
113
114 call assert_fails('call timer_info("abc")', 'E39:')
113 endfunc 115 endfunc
114 116
115 func Test_timer_stopall() 117 func Test_timer_stopall()
116 let id1 = timer_start(1000, 'MyHandler') 118 let id1 = timer_start(1000, 'MyHandler')
117 let id2 = timer_start(2000, 'MyHandler') 119 let id2 = timer_start(2000, 'MyHandler')
150 call assert_inrange(0, 30, slept) 152 call assert_inrange(0, 30, slept)
151 endif 153 endif
152 else 154 else
153 call assert_inrange(0, 10, slept) 155 call assert_inrange(0, 10, slept)
154 endif 156 endif
157
158 call assert_fails('call timer_pause("abc", 1)', 'E39:')
155 endfunc 159 endfunc
156 160
157 func StopMyself(timer) 161 func StopMyself(timer)
158 let g:called += 1 162 let g:called += 1
159 if g:called == 2 163 if g:called == 2
244 let timer = timer_start(10, 'FuncWithError', {'repeat': -1}) 248 let timer = timer_start(10, 'FuncWithError', {'repeat': -1})
245 " Timer will be stopped after failing 3 out of 3 times. 249 " Timer will be stopped after failing 3 out of 3 times.
246 call WaitForAssert({-> assert_equal(3, g:call_count)}) 250 call WaitForAssert({-> assert_equal(3, g:call_count)})
247 sleep 50m 251 sleep 50m
248 call assert_equal(3, g:call_count) 252 call assert_equal(3, g:call_count)
253
254 call assert_fails('call timer_start(100, "MyHandler", "abc")', 'E475:')
255 call assert_fails('call timer_start(100, [])', 'E921:')
256 call assert_fails('call timer_stop("abc")', 'E39:')
249 endfunc 257 endfunc
250 258
251 func FuncWithCaughtError(timer) 259 func FuncWithCaughtError(timer)
252 let g:call_count += 1 260 let g:call_count += 1
253 try 261 try
403 411
404 call delete('Xtest.vim') 412 call delete('Xtest.vim')
405 exe buf .. 'bwipe!' 413 exe buf .. 'bwipe!'
406 endfunc 414 endfunc
407 415
416 " Test for garbage collection when a timer is still running
417 func Test_timer_garbage_collect()
418 let timer = timer_start(1000, function('MyHandler'), {'repeat' : 10})
419 call test_garbagecollect_now()
420 let l = timer_info(timer)
421 call assert_equal(function('MyHandler'), l[0].callback)
422 call timer_stop(timer)
423 endfunc
424
408 " vim: shiftwidth=2 sts=2 expandtab 425 " vim: shiftwidth=2 sts=2 expandtab