diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-05-09 08:55:04 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2017-05-13 15:03:42 +0200 |
commit | f424189093ab23fb727a996d317ff19d4d3f0b63 (patch) | |
tree | 582a5a9a74a8a4f32c4fc0a9dea165efc3490089 /test/functional/api/vim_spec.lua | |
parent | 12fb634fe691a6ccfbd9bc7b44510c782af6c70a (diff) | |
download | rneovim-f424189093ab23fb727a996d317ff19d4d3f0b63.tar.gz rneovim-f424189093ab23fb727a996d317ff19d4d3f0b63.tar.bz2 rneovim-f424189093ab23fb727a996d317ff19d4d3f0b63.zip |
api: execute lua directly from the remote api
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r-- | test/functional/api/vim_spec.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 282ecbfd87..61ec6ea829 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -81,6 +81,36 @@ describe('api', function() end) end) + describe('nvim_execute_lua', function() + it('works', function() + meths.execute_lua('vim.api.nvim_set_var("test", 3)', {}) + eq(3, meths.get_var('test')) + + eq(17, meths.execute_lua('a, b = ...\nreturn a + b', {10,7})) + + eq(NIL, meths.execute_lua('function xx(a,b)\nreturn a..b\nend',{})) + eq("xy", meths.execute_lua('return xx(...)', {'x','y'})) + end) + + it('reports errors', function() + eq({false, 'Error loading lua: [string "<nvim>"]:1: '.. + "'=' expected near '+'"}, + meth_pcall(meths.execute_lua, 'a+*b', {})) + + eq({false, 'Error loading lua: [string "<nvim>"]:1: '.. + "unexpected symbol near '1'"}, + meth_pcall(meths.execute_lua, '1+2', {})) + + eq({false, 'Error loading lua: [string "<nvim>"]:1: '.. + "unexpected symbol"}, + meth_pcall(meths.execute_lua, 'aa=bb\0', {})) + + eq({false, 'Error executing lua: [string "<nvim>"]:1: '.. + "attempt to call global 'bork' (a nil value)"}, + meth_pcall(meths.execute_lua, 'bork()', {})) + end) + end) + describe('nvim_input', function() it("VimL error: does NOT fail, updates v:errmsg", function() local status, _ = pcall(nvim, "input", ":call bogus_fn()<CR>") |