aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/msgpack_functions_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2016-04-04 04:53:07 +0300
committerZyX <kp-pav@yandex.ru>2016-04-18 02:48:20 +0300
commitbda0165514a582978c2da672b528562df78a2d1a (patch)
tree0077fb7bb71acb3c1de99324cd6f4f7af153dbd5 /test/functional/eval/msgpack_functions_spec.lua
parentc4f1b5a9383c00e0a23fdfdca096c569f05e8a1c (diff)
downloadrneovim-bda0165514a582978c2da672b528562df78a2d1a.tar.gz
rneovim-bda0165514a582978c2da672b528562df78a2d1a.tar.bz2
rneovim-bda0165514a582978c2da672b528562df78a2d1a.zip
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.
Diffstat (limited to 'test/functional/eval/msgpack_functions_spec.lua')
-rw-r--r--test/functional/eval/msgpack_functions_spec.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/functional/eval/msgpack_functions_spec.lua b/test/functional/eval/msgpack_functions_spec.lua
index a602bad86f..9e501353a5 100644
--- a/test/functional/eval/msgpack_functions_spec.lua
+++ b/test/functional/eval/msgpack_functions_spec.lua
@@ -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)