aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/ex_cmds/cd_spec.lua13
-rw-r--r--test/functional/legacy/autochdir_spec.lua38
-rw-r--r--test/functional/legacy/fnamemodify_spec.lua2
-rw-r--r--test/functional/legacy/packadd_spec.lua3
-rw-r--r--test/functional/lua/diagnostic_spec.lua42
-rw-r--r--test/functional/lua/uri_spec.lua6
-rw-r--r--test/functional/plugin/lsp/incremental_sync_spec.lua26
-rw-r--r--test/functional/plugin/lsp_spec.lua10
-rw-r--r--test/unit/path_spec.lua14
9 files changed, 135 insertions, 19 deletions
diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua
index 283fcf9672..f9cce0deb6 100644
--- a/test/functional/ex_cmds/cd_spec.lua
+++ b/test/functional/ex_cmds/cd_spec.lua
@@ -294,7 +294,16 @@ describe("getcwd()", function ()
command('set autochdir')
command('edit ' .. directories.global .. '/foo')
eq(curdir .. pathsep .. directories.global, cwd())
+ eq(curdir, wcwd())
+ call('mkdir', 'bar')
+ command('edit ' .. 'bar/foo')
+ eq(curdir .. pathsep .. directories.global .. pathsep .. 'bar', cwd())
+ eq(curdir, wcwd())
+ command('lcd ..')
+ eq(curdir .. pathsep .. directories.global, cwd())
+ eq(curdir .. pathsep .. directories.global, wcwd())
+ command('edit')
+ eq(curdir .. pathsep .. directories.global .. pathsep .. 'bar', cwd())
+ eq(curdir .. pathsep .. directories.global, wcwd())
end)
end)
-
-
diff --git a/test/functional/legacy/autochdir_spec.lua b/test/functional/legacy/autochdir_spec.lua
index 466e3ed830..37a94476a0 100644
--- a/test/functional/legacy/autochdir_spec.lua
+++ b/test/functional/legacy/autochdir_spec.lua
@@ -1,10 +1,11 @@
local lfs = require('lfs')
local helpers = require('test.functional.helpers')(after_each)
-local clear, eq = helpers.clear, helpers.eq
-local eval, command = helpers.eval, helpers.command
+local clear, eq, matches = helpers.clear, helpers.eq, helpers.matches
+local eval, command, call = helpers.eval, helpers.command, helpers.call
+local exec_capture = helpers.exec_capture
describe('autochdir behavior', function()
- local dir = 'Xtest-functional-legacy-autochdir'
+ local dir = 'Xtest_functional_legacy_autochdir'
before_each(function()
lfs.mkdir(dir)
@@ -23,4 +24,35 @@ describe('autochdir behavior', function()
eq('Xtest', eval("expand('%')"))
eq(dir, eval([[substitute(getcwd(), '.*[/\\]\(\k*\)', '\1', '')]]))
end)
+
+ it(':verbose pwd shows whether autochdir is used', function()
+ local subdir = 'Xautodir'
+ command('cd '..dir)
+ local cwd = eval('getcwd()')
+ command('edit global.txt')
+ matches('%[global%].*'..dir, exec_capture('verbose pwd'))
+ call('mkdir', subdir)
+ command('split '..subdir..'/local.txt')
+ command('lcd '..subdir)
+ matches('%[window%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd'))
+ command('set autochdir')
+ command('wincmd w')
+ matches('%[autochdir%].*'..dir, exec_capture('verbose pwd'))
+ command('lcd '..cwd)
+ matches('%[window%].*'..dir, exec_capture('verbose pwd'))
+ command('tcd '..cwd)
+ matches('%[tabpage%].*'..dir, exec_capture('verbose pwd'))
+ command('cd '..cwd)
+ matches('%[global%].*'..dir, exec_capture('verbose pwd'))
+ command('edit')
+ matches('%[autochdir%].*'..dir, exec_capture('verbose pwd'))
+ command('wincmd w')
+ matches('%[autochdir%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd'))
+ command('set noautochdir')
+ matches('%[autochdir%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd'))
+ command('wincmd w')
+ matches('%[global%].*'..dir, exec_capture('verbose pwd'))
+ command('wincmd w')
+ matches('%[window%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd'))
+ end)
end)
diff --git a/test/functional/legacy/fnamemodify_spec.lua b/test/functional/legacy/fnamemodify_spec.lua
index 6a5538c26f..6262db3a2f 100644
--- a/test/functional/legacy/fnamemodify_spec.lua
+++ b/test/functional/legacy/fnamemodify_spec.lua
@@ -29,7 +29,7 @@ describe('filename modifiers', function()
call assert_equal('test.out', fnamemodify('test.out', ':.'))
call assert_equal('../testdir/a', fnamemodify('../testdir/a', ':.'))
call assert_equal(fnamemodify(tmpdir, ':~').'/test.out', fnamemodify('test.out', ':~'))
- call assert_equal('../testdir/a', fnamemodify('../testdir/a', ':~'))
+ call assert_equal(fnamemodify(tmpdir, ':~').'/../testdir/a', fnamemodify('../testdir/a', ':~'))
call assert_equal('a', fnamemodify('../testdir/a', ':t'))
call assert_equal('', fnamemodify('.', ':p:t'))
call assert_equal('test.out', fnamemodify('test.out', ':p:t'))
diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua
index 48cd3ef9f8..4f9f5a0237 100644
--- a/test/functional/legacy/packadd_spec.lua
+++ b/test/functional/legacy/packadd_spec.lua
@@ -20,6 +20,9 @@ describe('packadd', function()
func SetUp()
let s:topdir = expand(getcwd() . '/Xdir')
+ if isdirectory(s:topdir)
+ call delete(s:topdir, 'rf')
+ endif
exe 'set packpath=' . s:topdir
let s:plugdir = expand(s:topdir . '/pack/mine/opt/mytest')
endfunc
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index 6414483c0d..348b9de816 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -110,17 +110,21 @@ describe('vim.diagnostic', function()
it('retrieves diagnostics from all buffers and namespaces', function()
local result = exec_lua [[
- vim.diagnostic.set(diagnostic_ns, 1, {
+ local other_bufnr = vim.api.nvim_create_buf(true, false)
+ local lines = {"1st line of text", "2nd line of text", "wow", "cool", "more", "lines"}
+ vim.api.nvim_buf_set_lines(other_bufnr, 0, 1, false, lines)
+
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
make_error('Diagnostic #1', 1, 1, 1, 1),
make_error('Diagnostic #2', 2, 1, 2, 1),
})
- vim.diagnostic.set(other_ns, 2, {
+ vim.diagnostic.set(other_ns, other_bufnr, {
make_error('Diagnostic #3', 3, 1, 3, 1),
})
return vim.diagnostic.get()
]]
eq(3, #result)
- eq(2, exec_lua([[return #vim.tbl_filter(function(d) return d.bufnr == 1 end, ...)]], result))
+ eq(2, exec_lua([[return #vim.tbl_filter(function(d) return d.bufnr == diagnostic_bufnr end, ...)]], result))
eq('Diagnostic #1', result[1].message)
end)
@@ -339,6 +343,16 @@ describe('vim.diagnostic', function()
eq(0, result[5])
eq(3, result[6])
end)
+
+ it("doesn't error after bwipeout on buffer", function()
+ exec_lua [[
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, { lnum = 0, end_lnum = 0, col = 0, end_col = 0 })
+ vim.cmd("bwipeout! " .. diagnostic_bufnr)
+
+ vim.diagnostic.show(diagnostic_ns)
+ vim.diagnostic.hide(diagnostic_ns)
+ ]]
+ end)
end)
describe('enable() and disable()', function()
@@ -625,6 +639,15 @@ describe('vim.diagnostic', function()
]])
end)
+
+ it("doesn't error after bwipeout called on buffer", function()
+ exec_lua [[
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, { lnum = 0, end_lnum = 0, col = 0, end_col = 0 })
+ vim.cmd("bwipeout! " .. diagnostic_bufnr)
+
+ vim.diagnostic.reset(diagnostic_ns)
+ ]]
+ end)
end)
describe('get_next_pos()', function()
@@ -682,6 +705,19 @@ describe('vim.diagnostic', function()
return vim.diagnostic.get_prev_pos { namespace = diagnostic_ns }
]])
end)
+
+ it('works with diagnostics past the end of the line #16349', function()
+ eq({4, 0}, exec_lua [[
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
+ make_error('Diagnostic #1', 3, 9001, 3, 9001),
+ make_error('Diagnostic #2', 4, 0, 4, 0),
+ })
+ vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
+ vim.api.nvim_win_set_cursor(0, {1, 1})
+ vim.diagnostic.goto_next { float = false }
+ return vim.diagnostic.get_next_pos { namespace = diagnostic_ns }
+ ]])
+ end)
end)
describe('get_prev_pos()', function()
diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua
index 81f1820986..dbfbe2dbfe 100644
--- a/test/functional/lua/uri_spec.lua
+++ b/test/functional/lua/uri_spec.lua
@@ -143,8 +143,8 @@ describe('URI methods', function()
end)
it('uri_to_fname returns non-file scheme URI without authority unchanged', function()
- eq('zipfile:/path/to/archive.zip%3A%3Afilename.txt', exec_lua [[
- return vim.uri_to_fname('zipfile:/path/to/archive.zip%3A%3Afilename.txt')
+ eq('zipfile:///path/to/archive.zip%3A%3Afilename.txt', exec_lua [[
+ return vim.uri_to_fname('zipfile:///path/to/archive.zip%3A%3Afilename.txt')
]])
end)
end)
@@ -186,7 +186,7 @@ describe('URI methods', function()
end)
it('uri_to_bufnr & uri_from_bufnr returns original uri for non-file uris without authority', function()
- local uri = 'zipfile:/path/to/archive.zip%3A%3Afilename.txt'
+ local uri = 'zipfile:///path/to/archive.zip%3A%3Afilename.txt'
local test_case = string.format([[
local uri = '%s'
return vim.uri_from_bufnr(vim.uri_to_bufnr(uri))
diff --git a/test/functional/plugin/lsp/incremental_sync_spec.lua b/test/functional/plugin/lsp/incremental_sync_spec.lua
index 890db4abf5..5dd34e7665 100644
--- a/test/functional/plugin/lsp/incremental_sync_spec.lua
+++ b/test/functional/plugin/lsp/incremental_sync_spec.lua
@@ -297,7 +297,31 @@ describe('incremental synchronization', function()
}
test_edit({"🔥"}, {"x"}, expected_text_changes, 'utf-16', '\n')
end)
- it('deleting a multiple lines containing multibyte characters', function()
+ it('deleting a multibyte character from a long line', function()
+ local expected_text_changes = {
+ {
+ range = {
+ ['start'] = {
+ character = 85,
+ line = 1
+ },
+ ['end'] = {
+ character = 86,
+ line = 1
+ }
+ },
+ rangeLength = 1,
+ text = ''
+ }
+ }
+ local original_lines = {
+ "\\begin{document}",
+ "→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→",
+ "\\end{document}",
+ }
+ test_edit(original_lines, {"jx"}, expected_text_changes, 'utf-16', '\n')
+ end)
+ it('deleting multiple lines containing multibyte characters', function()
local expected_text_changes = {
{
range = {
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 228fc06e9b..b12d4227d5 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -66,7 +66,10 @@ local function fake_lsp_server_setup(test_name, timeout_ms, options)
end
end;
});
- root_dir = vim.loop.cwd();
+ workspace_folders = {{
+ uri = 'file://' .. vim.loop.cwd(),
+ name = 'test_folder',
+ }};
on_init = function(client, result)
TEST_RPC_CLIENT = client
vim.rpcrequest(1, "init", result)
@@ -153,7 +156,10 @@ describe('LSP', function()
"-c", string.format("lua TEST_NAME = %q", test_name),
"-c", "luafile "..fixture_filename;
};
- root_dir = vim.loop.cwd();
+ workspace_folders = {{
+ uri = 'file://' .. vim.loop.cwd(),
+ name = 'test_folder',
+ }};
}
end
TEST_CLIENT1 = test__start_client()
diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua
index 41954de9be..15ce59747e 100644
--- a/test/unit/path_spec.lua
+++ b/test/unit/path_spec.lua
@@ -54,15 +54,21 @@ describe('path.c', function()
eq(lfs.currentdir(), (ffi.string(buffer)))
end)
- itp('fails if the given directory does not exist', function()
- eq(FAIL, path_full_dir_name('does_not_exist', buffer, length))
- end)
-
itp('works with a normal relative dir', function()
local result = path_full_dir_name('unit-test-directory', buffer, length)
eq(lfs.currentdir() .. '/unit-test-directory', (ffi.string(buffer)))
eq(OK, result)
end)
+
+ itp('works with a non-existing relative dir', function()
+ local result = path_full_dir_name('does-not-exist', buffer, length)
+ eq(lfs.currentdir() .. '/does-not-exist', (ffi.string(buffer)))
+ eq(OK, result)
+ end)
+
+ itp('fails with a non-existing absolute dir', function()
+ eq(FAIL, path_full_dir_name('/does_not_exist', buffer, length))
+ end)
end)
describe('path_full_compare', function()