aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/lua')
-rw-r--r--test/functional/lua/uri_spec.lua32
-rw-r--r--test/functional/lua/vim_spec.lua29
2 files changed, 58 insertions, 3 deletions
diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua
index f782769935..052a8a1ecd 100644
--- a/test/functional/lua/uri_spec.lua
+++ b/test/functional/lua/uri_spec.lua
@@ -53,12 +53,18 @@ describe('URI methods', function()
describe('uri to filepath', function()
describe('decode Unix file path', function()
- it('file path includes only ascii charactors', function()
+ it('file path includes only ascii characters', function()
exec_lua("uri = 'file:///Foo/Bar/Baz.txt'")
eq('/Foo/Bar/Baz.txt', exec_lua("return vim.uri_to_fname(uri)"))
end)
+ it('local file path without hostname', function()
+ exec_lua("uri = 'file:/Foo/Bar/Baz.txt'")
+
+ eq('/Foo/Bar/Baz.txt', exec_lua("return vim.uri_to_fname(uri)"))
+ end)
+
it('file path including white space', function()
exec_lua("uri = 'file:///Foo%20/Bar/Baz.txt'")
@@ -85,6 +91,15 @@ describe('URI methods', function()
eq('C:\\Foo\\Bar\\Baz.txt', exec_lua(test_case))
end)
+ it('local file path without hostname', function()
+ local test_case = [[
+ local uri = 'file:/C:/Foo/Bar/Baz.txt'
+ return vim.uri_to_fname(uri)
+ ]]
+
+ eq('C:\\Foo\\Bar\\Baz.txt', exec_lua(test_case))
+ end)
+
it('file path includes only ascii charactors with encoded colon character', function()
local test_case = [[
local uri = 'file:///C%3A/Foo/Bar/Baz.txt'
@@ -125,6 +140,12 @@ describe('URI methods', function()
return vim.uri_to_fname('JDT://content/%5C/')
]])
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')
+ ]])
+ end)
end)
describe('decode URI without scheme', function()
@@ -146,5 +167,14 @@ describe('URI methods', function()
]], uri)
eq(uri, exec_lua(test_case))
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 test_case = string.format([[
+ local uri = '%s'
+ return vim.uri_from_bufnr(vim.uri_to_bufnr(uri))
+ ]], uri)
+ eq(uri, exec_lua(test_case))
+ end)
end)
end)
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index eff838aea3..4e2bed4deb 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -603,6 +603,31 @@ describe('lua stdlib', function()
return vim.tbl_islist(c) and count == 0
]]))
+ eq(exec_lua([[
+ local a = { a = { b = 1 } }
+ local b = { a = {} }
+ return vim.tbl_deep_extend("force", a, b)
+ ]]), {a = {b = 1}})
+
+ eq(exec_lua([[
+ local a = { a = 123 }
+ local b = { a = { b = 1} }
+ return vim.tbl_deep_extend("force", a, b)
+ ]]), {a = {b = 1}})
+
+ ok(exec_lua([[
+ local a = { a = {[2] = 3} }
+ local b = { a = {[3] = 3} }
+ local c = vim.tbl_deep_extend("force", a, b)
+ return vim.deep_equal(c, {a = {[3] = 3}})
+ ]]))
+
+ eq(exec_lua([[
+ local a = { a = { b = 1} }
+ local b = { a = 123 }
+ return vim.tbl_deep_extend("force", a, b)
+ ]]), {a = 123 })
+
eq('Error executing lua: vim/shared.lua:0: invalid "behavior": nil',
pcall_err(exec_lua, [[
return vim.tbl_deep_extend()
@@ -1332,12 +1357,12 @@ describe('lua stdlib', function()
it('should work for key-value pair options', function()
local listchars = exec_lua [[
- vim.opt.listchars = "tab:>~,space:_"
+ vim.opt.listchars = "tab:> ,space:_"
return vim.opt.listchars:get()
]]
eq({
- tab = ">~",
+ tab = "> ",
space = "_",
}, listchars)
end)