2021-09-04 08:39:22 -07:00
|
|
|
-- Test suite for testing interactions with API bindings
|
2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
2021-09-04 08:39:22 -07:00
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
local clear = n.clear
|
2024-04-08 02:03:20 -07:00
|
|
|
local eq = t.eq
|
2024-04-20 08:44:13 -07:00
|
|
|
local exec_lua = n.exec_lua
|
2021-09-04 08:39:22 -07:00
|
|
|
|
|
|
|
describe('lua vim.mpack', function()
|
|
|
|
before_each(clear)
|
2021-10-30 06:59:59 -07:00
|
|
|
it('encodes vim.NIL', function()
|
2021-09-04 08:39:22 -07:00
|
|
|
eq(
|
|
|
|
{ true, true, true, true },
|
|
|
|
exec_lua [[
|
2021-10-30 06:59:59 -07:00
|
|
|
local var = vim.mpack.decode(vim.mpack.encode({33, vim.NIL, 77}))
|
2021-09-04 08:39:22 -07:00
|
|
|
return {var[1]==33, var[2]==vim.NIL, var[3]==77, var[4]==nil}
|
|
|
|
]]
|
|
|
|
)
|
|
|
|
end)
|
|
|
|
|
2021-10-30 06:59:59 -07:00
|
|
|
it('encodes vim.empty_dict()', function()
|
2021-09-04 08:39:22 -07:00
|
|
|
eq(
|
|
|
|
{ { {}, 'foo', {} }, true, false },
|
|
|
|
exec_lua [[
|
2021-10-30 06:59:59 -07:00
|
|
|
local var = vim.mpack.decode(vim.mpack.encode({{}, "foo", vim.empty_dict()}))
|
2024-04-21 06:19:43 -07:00
|
|
|
return {var, vim.islist(var[1]), vim.islist(var[3])}
|
2021-09-04 08:39:22 -07:00
|
|
|
]]
|
|
|
|
)
|
|
|
|
end)
|
|
|
|
end)
|