aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/wait_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2021-09-17 09:16:40 -0700
committerGitHub <noreply@github.com>2021-09-17 09:16:40 -0700
commitd8de4eb685e35646c7d541e9a75bdc296127b7e2 (patch)
tree4bb05ec713856715ac9ba57e5d116eed344511b9 /test/functional/eval/wait_spec.lua
parentd56002f7b722facd97b0958e141c8ed2d01495f7 (diff)
downloadrneovim-d8de4eb685e35646c7d541e9a75bdc296127b7e2.tar.gz
rneovim-d8de4eb685e35646c7d541e9a75bdc296127b7e2.tar.bz2
rneovim-d8de4eb685e35646c7d541e9a75bdc296127b7e2.zip
test: reorg #15698
Problem: Subdirectories like "visual", "insert", "normal" encourage people to separate *related* tests for no good reason. Typically the _mode_ is not the relevant topic of a test (and when it is, _then_ create an appropriate describe() or it()). Solution: - Delete the various `test/functional/<mode>/` subdirectories, move their tests to more meaningful topics. - Rename `…/normal/` to `…/editor/`. - Move or merge `…/visual/*` and `…/insert/*` tests into here where appropriate. - Rename `…/eval/` to `…/vimscript/`. - Move `…/viml/*` into here also. * test(reorg): insert/* => editor/mode_insert_spec.lua * test(reorg): cmdline/* => editor/mode_cmdline_spec.lua * test(reorg): eval core tests => eval_spec.lua
Diffstat (limited to 'test/functional/eval/wait_spec.lua')
-rw-r--r--test/functional/eval/wait_spec.lua78
1 files changed, 0 insertions, 78 deletions
diff --git a/test/functional/eval/wait_spec.lua b/test/functional/eval/wait_spec.lua
deleted file mode 100644
index ee95e02a7f..0000000000
--- a/test/functional/eval/wait_spec.lua
+++ /dev/null
@@ -1,78 +0,0 @@
-local helpers = require('test.functional.helpers')(after_each)
-local call = helpers.call
-local clear = helpers.clear
-local command = helpers.command
-local eval = helpers.eval
-local eq = helpers.eq
-local feed = helpers.feed
-local feed_command = helpers.feed_command
-local next_msg = helpers.next_msg
-local nvim = helpers.nvim
-local source = helpers.source
-local pcall_err = helpers.pcall_err
-
-before_each(function()
- clear()
- local channel = nvim('get_api_info')[1]
- nvim('set_var', 'channel', channel)
-end)
-
-describe('wait()', function()
- it('waits and returns 0 when condition is satisfied', function()
- source([[
- let g:_awake = 0
- call timer_start(100, { -> nvim_command('let g:_awake = 1') })
- ]])
- eq(0, eval('g:_awake'))
- eq(0, eval('wait(1500, { -> g:_awake })'))
- eq(1, eval('g:_awake'))
-
- eq(0, eval('wait(0, 1)'))
- end)
-
- it('returns -1 on timeout', function()
- eq(-1, eval('wait(0, 0)'))
- eq(-1, eval('wait(50, 0)'))
- end)
-
- it('returns -2 when interrupted', function()
- feed_command('call rpcnotify(g:channel, "ready") | '..
- 'call rpcnotify(g:channel, "wait", wait(-1, 0))')
- eq({'notification', 'ready', {}}, next_msg())
- feed('<c-c>')
- eq({'notification', 'wait', {-2}}, next_msg())
- end)
-
- it('returns -3 on error', function()
- command('silent! let ret = wait(-1, "error")')
- eq(-3, eval('ret'))
- command('let ret = 0 | silent! let ret = wait(-1, { -> error })')
- eq(-3, eval('ret'))
- end)
-
- it('evaluates the condition on given interval', function()
- source([[
- function Count()
- let g:counter += 1
- return g:counter
- endfunction
- ]])
-
- -- XXX: flaky (#11137)
- helpers.retry(nil, nil, function()
- nvim('set_var', 'counter', 0)
- eq(-1, call('wait', 20, 'Count() >= 5', 99999))
- end)
-
- nvim('set_var', 'counter', 0)
- eq(0, call('wait', 10000, 'Count() >= 5', 5))
- eq(5, nvim('get_var', 'counter'))
- end)
-
- it('validates args', function()
- eq('Vim:E475: Invalid value for argument 1', pcall_err(call, 'wait', '', 1))
- eq('Vim:E475: Invalid value for argument 3', pcall_err(call, 'wait', 0, 1, -1))
- eq('Vim:E475: Invalid value for argument 3', pcall_err(call, 'wait', 0, 1, 0))
- eq('Vim:E475: Invalid value for argument 3', pcall_err(call, 'wait', 0, 1, ''))
- end)
-end)