aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/lua')
-rw-r--r--test/functional/lua/vim_spec.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index a739992611..419b96a572 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -996,6 +996,9 @@ describe('lua stdlib', function()
vim.g.to_delete = nil
]]
eq(NIL, funcs.luaeval "vim.g.to_delete")
+
+ matches([[^Error executing lua: .*: attempt to index .* nil value]],
+ pcall_err(exec_lua, 'return vim.g[0].testing'))
end)
it('vim.b', function()
@@ -1005,18 +1008,25 @@ describe('lua stdlib', function()
vim.api.nvim_buf_set_var(0, "floaty", 5120.1)
vim.api.nvim_buf_set_var(0, "nullvar", vim.NIL)
vim.api.nvim_buf_set_var(0, "to_delete", {hello="world"})
+ BUF = vim.api.nvim_create_buf(false, true)
+ vim.api.nvim_buf_set_var(BUF, "testing", "bye")
]]
eq('hi', funcs.luaeval "vim.b.testing")
+ eq('bye', funcs.luaeval "vim.b[BUF].testing")
eq(123, funcs.luaeval "vim.b.other")
eq(5120.1, funcs.luaeval "vim.b.floaty")
eq(NIL, funcs.luaeval "vim.b.nonexistant")
+ eq(NIL, funcs.luaeval "vim.b[BUF].nonexistant")
eq(NIL, funcs.luaeval "vim.b.nullvar")
-- lost over RPC, so test locally:
eq({false, true}, exec_lua [[
return {vim.b.nonexistant == vim.NIL, vim.b.nullvar == vim.NIL}
]])
+ matches([[^Error executing lua: .*: attempt to index .* nil value]],
+ pcall_err(exec_lua, 'return vim.b[BUF][0].testing'))
+
eq({hello="world"}, funcs.luaeval "vim.b.to_delete")
exec_lua [[
vim.b.to_delete = nil
@@ -1037,11 +1047,22 @@ describe('lua stdlib', function()
vim.api.nvim_win_set_var(0, "testing", "hi")
vim.api.nvim_win_set_var(0, "other", 123)
vim.api.nvim_win_set_var(0, "to_delete", {hello="world"})
+ BUF = vim.api.nvim_create_buf(false, true)
+ WIN = vim.api.nvim_open_win(BUF, false, {
+ width=10, height=10,
+ relative='win', row=0, col=0
+ })
+ vim.api.nvim_win_set_var(WIN, "testing", "bye")
]]
eq('hi', funcs.luaeval "vim.w.testing")
+ eq('bye', funcs.luaeval "vim.w[WIN].testing")
eq(123, funcs.luaeval "vim.w.other")
eq(NIL, funcs.luaeval "vim.w.nonexistant")
+ eq(NIL, funcs.luaeval "vim.w[WIN].nonexistant")
+
+ matches([[^Error executing lua: .*: attempt to index .* nil value]],
+ pcall_err(exec_lua, 'return vim.w[WIN][0].testing'))
eq({hello="world"}, funcs.luaeval "vim.w.to_delete")
exec_lua [[
@@ -1068,6 +1089,12 @@ describe('lua stdlib', function()
eq('hi', funcs.luaeval "vim.t.testing")
eq(123, funcs.luaeval "vim.t.other")
eq(NIL, funcs.luaeval "vim.t.nonexistant")
+ eq('hi', funcs.luaeval "vim.t[0].testing")
+ eq(123, funcs.luaeval "vim.t[0].other")
+ eq(NIL, funcs.luaeval "vim.t[0].nonexistant")
+
+ matches([[^Error executing lua: .*: attempt to index .* nil value]],
+ pcall_err(exec_lua, 'return vim.t[0][0].testing'))
eq({hello="world"}, funcs.luaeval "vim.t.to_delete")
exec_lua [[
@@ -1096,6 +1123,8 @@ describe('lua stdlib', function()
eq(funcs.luaeval "vim.api.nvim_get_vvar('progpath')", funcs.luaeval "vim.v.progpath")
eq(false, funcs.luaeval "vim.v['false']")
eq(NIL, funcs.luaeval "vim.v.null")
+ matches([[^Error executing lua: .*: attempt to index .* nil value]],
+ pcall_err(exec_lua, 'return vim.v[0].progpath'))
end)
it('vim.bo', function()