diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-05-13 15:06:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-13 15:06:41 +0200 |
commit | 244a1f97db6da0441607754dab9ae11096bffd9e (patch) | |
tree | 5ba7ce5425f2bfce681b3bcbe318363bf872e450 /test/functional/api/vim_spec.lua | |
parent | ac47f8a50691e6ce99c54712e5c984db8b1f079e (diff) | |
parent | f424189093ab23fb727a996d317ff19d4d3f0b63 (diff) | |
download | rneovim-244a1f97db6da0441607754dab9ae11096bffd9e.tar.gz rneovim-244a1f97db6da0441607754dab9ae11096bffd9e.tar.bz2 rneovim-244a1f97db6da0441607754dab9ae11096bffd9e.zip |
Merge pull request #6704 from bfredl/luaexec
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>") |