diff options
author | Marco Hinz <mh.codebro@gmail.com> | 2019-01-16 21:21:10 +0100 |
---|---|---|
committer | Marco Hinz <mh.codebro@gmail.com> | 2019-01-17 15:59:23 +0100 |
commit | f2e996b9918de2bf23523ffe5b76c3718991158f (patch) | |
tree | 2adc632e60d6e8c4ff36557fab2a9b500ae0b6f6 /test/functional/eval/timer_spec.lua | |
parent | 0afd452ef19ed08db8e74d72c0316bc40ac9c9bd (diff) | |
download | rneovim-f2e996b9918de2bf23523ffe5b76c3718991158f.tar.gz rneovim-f2e996b9918de2bf23523ffe5b76c3718991158f.tar.bz2 rneovim-f2e996b9918de2bf23523ffe5b76c3718991158f.zip |
tests: load-adjust timer tests (functionaltest)
Diffstat (limited to 'test/functional/eval/timer_spec.lua')
-rw-r--r-- | test/functional/eval/timer_spec.lua | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua index 124b9625c3..ce0e24d8d7 100644 --- a/test/functional/eval/timer_spec.lua +++ b/test/functional/eval/timer_spec.lua @@ -4,6 +4,7 @@ local feed, eq, eval = helpers.feed, helpers.eq, helpers.eval local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run local clear, command, funcs = helpers.clear, helpers.command, helpers.funcs local curbufmeths = helpers.curbufmeths +local load_adjust = helpers.load_adjust describe('timers', function() before_each(function() @@ -19,14 +20,14 @@ describe('timers', function() it('works one-shot', function() command("call timer_start(50, 'MyHandler')") eq(0,eval("g:val")) - run(nil, nil, nil, 200) + run(nil, nil, nil, load_adjust(200)) eq(1,eval("g:val")) end) it('works one-shot when repeat=0', function() command("call timer_start(50, 'MyHandler', {'repeat': 0})") eq(0,eval("g:val")) - run(nil, nil, nil, 200) + run(nil, nil, nil, load_adjust(200)) eq(1,eval("g:val")) end) @@ -34,7 +35,7 @@ describe('timers', function() it('works with repeat two', function() command("call timer_start(50, 'MyHandler', {'repeat': 2})") eq(0,eval("g:val")) - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(2,eval("g:val")) end) @@ -42,14 +43,14 @@ describe('timers', function() command("call timer_start(50, 'MyHandler', {'repeat': 2})") nvim_async("command", "sleep 10") eq(0,eval("g:val")) - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(2,eval("g:val")) end) it('works with zero timeout', function() -- timer_start does still not invoke the callback immediately eq(0,eval("[timer_start(0, 'MyHandler', {'repeat': 1000}), g:val][1]")) - run(nil, nil, nil, 400) + run(nil, nil, nil, load_adjust(400)) eq(1000,eval("g:val")) end) @@ -58,18 +59,18 @@ describe('timers', function() -- this also tests that remote requests works during sleep eval("timer_start(50, 'MyHandler', {'repeat': 2})") eq(0,eval("g:val")) - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(2,eval("g:val")) end) it('are paused when event processing is disabled', function() command("call timer_start(50, 'MyHandler', {'repeat': -1})") - run(nil, nil, nil, 100) + run(nil, nil, nil, load_adjust(100)) local count = eval("g:val") -- shows two line error message and thus invokes the return prompt. -- if we start to allow event processing here, we need to change this test. feed(':throw "fatal error"<CR>') - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) feed("<cr>") local diff = eval("g:val") - count assert(0 <= diff and diff <= 4, @@ -79,7 +80,7 @@ describe('timers', function() it('are triggered in blocking getchar() call', function() command("call timer_start(50, 'MyHandler', {'repeat': -1})") nvim_async("command", "let g:c = getchar()") - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) feed("c") local count = eval("g:val") assert(count >= 3, 'expected count >= 3, got: '..tostring(count)) @@ -137,10 +138,10 @@ describe('timers', function() it('can be stopped', function() local t = eval("timer_start(50, 'MyHandler', {'repeat': -1})") eq(0,eval("g:val")) - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) funcs.timer_stop(t) local count = eval("g:val") - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) local count2 = eval("g:val") -- when count is eval:ed after timer_stop this should be non-racy eq(count, count2) @@ -161,7 +162,7 @@ describe('timers', function() ]]) command("call timer_start(50, 'MyHandler', {'repeat': -1})") eq(0,eval("g:val")) - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(3,eval("g:val")) end) @@ -174,7 +175,7 @@ describe('timers', function() ]]) command("call timer_start(20, 'MyHandler', {'repeat': 3})") command("call timer_start(40, 'MyHandler2', {'repeat': 2})") - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(3,eval("g:val")) eq(2,eval("g:val2")) end) @@ -189,7 +190,7 @@ describe('timers', function() endfunc ]]) command("call timer_start(5, 'MyHandler', {'repeat': 1})") - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(1,eval("g:val")) end) |