diff options
Diffstat (limited to 'test/functional/lua')
-rw-r--r-- | test/functional/lua/api_spec.lua | 11 | ||||
-rw-r--r-- | test/functional/lua/spell_spec.lua | 53 | ||||
-rw-r--r-- | test/functional/lua/uri_spec.lua | 6 |
3 files changed, 66 insertions, 4 deletions
diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua index 81e00bba6d..f6038e23fe 100644 --- a/test/functional/lua/api_spec.lua +++ b/test/functional/lua/api_spec.lua @@ -8,6 +8,7 @@ local clear = helpers.clear local eval = helpers.eval local NIL = helpers.NIL local eq = helpers.eq +local exec_lua = helpers.exec_lua before_each(clear) @@ -111,6 +112,12 @@ describe('luaeval(vim.api.…)', function() eq(7, eval([[type(luaeval('vim.api.nvim__id(nil)'))]])) eq({foo=1, bar={42, {{baz=true}, 5}}}, funcs.luaeval('vim.api.nvim__id({foo=1, bar={42, {{baz=true}, 5}}})')) + + eq(true, funcs.luaeval('vim.api.nvim__id(vim.api.nvim__id)(true)')) + eq(42, exec_lua [[ + local f = vim.api.nvim__id({42, vim.api.nvim__id}) + return f[2](f[1]) + ]]) end) it('correctly converts container objects with type_idx to API objects', function() @@ -159,12 +166,8 @@ describe('luaeval(vim.api.…)', function() it('errors out correctly when working with API', function() -- Conversion errors - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Cannot convert given lua type', - remove_trace(exc_exec([[call luaeval("vim.api.nvim__id(vim.api.nvim__id)")]]))) eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Cannot convert given lua table', remove_trace(exc_exec([[call luaeval("vim.api.nvim__id({1, foo=42})")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Cannot convert given lua type', - remove_trace(exc_exec([[call luaeval("vim.api.nvim__id({42, vim.api.nvim__id})")]]))) -- Errors in number of arguments eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected 1 argument', remove_trace(exc_exec([[call luaeval("vim.api.nvim__id()")]]))) diff --git a/test/functional/lua/spell_spec.lua b/test/functional/lua/spell_spec.lua new file mode 100644 index 0000000000..7e831f16a7 --- /dev/null +++ b/test/functional/lua/spell_spec.lua @@ -0,0 +1,53 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear +local exec_lua = helpers.exec_lua +local eq = helpers.eq +local pcall_err = helpers.pcall_err + +describe('vim.spell', function() + before_each(function() + clear() + end) + + describe('.check', function() + local check = function(x, exp) + return eq(exp, exec_lua("return vim.spell.check(...)", x)) + end + + it('can handle nil', function() + eq([[Error executing lua: [string "<nvim>"]:0: bad argument #1 to 'check' (expected string)]], + pcall_err(exec_lua, [[vim.spell.check(nil)]])) + end) + + it('can check spellings', function() + check('hello', {}) + + check( + 'helloi', + {{"helloi", "bad", 1}} + ) + + check( + 'hello therei', + {{"therei", "bad", 7}} + ) + + check( + 'hello. there', + {{"there", "caps", 8}} + ) + + check( + 'neovim cna chkc spellins. okay?', + { + {"neovim" , "bad" , 1}, + {"cna" , "bad" , 8}, + {"chkc" , "bad" , 12}, + {"spellins", "bad" , 17}, + {"okay" , "caps", 27} + } + ) + end) + + end) +end) diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua index dbfbe2dbfe..fa11fdf794 100644 --- a/test/functional/lua/uri_spec.lua +++ b/test/functional/lua/uri_spec.lua @@ -155,6 +155,12 @@ describe('URI methods', function() return pcall(vim.uri_to_fname, 'not_an_uri.txt') ]]) end) + + it('uri_to_fname should not treat comma as a scheme character', function() + eq(false, exec_lua [[ + return pcall(vim.uri_to_fname, 'foo,://bar') + ]]) + end) end) end) |