diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-07-01 15:50:57 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2019-07-01 18:44:58 +0200 |
commit | 6ee05536ca2668b8d45103a63be38b1de698c4a9 (patch) | |
tree | fcbaeedf66c77ff67c906f10b6ea29c5bd3bf733 /test/functional/api/vim_spec.lua | |
parent | 740fb337dd8c63b63db186057fca2994b92ddbf5 (diff) | |
download | rneovim-6ee05536ca2668b8d45103a63be38b1de698c4a9.tar.gz rneovim-6ee05536ca2668b8d45103a63be38b1de698c4a9.tar.bz2 rneovim-6ee05536ca2668b8d45103a63be38b1de698c4a9.zip |
api/lua: make nvim_execute_lua use native lua floats, not special tables
Rationale: the purpose of nvim_execute_lua is to simply call lua code with lua
values. If a lua function expects a floating point value, it should be enough
to specify a float as argument to nvim_execute_lua.
However, make sure to preserve the existing roundtripping behavior of
API values when using `vim.api` functions. This is covered by existing
lua/api_spec.lua tests.
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r-- | test/functional/api/vim_spec.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 4279a5d420..a3d57662b3 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -339,6 +339,15 @@ describe('API', function() "did\nthe\nfail"}, meth_pcall(meths.execute_lua, 'error("did\\nthe\\nfail")', {})) end) + + it('uses native float values', function() + eq(2.5, meths.execute_lua("return select(1, ...)", {2.5})) + eq("2.5", meths.execute_lua("return vim.inspect(...)", {2.5})) + + -- "special" float values are still accepted as return values. + eq(2.5, meths.execute_lua("return vim.api.nvim_eval('2.5')", {})) + eq("{\n [false] = 2.5,\n [true] = 3\n}", meths.execute_lua("return vim.inspect(vim.api.nvim_eval('2.5'))", {})) + end) end) describe('nvim_input', function() |