diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/lua/command_line_completion_spec.lua | 82 | ||||
-rw-r--r-- | test/functional/lua/thread_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/options/defaults_spec.lua | 31 | ||||
-rw-r--r-- | test/functional/script/luacats_grammar_spec.lua | 2 |
4 files changed, 42 insertions, 75 deletions
diff --git a/test/functional/lua/command_line_completion_spec.lua b/test/functional/lua/command_line_completion_spec.lua index ae0ab19d6b..7dac7448e9 100644 --- a/test/functional/lua/command_line_completion_spec.lua +++ b/test/functional/lua/command_line_completion_spec.lua @@ -18,19 +18,19 @@ end before_each(clear) describe('nlua_expand_pat', function() - it('should complete exact matches', function() + it('completes exact matches', function() eq({ { 'exact' }, 0 }, get_completions('exact', { exact = true })) end) - it('should return empty table when nothing matches', function() + it('returns empty table when nothing matches', function() eq({ {}, 0 }, get_completions('foo', { bar = true })) end) - it('should return nice completions with function call prefix', function() + it('returns nice completions with function call prefix', function() eq({ { 'FOO' }, 6 }, get_completions('print(F', { FOO = true, bawr = true })) end) - it('should return keys for nested dictionaries', function() + it('returns keys for nested dicts', function() eq( { { 'nvim_buf_set_lines', @@ -47,7 +47,7 @@ describe('nlua_expand_pat', function() ) end) - it('it should work with colons', function() + it('with colons', function() eq( { { 'bawr', @@ -63,7 +63,7 @@ describe('nlua_expand_pat', function() ) end) - it('should return keys for string reffed dictionaries', function() + it('returns keys after string key', function() eq( { { 'nvim_buf_set_lines', @@ -78,9 +78,7 @@ describe('nlua_expand_pat', function() }, }) ) - end) - it('should return keys for string reffed dictionaries', function() eq( { { 'nvim_buf_set_lines', @@ -99,7 +97,7 @@ describe('nlua_expand_pat', function() ) end) - it('should work with lazy submodules of "vim" global', function() + it('with lazy submodules of "vim" global', function() eq({ { 'inspect', 'inspect_pos' }, 4 }, get_completions('vim.inspec')) eq({ { 'treesitter' }, 4 }, get_completions('vim.treesi')) @@ -107,7 +105,7 @@ describe('nlua_expand_pat', function() eq({ { 'set' }, 11 }, get_completions('vim.keymap.se')) end) - it('should exclude private fields after "."', function() + it('excludes private fields after "."', function() eq( { { 'bar' }, 4 }, get_completions('foo.', { @@ -119,7 +117,7 @@ describe('nlua_expand_pat', function() ) end) - it('should include private fields after "._"', function() + it('includes private fields after "._"', function() eq( { { '_bar' }, 4 }, get_completions('foo._', { @@ -131,7 +129,7 @@ describe('nlua_expand_pat', function() ) end) - it('should be able to interpolate globals', function() + it('can interpolate globals', function() eq( { { 'nvim_buf_set_lines', @@ -149,8 +147,8 @@ describe('nlua_expand_pat', function() ) end) - describe('should complete vim.fn', function() - it('correctly works for simple completion', function() + describe('vim.fn', function() + it('simple completion', function() local actual = get_completions('vim.fn.did') local expected = { { 'did_filetype' }, @@ -158,7 +156,7 @@ describe('nlua_expand_pat', function() } eq(expected, actual) end) - it('should not suggest items with #', function() + it('does not suggest "#" items', function() exec_lua [[ -- ensure remote#host#... functions exist vim.cmd [=[ @@ -176,7 +174,7 @@ describe('nlua_expand_pat', function() end) end) - describe('should complete for variable accessors for', function() + describe('completes', function() it('vim.v', function() local actual = get_completions('vim.v.t_') local expected = { @@ -240,7 +238,7 @@ describe('nlua_expand_pat', function() end) end) - describe('should complete for option accessors for', function() + describe('completes', function() -- for { vim.o, vim.go, vim.opt, vim.opt_local, vim.opt_global } local test_opt = function(accessor) do @@ -271,7 +269,7 @@ describe('nlua_expand_pat', function() test_opt('vim.opt_local') test_opt('vim.opt_global') - it('vim.o, suggesting all the known options', function() + it('vim.o, suggesting all known options', function() local completions = get_completions('vim.o.')[1] ---@type string[] eq( exec_lua [[ @@ -314,45 +312,19 @@ describe('nlua_expand_pat', function() end) end) - it('should return everything if the input is of length 0', function() + it('returns everything if input is empty', function() eq({ { 'other', 'vim' }, 0 }, get_completions('', { vim = true, other = true })) end) - describe('get_parts', function() - it('should return an empty list for no separators', function() - eq({ {}, 1 }, get_compl_parts('vim')) - end) - - it('just the first item before a period', function() - eq({ { 'vim' }, 5 }, get_compl_parts('vim.ap')) - end) - - it('should return multiple parts just for period', function() - eq({ { 'vim', 'api' }, 9 }, get_compl_parts('vim.api.nvim_buf')) - end) - - it('should be OK with colons', function() - eq({ { 'vim', 'api' }, 9 }, get_compl_parts('vim:api.nvim_buf')) - end) - - it('should work for just one string ref', function() - eq({ { 'vim', 'api' }, 12 }, get_compl_parts("vim['api'].nvim_buf")) - end) - - it('should work for just one string ref, with double quote', function() - eq({ { 'vim', 'api' }, 12 }, get_compl_parts('vim["api"].nvim_buf')) - end) - - it('should allows back-to-back string ref', function() - eq({ { 'vim', 'nested', 'api' }, 22 }, get_compl_parts('vim["nested"]["api"].nvim_buf')) - end) - - it('should allows back-to-back string ref with spaces before and after', function() - eq({ { 'vim', 'nested', 'api' }, 25 }, get_compl_parts('vim[ "nested" ]["api"].nvim_buf')) - end) - - it('should allow VAR style loolup', function() - eq({ { 'vim', { 'NESTED' }, 'api' }, 20 }, get_compl_parts('vim[NESTED]["api"].nvim_buf')) - end) + it('get_parts', function() + eq({ {}, 1 }, get_compl_parts('vim')) + eq({ { 'vim' }, 5 }, get_compl_parts('vim.ap')) + eq({ { 'vim', 'api' }, 9 }, get_compl_parts('vim.api.nvim_buf')) + eq({ { 'vim', 'api' }, 9 }, get_compl_parts('vim:api.nvim_buf')) + eq({ { 'vim', 'api' }, 12 }, get_compl_parts("vim['api'].nvim_buf")) + eq({ { 'vim', 'api' }, 12 }, get_compl_parts('vim["api"].nvim_buf')) + eq({ { 'vim', 'nested', 'api' }, 22 }, get_compl_parts('vim["nested"]["api"].nvim_buf')) + eq({ { 'vim', 'nested', 'api' }, 25 }, get_compl_parts('vim[ "nested" ]["api"].nvim_buf')) + eq({ { 'vim', { 'NESTED' }, 'api' }, 20 }, get_compl_parts('vim[NESTED]["api"].nvim_buf')) end) end) diff --git a/test/functional/lua/thread_spec.lua b/test/functional/lua/thread_spec.lua index 8ca4bdc4f5..7610886b47 100644 --- a/test/functional/lua/thread_spec.lua +++ b/test/functional/lua/thread_spec.lua @@ -19,7 +19,7 @@ describe('thread', function() screen = Screen.new(50, 10) end) - it('handle non-string error', function() + it('non-string error()', function() exec_lua [[ local thread = vim.uv.new_thread(function() error() diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index a82279e775..83d45bcf62 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -888,8 +888,9 @@ describe('stdpath()', function() os.remove(testlog) end) - -- Windows appends 'nvim-data' instead of just 'nvim' to prevent collisions - -- due to XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME being the same. + --- Windows appends 'nvim-data' instead of just 'nvim' to prevent collisions + --- due to XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME being the same. + --- @param name string local function maybe_data(name) return is_os('win') and name .. '-data' or name end @@ -898,7 +899,7 @@ describe('stdpath()', function() local statedir = maybe_data('nvim') local env_sep = is_os('win') and ';' or ':' - it('acceptance', function() + it('works', function() clear() -- Do not explicitly set any env vars. eq('nvim', fn.fnamemodify(fn.stdpath('cache'), ':t')) @@ -911,6 +912,15 @@ describe('stdpath()', function() assert_alive() -- Check for crash. #8393 end) + it('failure modes', function() + clear() + eq('Vim(call):E6100: "capybara" is not a valid stdpath', exc_exec('call stdpath("capybara")')) + eq('Vim(call):E6100: "" is not a valid stdpath', exc_exec('call stdpath("")')) + eq('Vim(call):E6100: "23" is not a valid stdpath', exc_exec('call stdpath(23)')) + eq('Vim(call):E731: Using a Dictionary as a String', exc_exec('call stdpath({"eris": 23})')) + eq('Vim(call):E730: Using a List as a String', exc_exec('call stdpath([23])')) + end) + it('$NVIM_APPNAME', function() local appname = 'NVIM_APPNAME_TEST' .. ('_'):rep(106) clear({ env = { NVIM_APPNAME = appname, NVIM_LOG_FILE = testlog } }) @@ -1263,19 +1273,4 @@ describe('stdpath()', function() }) end) end) - - describe('errors', function() - before_each(clear) - - it('on unknown strings', function() - eq('Vim(call):E6100: "capybara" is not a valid stdpath', exc_exec('call stdpath("capybara")')) - eq('Vim(call):E6100: "" is not a valid stdpath', exc_exec('call stdpath("")')) - eq('Vim(call):E6100: "23" is not a valid stdpath', exc_exec('call stdpath(23)')) - end) - - it('on non-strings', function() - eq('Vim(call):E731: Using a Dictionary as a String', exc_exec('call stdpath({"eris": 23})')) - eq('Vim(call):E730: Using a List as a String', exc_exec('call stdpath([23])')) - end) - end) end) diff --git a/test/functional/script/luacats_grammar_spec.lua b/test/functional/script/luacats_grammar_spec.lua index 2fcd0adfa4..6d1037b79c 100644 --- a/test/functional/script/luacats_grammar_spec.lua +++ b/test/functional/script/luacats_grammar_spec.lua @@ -264,7 +264,7 @@ describe('luacats grammar', function() -- generics { 'elem_or_list<string>' }, { - 'elem_or_list<fun(client: vim.lsp.Client, initialize_result: lsp.InitializeResult)>', + 'elem_or_list<fun(client: vim.lsp.Client, init_result: lsp.InitializeResult)>', nil, }, } |