aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript/json_functions_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/vimscript/json_functions_spec.lua')
-rw-r--r--test/functional/vimscript/json_functions_spec.lua32
1 files changed, 6 insertions, 26 deletions
diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua
index ae56e8873d..c6e0e75bdc 100644
--- a/test/functional/vimscript/json_functions_spec.lua
+++ b/test/functional/vimscript/json_functions_spec.lua
@@ -502,9 +502,9 @@ describe('json_decode() function', function()
end
it('parses strings with NUL properly', function()
- sp_decode_eq({ _TYPE = 'string', _VAL = { '\n' } }, '"\\u0000"')
- sp_decode_eq({ _TYPE = 'string', _VAL = { '\n', '\n' } }, '"\\u0000\\n\\u0000"')
- sp_decode_eq({ _TYPE = 'string', _VAL = { '\n«\n' } }, '"\\u0000\\u00AB\\u0000"')
+ sp_decode_eq('\000', '"\\u0000"')
+ sp_decode_eq('\000\n\000', '"\\u0000\\n\\u0000"')
+ sp_decode_eq('\000«\000', '"\\u0000\\u00AB\\u0000"')
end)
it('parses dictionaries with duplicate keys to special maps', function()
@@ -580,14 +580,8 @@ describe('json_decode() function', function()
end)
it('parses dictionaries with keys with NUL bytes to special maps', function()
- sp_decode_eq(
- { _TYPE = 'map', _VAL = { { { _TYPE = 'string', _VAL = { 'a\n', 'b' } }, 4 } } },
- '{"a\\u0000\\nb": 4}'
- )
- sp_decode_eq(
- { _TYPE = 'map', _VAL = { { { _TYPE = 'string', _VAL = { 'a\n', 'b', '' } }, 4 } } },
- '{"a\\u0000\\nb\\n": 4}'
- )
+ sp_decode_eq({ _TYPE = 'map', _VAL = { { 'a\000\nb', 4 } } }, '{"a\\u0000\\nb": 4}')
+ sp_decode_eq({ _TYPE = 'map', _VAL = { { 'a\000\nb\n', 4 } } }, '{"a\\u0000\\nb\\n": 4}')
sp_decode_eq({
_TYPE = 'map',
_VAL = {
@@ -595,10 +589,7 @@ describe('json_decode() function', function()
{ 'a', 1 },
{ 'c', 4 },
{ 'd', 2 },
- {
- { _TYPE = 'string', _VAL = { '\n' } },
- 4,
- },
+ { '\000', 4 },
},
}, '{"b": 3, "a": 1, "c": 4, "d": 2, "\\u0000": 4}')
end)
@@ -738,22 +729,11 @@ describe('json_encode() function', function()
eq('{"\\u0000": 1}', eval('json_encode(todump)'))
end)
- it('can dump generic mapping with BIN special key and NUL', function()
- command('let todump = {"_TYPE": v:msgpack_types.binary, "_VAL": ["\\n"]}')
- command('let todump = {"_TYPE": v:msgpack_types.map, "_VAL": [[todump, 1]]}')
- eq('{"\\u0000": 1}', eval('json_encode(todump)'))
- end)
-
it('can dump STR special mapping with NUL and NL', function()
command('let todump = {"_TYPE": v:msgpack_types.string, "_VAL": ["\\n", ""]}')
eq('"\\u0000\\n"', eval('json_encode(todump)'))
end)
- it('can dump BIN special mapping with NUL and NL', function()
- command('let todump = {"_TYPE": v:msgpack_types.binary, "_VAL": ["\\n", ""]}')
- eq('"\\u0000\\n"', eval('json_encode(todump)'))
- end)
-
it('cannot dump special ext mapping', function()
command('let todump = {"_TYPE": v:msgpack_types.ext, "_VAL": [5, ["",""]]}')
eq('Vim(call):E474: Unable to convert EXT string to JSON', exc_exec('call json_encode(todump)'))