mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +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:
@@ -84,6 +84,18 @@ describe('string() function', function()
|
||||
eq('\'\'\'b\'\'\'\'d\'', funcs.string('\'b\'\'d'))
|
||||
eq('\'a\'\'b\'\'c\'\'d\'', funcs.string('a\'b\'c\'d'))
|
||||
end)
|
||||
|
||||
it('dumps NULL strings', function()
|
||||
eq('\'\'', eval('string($XXX_UNEXISTENT_VAR_XXX)'))
|
||||
end)
|
||||
|
||||
it('dumps NULL lists', function()
|
||||
eq('[]', eval('string(v:_null_list)'))
|
||||
end)
|
||||
|
||||
it('dumps NULL dictionaries', function()
|
||||
eq('{}', eval('string(v:_null_dict)'))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('used to represent funcrefs', function()
|
||||
|
Reference in New Issue
Block a user