local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local NIL = helpers.NIL
local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq
local command = helpers.command
local eval = helpers.eval
local funcs = helpers.funcs
local iswin = helpers.iswin
local meth_pcall = helpers.meth_pcall
local meths = helpers.meths
local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed
local os_name = helpers.os_name
local request = helpers.request
local source = helpers.source
local next_msg = helpers.next_msg
local expect_err = helpers.expect_err
local format_string = helpers.format_string
local intchar2lua = helpers.intchar2lua
local mergedicts_copy = helpers.mergedicts_copy
describe('API', function()
before_each(clear)
it('validates requests', function()
-- RPC
expect_err('Invalid method: bogus$',
request, 'bogus')
expect_err('Invalid method: … の り 。…$',
request, '… の り 。…')
expect_err('Invalid method: <empty>$',
request, '')
-- Non-RPC: rpcrequest(v:servername) uses internal channel.
expect_err('Invalid method: … の り 。…$',
request, 'nvim_eval',
[=[rpcrequest(sockconnect('pipe', v:servername, {'rpc':1}), '… の り 。…')]=])
expect_err('Invalid method: bogus$',
request, 'nvim_eval',
[=[rpcrequest(sockconnect('pipe', v:servername, {'rpc':1}), 'bogus')]=])
-- XXX: This must be the last one, else next one will fail:
-- "Packer instance already working. Use another Packer ..."
expect_err("can't serialize object$",
request, nil)
end)
it('handles errors in async requests', function()
local error_types = meths.get_api_info()[2].error_types
nvim_async('bogus')
eq({'notification', 'nvim_error_event',
{error_types.Exception.id, 'Invalid method: nvim_bogus'}}, next_msg())
-- error didn't close channel.
eq(2, eval('1+1'))
end)
it('failed async request emits nvim_error_event', function()
local error_types = meths.get_api_info()[2].error_types
nvim_async('command', 'bogus')
eq({'notification', 'nvim_error_event',
{error_types.Exception.id, 'Vim:E492: Not an editor command: bogus'}},
next_msg())
-- error didn't close channel.
eq(2, eval('1+1'))
end)
it('does not set CA_COMMAND_BUSY #7254', function()
nvim('command', 'split')
nvim('command', 'autocmd WinEnter * startinsert')
nvim('command', 'wincmd w')
eq({mode='i', blocking=false}, nvim("get_mode"))
end)
describe('nvim_command', function()
it('works', function()
local fname = helpers.tmpname()
nvim
|