diff options
author | Lewis Russell <lewis6991@gmail.com> | 2022-11-14 10:01:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-14 10:01:35 +0000 |
commit | e8cc489accc435076afb4fdf89778b64f0a48473 (patch) | |
tree | 78b5a74c13cefb916752f25cf42e301a400fcab2 /test/functional/lua | |
parent | 5c5187c6f809c50e2cfd0ba04961ae8e0d2dabd0 (diff) | |
download | rneovim-e8cc489accc435076afb4fdf89778b64f0a48473.tar.gz rneovim-e8cc489accc435076afb4fdf89778b64f0a48473.tar.bz2 rneovim-e8cc489accc435076afb4fdf89778b64f0a48473.zip |
feat(test): add Lua forms for API methods (#20152)
Diffstat (limited to 'test/functional/lua')
-rw-r--r-- | test/functional/lua/diagnostic_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/lua/spell_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/lua/thread_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/lua/vim_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/lua/xdiff_spec.lua | 18 |
5 files changed, 16 insertions, 14 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua index 28a8679205..565243d5a0 100644 --- a/test/functional/lua/diagnostic_spec.lua +++ b/test/functional/lua/diagnostic_spec.lua @@ -1776,7 +1776,7 @@ end) return lines ]]) - eq("Error executing lua: .../diagnostic.lua:0: prefix: expected 'string' or 'table' or 'function', got 42", + eq(".../diagnostic.lua:0: prefix: expected 'string' or 'table' or 'function', got 42", pcall_err(exec_lua, [[ vim.diagnostic.open_float({ prefix = 42 }) ]])) end) diff --git a/test/functional/lua/spell_spec.lua b/test/functional/lua/spell_spec.lua index 7e831f16a7..b3de6a0912 100644 --- a/test/functional/lua/spell_spec.lua +++ b/test/functional/lua/spell_spec.lua @@ -15,7 +15,7 @@ describe('vim.spell', function() end it('can handle nil', function() - eq([[Error executing lua: [string "<nvim>"]:0: bad argument #1 to 'check' (expected string)]], + eq([[bad argument #1 to 'check' (expected string)]], pcall_err(exec_lua, [[vim.spell.check(nil)]])) end) diff --git a/test/functional/lua/thread_spec.lua b/test/functional/lua/thread_spec.lua index e183ce3a57..c7f2783cf3 100644 --- a/test/functional/lua/thread_spec.lua +++ b/test/functional/lua/thread_spec.lua @@ -272,7 +272,7 @@ describe('threadpool', function() work:queue({}) ]]) - eq([[Error executing lua: [string "<nvim>"]:0: Error: thread arg not support type 'function' at 1]], + eq([[Error: thread arg not support type 'function' at 1]], status) end) diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 38f772c5cf..6d0d87746c 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -168,8 +168,8 @@ describe('lua stdlib', function() for i,k in pairs(indicies16) do eq(k, exec_lua("return vim.str_byteindex(_G.test_text, ..., true)", i), i) end - matches(": index out of range$", pcall_err(exec_lua, "return vim.str_byteindex(_G.test_text, ...)", #indicies32 + 1)) - matches(": index out of range$", pcall_err(exec_lua, "return vim.str_byteindex(_G.test_text, ..., true)", #indicies16 + 1)) + eq("index out of range", pcall_err(exec_lua, "return vim.str_byteindex(_G.test_text, ...)", #indicies32 + 1)) + eq("index out of range", pcall_err(exec_lua, "return vim.str_byteindex(_G.test_text, ..., true)", #indicies16 + 1)) local i32, i16 = 0, 0 local len = 51 for k = 0,len do @@ -184,7 +184,7 @@ describe('lua stdlib', function() end eq({i32, i16}, exec_lua("return {vim.str_utfindex(_G.test_text, ...)}", k), k) end - matches(": index out of range$", pcall_err(exec_lua, "return vim.str_utfindex(_G.test_text, ...)", len + 1)) + eq("index out of range", pcall_err(exec_lua, "return vim.str_utfindex(_G.test_text, ...)", len + 1)) end) it("vim.str_utf_start", function() diff --git a/test/functional/lua/xdiff_spec.lua b/test/functional/lua/xdiff_spec.lua index d55268fc78..3121ac051f 100644 --- a/test/functional/lua/xdiff_spec.lua +++ b/test/functional/lua/xdiff_spec.lua @@ -74,11 +74,13 @@ describe('xdiff bindings', function() end) it('with error callback', function() - exec_lua([[on_hunk = function(sa, ca, sb, cb) + exec_lua[[ + on_hunk = function(sa, ca, sb, cb) error('ERROR1') - end]]) + end + ]] - eq([[Error executing lua: [string "<nvim>"]:0: error running function on_hunk: [string "<nvim>"]:0: ERROR1]], + eq([[error running function on_hunk: [string "<nvim>"]:0: ERROR1]], pcall_err(exec_lua, [[vim.diff(a1, b1, {on_hunk = on_hunk})]])) end) @@ -135,19 +137,19 @@ describe('xdiff bindings', function() end) it('can handle bad args', function() - eq([[Error executing lua: [string "<nvim>"]:0: Expected at least 2 arguments]], + eq([[Expected at least 2 arguments]], pcall_err(exec_lua, [[vim.diff('a')]])) - eq([[Error executing lua: [string "<nvim>"]:0: bad argument #1 to 'diff' (expected string)]], + eq([[bad argument #1 to 'diff' (expected string)]], pcall_err(exec_lua, [[vim.diff(1, 2)]])) - eq([[Error executing lua: [string "<nvim>"]:0: bad argument #3 to 'diff' (expected table)]], + eq([[bad argument #3 to 'diff' (expected table)]], pcall_err(exec_lua, [[vim.diff('a', 'b', true)]])) - eq([[Error executing lua: [string "<nvim>"]:0: unexpected key: bad_key]], + eq([[unexpected key: bad_key]], pcall_err(exec_lua, [[vim.diff('a', 'b', { bad_key = true })]])) - eq([[Error executing lua: [string "<nvim>"]:0: on_hunk is not a function]], + eq([[on_hunk is not a function]], pcall_err(exec_lua, [[vim.diff('a', 'b', { on_hunk = true })]])) end) |