diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-18 09:50:44 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-05-18 15:48:13 +0200 |
commit | 7669fc1e9b9dba015597974f4a2b46f2439b48da (patch) | |
tree | 3fe14d0eac1881c552c3fb6e732e84cf4d5da147 /src | |
parent | bba75eb184cee3d96264a392e2083f5b50732214 (diff) | |
download | rneovim-7669fc1e9b9dba015597974f4a2b46f2439b48da.tar.gz rneovim-7669fc1e9b9dba015597974f4a2b46f2439b48da.tar.bz2 rneovim-7669fc1e9b9dba015597974f4a2b46f2439b48da.zip |
test: share implementation of testdir/load.vim
Also, don't compute load factor unless load_adjust() was called, it
slows down the test suite.
ref #9292
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/testdir/load.vim | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_timers.vim | 14 |
2 files changed, 9 insertions, 11 deletions
diff --git a/src/nvim/testdir/load.vim b/src/nvim/testdir/load.vim index 2e01338dd0..6369b8f45e 100644 --- a/src/nvim/testdir/load.vim +++ b/src/nvim/testdir/load.vim @@ -1,3 +1,5 @@ +" Also used by: test/functional/helpers.lua + function! s:load_factor() abort let timeout = 200 let times = [] @@ -23,8 +25,8 @@ function! s:load_factor() abort endfunction " Compute load factor only once. -let s:load_factor = s:load_factor() +let g:test_load_factor = s:load_factor() function! LoadAdjust(num) abort - return float2nr(ceil(a:num * s:load_factor)) + return float2nr(ceil(a:num * g:test_load_factor)) endfunction diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index 5b5f001e6b..9384989a35 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -15,17 +15,13 @@ func MyHandlerWithLists(lists, timer) let x = string(a:lists) endfunc -func s:assert_inrange(lower, upper, actual) - return assert_inrange(a:lower, LoadAdjust(a:upper), a:actual) -endfunc - func Test_oneshot() let g:val = 0 let timer = timer_start(50, 'MyHandler') let slept = WaitFor('g:val == 1') call assert_equal(1, g:val) if has('reltime') - call s:assert_inrange(40, 120, slept) + call assert_inrange(40, LoadAdjust(120), slept) else call assert_inrange(20, 120, slept) endif @@ -37,7 +33,7 @@ func Test_repeat_three() let slept = WaitFor('g:val == 3') call assert_equal(3, g:val) if has('reltime') - call s:assert_inrange(120, 250, slept) + call assert_inrange(120, LoadAdjust(250), slept) else call assert_inrange(80, 200, slept) endif @@ -52,7 +48,7 @@ func Test_repeat_many() endif sleep 200m call timer_stop(timer) - call s:assert_inrange((has('mac') ? 1 : 2), 4, g:val) + call assert_inrange((has('mac') ? 1 : 2), LoadAdjust(4), g:val) endfunc func Test_with_partial_callback() @@ -66,7 +62,7 @@ func Test_with_partial_callback() let slept = WaitFor('g:val == 1') call assert_equal(1, g:val) if has('reltime') - call s:assert_inrange(40, 130, slept) + call assert_inrange(40, LoadAdjust(130), slept) else call assert_inrange(20, 100, slept) endif @@ -129,7 +125,7 @@ func Test_paused() let slept = WaitFor('g:val == 1') call assert_equal(1, g:val) if has('reltime') - call s:assert_inrange(0, 140, slept) + call assert_inrange(0, LoadAdjust(140), slept) else call assert_inrange(0, 10, slept) endif |