mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
test: typing for helpers.meths
This commit is contained in:
@ -67,17 +67,17 @@ describe('luaeval()', function()
|
||||
describe('strings with NULs', function()
|
||||
it('are successfully converted to blobs', function()
|
||||
command([[let s = luaeval('"\0"')]])
|
||||
eq('\000', meths.get_var('s'))
|
||||
eq('\000', meths.nvim_get_var('s'))
|
||||
end)
|
||||
it('are successfully converted to special dictionaries in table keys', function()
|
||||
command([[let d = luaeval('{["\0"]=1}')]])
|
||||
eq({_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n'}}, 1}}}, meths.get_var('d'))
|
||||
eq({_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n'}}, 1}}}, meths.nvim_get_var('d'))
|
||||
eq(1, funcs.eval('d._TYPE is v:msgpack_types.map'))
|
||||
eq(1, funcs.eval('d._VAL[0][0]._TYPE is v:msgpack_types.string'))
|
||||
end)
|
||||
it('are successfully converted to blobs from a list', function()
|
||||
command([[let l = luaeval('{"abc", "a\0b", "c\0d", "def"}')]])
|
||||
eq({'abc', 'a\000b', 'c\000d', 'def'}, meths.get_var('l'))
|
||||
eq({'abc', 'a\000b', 'c\000d', 'def'}, meths.nvim_get_var('l'))
|
||||
end)
|
||||
end)
|
||||
|
||||
@ -411,14 +411,14 @@ describe('luaeval()', function()
|
||||
end)
|
||||
|
||||
it('correctly converts self-containing containers', function()
|
||||
meths.set_var('l', {})
|
||||
meths.nvim_set_var('l', {})
|
||||
eval('add(l, l)')
|
||||
eq(true, eval('luaeval("_A == _A[1]", l)'))
|
||||
eq(true, eval('luaeval("_A[1] == _A[1][1]", [l])'))
|
||||
eq(true, eval('luaeval("_A.d == _A.d[1]", {"d": l})'))
|
||||
eq(true, eval('luaeval("_A ~= _A[1]", [l])'))
|
||||
|
||||
meths.set_var('d', {foo=42})
|
||||
meths.nvim_set_var('d', {foo=42})
|
||||
eval('extend(d, {"d": d})')
|
||||
eq(true, eval('luaeval("_A == _A.d", d)'))
|
||||
eq(true, eval('luaeval("_A[1] == _A[1].d", [d])'))
|
||||
@ -478,7 +478,7 @@ describe('v:lua', function()
|
||||
eq(7, eval('v:lua.foo(3,4,v:null)'))
|
||||
eq(true, exec_lua([[return _G.val == vim.NIL]]))
|
||||
eq(NIL, eval('v:lua.mymod.noisy("eval")'))
|
||||
eq("hey eval", meths.get_current_line())
|
||||
eq("hey eval", meths.nvim_get_current_line())
|
||||
eq("string: abc", eval('v:lua.mymod.whatis(0z616263)'))
|
||||
eq("string: ", eval('v:lua.mymod.whatis(v:_null_blob)'))
|
||||
|
||||
@ -494,7 +494,7 @@ describe('v:lua', function()
|
||||
eq("boop", exec_lua([[return _G.val]]))
|
||||
|
||||
eq(NIL, eval('"there"->v:lua.mymod.noisy()'))
|
||||
eq("hey there", meths.get_current_line())
|
||||
eq("hey there", meths.nvim_get_current_line())
|
||||
eq({5, 10, 15, 20}, eval('[[1], [2, 3], [4]]->v:lua.vim.tbl_flatten()->map({_, v -> v * 5})'))
|
||||
|
||||
eq("Vim:E5108: Error executing lua [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)",
|
||||
@ -503,7 +503,7 @@ describe('v:lua', function()
|
||||
|
||||
it('works in :call', function()
|
||||
command(":call v:lua.mymod.noisy('command')")
|
||||
eq("hey command", meths.get_current_line())
|
||||
eq("hey command", meths.nvim_get_current_line())
|
||||
eq("Vim(call):E5108: Error executing lua [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)",
|
||||
pcall_err(command, 'call v:lua.mymod.crashy()'))
|
||||
end)
|
||||
@ -518,7 +518,7 @@ describe('v:lua', function()
|
||||
[5] = {bold = true, foreground = Screen.colors.SeaGreen4},
|
||||
})
|
||||
screen:attach()
|
||||
meths.set_option_value('omnifunc', 'v:lua.mymod.omni', {})
|
||||
meths.nvim_set_option_value('omnifunc', 'v:lua.mymod.omni', {})
|
||||
feed('isome st<c-x><c-o>')
|
||||
screen:expect{grid=[[
|
||||
some stuff^ |
|
||||
@ -528,9 +528,9 @@ describe('v:lua', function()
|
||||
{1:~ }|*3
|
||||
{4:-- Omni completion (^O^N^P) }{5:match 1 of 3} |
|
||||
]]}
|
||||
meths.set_option_value('operatorfunc', 'v:lua.mymod.noisy', {})
|
||||
meths.nvim_set_option_value('operatorfunc', 'v:lua.mymod.noisy', {})
|
||||
feed('<Esc>g@g@')
|
||||
eq("hey line", meths.get_current_line())
|
||||
eq("hey line", meths.nvim_get_current_line())
|
||||
end)
|
||||
|
||||
it('supports packages', function()
|
||||
|
Reference in New Issue
Block a user