summaryrefslogtreecommitdiff
path: root/src/testdir/test_timers.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-08-22 21:40:29 +0200
committerBram Moolenaar <Bram@vim.org>2016-08-22 21:40:29 +0200
commitf267f8bdf777073e392ada5b31d837c7b6090eb4 (patch)
tree304b0775c08e167320e8d9c6f15c61baafa493a0 /src/testdir/test_timers.vim
parent9baf297c99cc35adb921bee04369499d76438889 (diff)
downloadvim-git-f267f8bdf777073e392ada5b31d837c7b6090eb4.tar.gz
patch 7.4.2240v7.4.2240
Problem: Tests using the sleep time can be flaky. Solution: Use reltime() if available. (Partly by Shane Harper)
Diffstat (limited to 'src/testdir/test_timers.vim')
-rw-r--r--src/testdir/test_timers.vim24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim
index 46777d1ea..5b9e5c48a 100644
--- a/src/testdir/test_timers.vim
+++ b/src/testdir/test_timers.vim
@@ -19,7 +19,11 @@ func Test_oneshot()
let timer = timer_start(50, 'MyHandler')
let slept = WaitFor('g:val == 1')
call assert_equal(1, g:val)
- call assert_inrange(30, 100, slept)
+ if has('reltime')
+ call assert_inrange(50, 100, slept)
+ else
+ call assert_inrange(20, 100, slept)
+ endif
endfunc
func Test_repeat_three()
@@ -27,7 +31,11 @@ func Test_repeat_three()
let timer = timer_start(50, 'MyHandler', {'repeat': 3})
let slept = WaitFor('g:val == 3')
call assert_equal(3, g:val)
- call assert_inrange(80, 200, slept)
+ if has('reltime')
+ call assert_inrange(150, 200, slept)
+ else
+ call assert_inrange(80, 200, slept)
+ endif
endfunc
func Test_repeat_many()
@@ -48,7 +56,11 @@ func Test_with_partial_callback()
call timer_start(50, s:meow.bite)
let slept = WaitFor('g:val == 1')
call assert_equal(1, g:val)
- call assert_inrange(30, 100, slept)
+ if has('reltime')
+ call assert_inrange(50, 100, slept)
+ else
+ call assert_inrange(20, 100, slept)
+ endif
endfunc
func Test_retain_partial()
@@ -109,7 +121,11 @@ func Test_paused()
let slept = WaitFor('g:val == 1')
call assert_equal(1, g:val)
- call assert_inrange(0, 10, slept)
+ if has('reltime')
+ call assert_inrange(0, 30, slept)
+ else
+ call assert_inrange(0, 10, slept)
+ endif
endfunc
" vim: shiftwidth=2 sts=2 expandtab