diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-09-03 22:51:45 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-09-06 17:19:07 -0700 |
commit | af946046b922dc5d5285a70a23d11916d8389a5d (patch) | |
tree | 090d68a1dd675b5ad6e99abc829be0daafe2a7d9 /test/functional/lua/utility_functions_spec.lua | |
parent | 638f2b6dee7439de303bea12dec80240617e8034 (diff) | |
download | rneovim-af946046b922dc5d5285a70a23d11916d8389a5d.tar.gz rneovim-af946046b922dc5d5285a70a23d11916d8389a5d.tar.bz2 rneovim-af946046b922dc5d5285a70a23d11916d8389a5d.zip |
test: Rename meth_pcall to pcall_err
- Rename `meth_pcall`.
- Make `pcall_err` raise an error if the function does not fail.
- Add `vim.pesc()` to treat a string as literal where a Lua pattern is
expected.
Diffstat (limited to 'test/functional/lua/utility_functions_spec.lua')
-rw-r--r-- | test/functional/lua/utility_functions_spec.lua | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/test/functional/lua/utility_functions_spec.lua b/test/functional/lua/utility_functions_spec.lua index ff15ebf8b3..ea2b1fc8a9 100644 --- a/test/functional/lua/utility_functions_spec.lua +++ b/test/functional/lua/utility_functions_spec.lua @@ -7,12 +7,12 @@ local clear = helpers.clear local eq = helpers.eq local eval = helpers.eval local feed = helpers.feed -local meth_pcall = helpers.meth_pcall +local pcall_err = helpers.pcall_err local exec_lua = helpers.exec_lua before_each(clear) -describe('lua function', function() +describe('lua stdlib', function() -- İ: `tolower("İ")` is `i` which has length 1 while `İ` itself has -- length 2 (in bytes). -- Ⱥ: `tolower("Ⱥ")` is `ⱥ` which has length 2 while `Ⱥ` itself has @@ -147,11 +147,11 @@ describe('lua function', function() eq({"yy","xx"}, exec_lua("return test_table")) -- type checked args - eq({false, 'Error executing lua: vim.schedule: expected function'}, - meth_pcall(exec_lua, "vim.schedule('stringly')")) + eq('Error executing lua: vim.schedule: expected function', + pcall_err(exec_lua, "vim.schedule('stringly')")) - eq({false, 'Error executing lua: vim.schedule: expected function'}, - meth_pcall(exec_lua, "vim.schedule()")) + eq('Error executing lua: vim.schedule: expected function', + pcall_err(exec_lua, "vim.schedule()")) exec_lua([[ vim.schedule(function() @@ -283,4 +283,9 @@ describe('lua function', function() assert(is_dc) end) + + it('vim.pesc', function() + eq('foo%-bar', exec_lua([[return vim.pesc('foo-bar')]])) + eq('foo%%%-bar', exec_lua([[return vim.pesc(vim.pesc('foo-bar'))]])) + end) end) |