diff options
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 883e0e373b..57bb2f9765 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -2148,6 +2148,13 @@ describe('lua stdlib', function() ]] eq('2', funcs.luaeval "BUF") eq(2, funcs.luaeval "#vim.api.nvim_list_bufs()") + + -- vim.cmd can be indexed with a command name + exec_lua [[ + vim.cmd.let 'g:var = 2' + ]] + + eq(2, funcs.luaeval "vim.g.var") end) it('vim.regex', function() @@ -2493,6 +2500,41 @@ describe('lua stdlib', function() eq(false, pcall_result) end) + + describe('returns -2 when interrupted', function() + before_each(function() + local channel = meths.get_api_info()[1] + meths.set_var('channel', channel) + end) + + it('without callback', function() + exec_lua([[ + function _G.Wait() + vim.rpcnotify(vim.g.channel, 'ready') + local _, interrupted = vim.wait(4000) + vim.rpcnotify(vim.g.channel, 'wait', interrupted) + end + ]]) + feed(':lua _G.Wait()<CR>') + eq({'notification', 'ready', {}}, next_msg(500)) + feed('<C-C>') + eq({'notification', 'wait', {-2}}, next_msg(500)) + end) + + it('with callback', function() + exec_lua([[ + function _G.Wait() + vim.rpcnotify(vim.g.channel, 'ready') + local _, interrupted = vim.wait(4000, function() end) + vim.rpcnotify(vim.g.channel, 'wait', interrupted) + end + ]]) + feed(':lua _G.Wait()<CR>') + eq({'notification', 'ready', {}}, next_msg(500)) + feed('<C-C>') + eq({'notification', 'wait', {-2}}, next_msg(500)) + end) + end) end) it('vim.notify_once', function() |