mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
refactor(typval)!: remove distinction of binary and nonbinary strings
This is a breaking change which will make refactor of typval and shada code a lot easier. In particular, code that would use or check for v:msgpack_types.binary in the wild would be broken. This appears to be rarely used in existing plugins. Also some cases where v:msgpack_type.string would be used to represent a binary string of "string" type, we use a BLOB instead, which is vimscripts native type for binary blobs, and already was used for BIN formats when necessary. msgpackdump(msgpackparse(data)) no longer preserves the distinction of BIN and STR strings. This is very common behavior for language-specific msgpack bindings. Nvim uses msgpack as a tool to serialize its data. Nvim is not a tool to bit-perfectly manipulate arbitrary msgpack data out in the wild. The changed tests should indicate how behavior changes in various edge cases.
This commit is contained in:
@@ -72,9 +72,9 @@ describe('luaeval()', function()
|
||||
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}}}, api.nvim_get_var('d'))
|
||||
eq({_TYPE={}, _VAL={{'\000', 1}}}, api.nvim_get_var('d'))
|
||||
eq(1, fn.eval('d._TYPE is v:msgpack_types.map'))
|
||||
eq(1, fn.eval('d._VAL[0][0]._TYPE is v:msgpack_types.string'))
|
||||
eq(eval('v:t_blob'), fn.eval('type(d._VAL[0][0])'))
|
||||
end)
|
||||
it('are successfully converted to blobs from a list', function()
|
||||
command([[let l = luaeval('{"abc", "a\0b", "c\0d", "def"}')]])
|
||||
@@ -125,11 +125,11 @@ describe('luaeval()', function()
|
||||
local level = 30
|
||||
eq(nested_by_level[level].o, fn.luaeval(nested_by_level[level].s))
|
||||
|
||||
eq({_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n', '\n'}}, '\000\n\000\000'}}},
|
||||
eq({_TYPE={}, _VAL={{'\000\n\000', '\000\n\000\000'}}},
|
||||
fn.luaeval([[{['\0\n\0']='\0\n\0\0'}]]))
|
||||
eq(1, eval([[luaeval('{["\0\n\0"]="\0\n\0\0"}')._TYPE is v:msgpack_types.map]]))
|
||||
eq(1, eval([[luaeval('{["\0\n\0"]="\0\n\0\0"}')._VAL[0][0]._TYPE is v:msgpack_types.string]]))
|
||||
eq({nested={{_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n', '\n'}}, '\000\n\000\000'}}}}},
|
||||
eq(eval("v:t_blob"), eval([[type(luaeval('{["\0\n\0"]="\0\n\0\0"}')._VAL[0][0])]]))
|
||||
eq({nested={{_TYPE={}, _VAL={{'\000\n\000', '\000\n\000\000'}}}}},
|
||||
fn.luaeval([[{nested={{['\0\n\0']='\0\n\0\0'}}}]]))
|
||||
end)
|
||||
|
||||
@@ -177,12 +177,10 @@ describe('luaeval()', function()
|
||||
end
|
||||
|
||||
it('correctly passes special dictionaries', function()
|
||||
eq({0, '\000\n\000'}, luaevalarg(sp('binary', '["\\n", "\\n"]')))
|
||||
eq({0, '\000\n\000'}, luaevalarg(sp('string', '["\\n", "\\n"]')))
|
||||
eq({0, true}, luaevalarg(sp('boolean', 1)))
|
||||
eq({0, false}, luaevalarg(sp('boolean', 0)))
|
||||
eq({0, NIL}, luaevalarg(sp('nil', 0)))
|
||||
eq({0, {[""]=""}}, luaevalarg(mapsp(sp('binary', '[""]'), '""')))
|
||||
eq({0, {[""]=""}}, luaevalarg(mapsp(sp('string', '[""]'), '""')))
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user