From 86593beaa40035a10a664d3147327a01f4885cb7 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Tue, 31 Aug 2021 23:49:43 +0100 Subject: feat(eval/method): partially port v8.1.1954 Does not include listener_*() functions. js_*() functions are N/A. json_encode() and json_decode() didn't include tests; add some anyway (to json_functions_spec.lua). test_lua.vim isn't included yet, so add tests to luaeval_spec.lua. --- test/functional/vimscript/json_functions_spec.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'test/functional/vimscript/json_functions_spec.lua') diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua index c3b607b544..5d1597f53d 100644 --- a/test/functional/vimscript/json_functions_spec.lua +++ b/test/functional/vimscript/json_functions_spec.lua @@ -168,7 +168,8 @@ describe('json_decode() function', function() end) it('parses floating-point numbers', function() - eq('100000.0', eval('string(json_decode("100000.0"))')) + -- Also test method call (->) syntax + eq('100000.0', eval('"100000.0"->json_decode()->string()')) eq(100000.5, funcs.json_decode('100000.5')) eq(-100000.5, funcs.json_decode('-100000.5')) eq(-100000.5e50, funcs.json_decode('-100000.5e50')) @@ -549,11 +550,12 @@ describe('json_encode() function', function() end) it('dumps floats', function() - eq('0.0', eval('json_encode(0.0)')) + -- Also test method call (->) syntax + eq('0.0', eval('0.0->json_encode()')) eq('10.5', funcs.json_encode(10.5)) eq('-10.5', funcs.json_encode(-10.5)) eq('-1.0e-5', funcs.json_encode(-1e-5)) - eq('1.0e50', eval('json_encode(1.0e50)')) + eq('1.0e50', eval('1.0e50->json_encode()')) end) it('fails to dump NaN and infinite values', function() -- cgit