aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2020-01-08 09:20:53 -0800
committerJustin M. Keyes <justinkz@gmail.com>2020-01-08 09:30:59 -0800
commit844cd9cef12d77fd5d0bb14819dbe201dbf68f0b (patch)
tree29e334f1926cc4bd66147b92675756d9decfef99
parente616ec439436816bb39b1d5e720593e6c66580c9 (diff)
downloadrneovim-844cd9cef12d77fd5d0bb14819dbe201dbf68f0b.tar.gz
rneovim-844cd9cef12d77fd5d0bb14819dbe201dbf68f0b.tar.bz2
rneovim-844cd9cef12d77fd5d0bb14819dbe201dbf68f0b.zip
test: just say no to hyper-granularity
- Move plugin/lsp/* to plugin/* - Merge lsp/util_spec.lua into lsp_spec.lua
-rw-r--r--test/functional/plugin/lsp/util_spec.lua76
-rw-r--r--test/functional/plugin/lsp_spec.lua (renamed from test/functional/plugin/lsp/lsp_spec.lua)68
2 files changed, 68 insertions, 76 deletions
diff --git a/test/functional/plugin/lsp/util_spec.lua b/test/functional/plugin/lsp/util_spec.lua
deleted file mode 100644
index 1cf0e48be4..0000000000
--- a/test/functional/plugin/lsp/util_spec.lua
+++ /dev/null
@@ -1,76 +0,0 @@
-local helpers = require('test.functional.helpers')(after_each)
-local eq = helpers.eq
-local exec_lua = helpers.exec_lua
-local dedent = helpers.dedent
-local insert = helpers.insert
-local clear = helpers.clear
-
-describe('LSP util', function()
- local test_text = dedent([[
- First line of text
- Second line of text
- Third line of text
- Fourth line of text]])
-
- local function reset()
- clear()
- insert(test_text)
- end
-
- before_each(reset)
-
- local function make_edit(y_0, x_0, y_1, x_1, text)
- return {
- range = {
- start = { line = y_0, character = x_0 };
- ["end"] = { line = y_1, character = x_1 };
- };
- newText = type(text) == 'table' and table.concat(text, '\n') or (text or "");
- }
- end
-
- local function buf_lines(bufnr)
- return exec_lua("return vim.api.nvim_buf_get_lines((...), 0, -1, false)", bufnr)
- end
-
- describe('apply_edits', function()
- it('should apply simple edits', function()
- local edits = {
- make_edit(0, 0, 0, 0, {"123"});
- make_edit(1, 0, 1, 1, {"2"});
- make_edit(2, 0, 2, 2, {"3"});
- }
- exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1)
- eq({
- '123First line of text';
- '2econd line of text';
- '3ird line of text';
- 'Fourth line of text';
- }, buf_lines(1))
- end)
-
- it('should apply complex edits', function()
- local edits = {
- make_edit(0, 0, 0, 0, {"", "12"});
- make_edit(0, 0, 0, 0, {"3", "foo"});
- make_edit(0, 1, 0, 1, {"bar", "123"});
- make_edit(0, #"First ", 0, #"First line of text", {"guy"});
- make_edit(1, 0, 1, #'Second', {"baz"});
- make_edit(2, #'Th', 2, #"Third", {"e next"});
- make_edit(3, #'', 3, #"Fourth", {"another line of text", "before this"});
- make_edit(3, #'Fourth', 3, #"Fourth line of text", {"!"});
- }
- exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1)
- eq({
- '';
- '123';
- 'fooFbar';
- '123irst guy';
- 'baz line of text';
- 'The next line of text';
- 'another line of text';
- 'before this!';
- }, buf_lines(1))
- end)
- end)
-end)
diff --git a/test/functional/plugin/lsp/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index e54275e820..803483c0ef 100644
--- a/test/functional/plugin/lsp/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -1,8 +1,10 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
+local dedent = helpers.dedent
local exec_lua = helpers.exec_lua
local eq = helpers.eq
+local insert = helpers.insert
local iswin = helpers.iswin
local retry = helpers.retry
local NIL = helpers.NIL
@@ -706,3 +708,69 @@ describe('LSP', function()
end)
end)
+
+describe('LSP util', function()
+ before_each(function()
+ clear()
+ insert(dedent([[
+ First line of text
+ Second line of text
+ Third line of text
+ Fourth line of text]]))
+ end)
+
+ local function make_edit(y_0, x_0, y_1, x_1, text)
+ return {
+ range = {
+ start = { line = y_0, character = x_0 };
+ ["end"] = { line = y_1, character = x_1 };
+ };
+ newText = type(text) == 'table' and table.concat(text, '\n') or (text or "");
+ }
+ end
+
+ local function buf_lines(bufnr)
+ return exec_lua("return vim.api.nvim_buf_get_lines((...), 0, -1, false)", bufnr)
+ end
+
+ describe('apply_edits', function()
+ it('should apply simple edits', function()
+ local edits = {
+ make_edit(0, 0, 0, 0, {"123"});
+ make_edit(1, 0, 1, 1, {"2"});
+ make_edit(2, 0, 2, 2, {"3"});
+ }
+ exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1)
+ eq({
+ '123First line of text';
+ '2econd line of text';
+ '3ird line of text';
+ 'Fourth line of text';
+ }, buf_lines(1))
+ end)
+
+ it('should apply complex edits', function()
+ local edits = {
+ make_edit(0, 0, 0, 0, {"", "12"});
+ make_edit(0, 0, 0, 0, {"3", "foo"});
+ make_edit(0, 1, 0, 1, {"bar", "123"});
+ make_edit(0, #"First ", 0, #"First line of text", {"guy"});
+ make_edit(1, 0, 1, #'Second', {"baz"});
+ make_edit(2, #'Th', 2, #"Third", {"e next"});
+ make_edit(3, #'', 3, #"Fourth", {"another line of text", "before this"});
+ make_edit(3, #'Fourth', 3, #"Fourth line of text", {"!"});
+ }
+ exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1)
+ eq({
+ '';
+ '123';
+ 'fooFbar';
+ '123irst guy';
+ 'baz line of text';
+ 'The next line of text';
+ 'another line of text';
+ 'before this!';
+ }, buf_lines(1))
+ end)
+ end)
+end)