mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
feat(test): add Lua forms for API methods (#20152)
This commit is contained in:
@@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen')
|
||||
local clear, nvim, buffer = helpers.clear, helpers.nvim, helpers.buffer
|
||||
local curbuf, curwin, eq = helpers.curbuf, helpers.curwin, helpers.eq
|
||||
local curbufmeths, ok = helpers.curbufmeths, helpers.ok
|
||||
local describe_lua_and_rpc = helpers.describe_lua_and_rpc(describe)
|
||||
local meths = helpers.meths
|
||||
local funcs = helpers.funcs
|
||||
local request = helpers.request
|
||||
@@ -579,9 +580,8 @@ describe('api/buf', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_buf_get_text', function()
|
||||
local get_text = curbufmeths.get_text
|
||||
|
||||
describe_lua_and_rpc('nvim_buf_get_text', function(api)
|
||||
local get_text = api.curbufmeths.get_text
|
||||
before_each(function()
|
||||
insert([[
|
||||
hello foo!
|
||||
|
||||
@@ -605,10 +605,10 @@ describe('API', function()
|
||||
eq([[Error loading lua: [string "<nvim>"]:0: unexpected symbol]],
|
||||
pcall_err(meths.exec_lua, 'aa=bb\0', {}))
|
||||
|
||||
eq([[Error executing lua: [string "<nvim>"]:0: attempt to call global 'bork' (a nil value)]],
|
||||
eq([[attempt to call global 'bork' (a nil value)]],
|
||||
pcall_err(meths.exec_lua, 'bork()', {}))
|
||||
|
||||
eq('Error executing lua: [string "<nvim>"]:0: did\nthe\nfail',
|
||||
eq('did\nthe\nfail',
|
||||
pcall_err(meths.exec_lua, 'error("did\\nthe\\nfail")', {}))
|
||||
end)
|
||||
|
||||
@@ -1149,7 +1149,7 @@ describe('API', function()
|
||||
end)
|
||||
it('vim.paste() failure', function()
|
||||
nvim('exec_lua', 'vim.paste = (function(lines, phase) error("fake fail") end)', {})
|
||||
eq([[Error executing lua: [string "<nvim>"]:0: fake fail]],
|
||||
eq('fake fail',
|
||||
pcall_err(request, 'nvim_paste', 'line 1\nline 2\nline 3', false, 1))
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user