mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 05:48:17 +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:
@@ -784,4 +784,16 @@ describe('json_encode() function', function()
|
||||
eq([["\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000B\f\r\u000E\u000F\u0010\u0011\u0012\u0013"]],
|
||||
eval('json_encode({"_TYPE": v:msgpack_types.string, "_VAL": ["\n\1\2\3\4\5\6\7\8\9", "\11\12\13\14\15\16\17\18\19"]})'))
|
||||
end)
|
||||
|
||||
it('can dump NULL string', function()
|
||||
eq('""', eval('json_encode($XXX_UNEXISTENT_VAR_XXX)'))
|
||||
end)
|
||||
|
||||
it('can dump NULL list', function()
|
||||
eq('[]', eval('json_encode(v:_null_list)'))
|
||||
end)
|
||||
|
||||
it('can dump NULL dictionary', function()
|
||||
eq('{}', eval('json_encode(v:_null_dict)'))
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user