mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
eval/encode: Make sure that encoder can encode NULL variables
Adds two undocumented v: variables: _null_list and _null_dict because I do not know a reproducible way to get such lists (though I think I heard about this) and dictionaries (do not remember hearing about them). NULL strings are obtained using $XXX_UNEXISTENT_VAR_XXX. Fixes crash in json_encode($XXX_UNEXISTENT_VAR_XXX). Other added tests worked fine before this commit.
This commit is contained in:
@@ -686,4 +686,18 @@ describe('msgpackdump() function', function()
|
||||
exc_exec('call msgpackdump(' .. val .. ')'))
|
||||
end
|
||||
end)
|
||||
|
||||
it('can dump NULL string', function()
|
||||
eq({'\196\n'}, eval('msgpackdump([$XXX_UNEXISTENT_VAR_XXX])'))
|
||||
eq({'\196\n'}, eval('msgpackdump([{"_TYPE": v:msgpack_types.binary, "_VAL": [$XXX_UNEXISTENT_VAR_XXX]}])'))
|
||||
eq({'\160'}, eval('msgpackdump([{"_TYPE": v:msgpack_types.string, "_VAL": [$XXX_UNEXISTENT_VAR_XXX]}])'))
|
||||
end)
|
||||
|
||||
it('can dump NULL list', function()
|
||||
eq({'\144'}, eval('msgpackdump([v:_null_list])'))
|
||||
end)
|
||||
|
||||
it('can dump NULL dictionary', function()
|
||||
eq({'\128'}, eval('msgpackdump([v:_null_dict])'))
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user