aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core/path_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-03-09 15:00:41 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-03-09 15:00:41 -0700
commit7a7f497b483cd65e340064f23ed1c73425ecba0a (patch)
treed5c99ea22a1e10300d06165f8ac96df6b0dc59e1 /test/functional/core/path_spec.lua
parent1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (diff)
parentade1b12f49c3b3914c74847d791eb90ea90b56b7 (diff)
downloadrneovim-7a7f497b483cd65e340064f23ed1c73425ecba0a.tar.gz
rneovim-7a7f497b483cd65e340064f23ed1c73425ecba0a.tar.bz2
rneovim-7a7f497b483cd65e340064f23ed1c73425ecba0a.zip
Merge remote-tracking branch 'upstream/master' into aucmd_textputpost
Diffstat (limited to 'test/functional/core/path_spec.lua')
-rw-r--r--test/functional/core/path_spec.lua50
1 files changed, 33 insertions, 17 deletions
diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua
index 97c32f7de6..e98bfc0d45 100644
--- a/test/functional/core/path_spec.lua
+++ b/test/functional/core/path_spec.lua
@@ -4,7 +4,7 @@ local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
-local funcs = helpers.funcs
+local fn = helpers.fn
local insert = helpers.insert
local is_os = helpers.is_os
local mkdir = helpers.mkdir
@@ -13,7 +13,7 @@ local write_file = helpers.write_file
local function join_path(...)
local pathsep = (is_os('win') and '\\' or '/')
- return table.concat({...}, pathsep)
+ return table.concat({ ... }, pathsep)
end
describe('path collapse', function()
@@ -23,40 +23,40 @@ describe('path collapse', function()
before_each(function()
targetdir = join_path('test', 'functional', 'fixtures')
clear()
- command('edit '..join_path(targetdir, 'tty-test.c'))
+ command('edit ' .. join_path(targetdir, 'tty-test.c'))
expected_path = eval('expand("%:p")')
end)
it('with /./ segment #7117', function()
- command('edit '..join_path(targetdir, '.', 'tty-test.c'))
+ command('edit ' .. join_path(targetdir, '.', 'tty-test.c'))
eq(expected_path, eval('expand("%:p")'))
end)
it('with ./ prefix #7117', function()
- command('edit '..join_path('.', targetdir, 'tty-test.c'))
+ command('edit ' .. join_path('.', targetdir, 'tty-test.c'))
eq(expected_path, eval('expand("%:p")'))
end)
it('with ./ prefix, after directory change #7117', function()
- command('edit '..join_path('.', targetdir, 'tty-test.c'))
+ command('edit ' .. join_path('.', targetdir, 'tty-test.c'))
command('cd test')
eq(expected_path, eval('expand("%:p")'))
end)
it('with /../ segment #7117', function()
- command('edit '..join_path(targetdir, '..', 'fixtures', 'tty-test.c'))
+ command('edit ' .. join_path(targetdir, '..', 'fixtures', 'tty-test.c'))
eq(expected_path, eval('expand("%:p")'))
end)
it('with ../ and different starting directory #7117', function()
command('cd test')
- command('edit '..join_path('..', targetdir, 'tty-test.c'))
+ command('edit ' .. join_path('..', targetdir, 'tty-test.c'))
eq(expected_path, eval('expand("%:p")'))
end)
it('with ./../ and different starting directory #7117', function()
command('cd test')
- command('edit '..join_path('.', '..', targetdir, 'tty-test.c'))
+ command('edit ' .. join_path('.', '..', targetdir, 'tty-test.c'))
eq(expected_path, eval('expand("%:p")'))
end)
end)
@@ -67,16 +67,16 @@ describe('expand wildcard', function()
it('with special characters #24421', function()
local folders = is_os('win') and {
'{folder}',
- 'folder$name'
+ 'folder$name',
} or {
'folder-name',
- 'folder#name'
+ 'folder#name',
}
for _, folder in ipairs(folders) do
mkdir(folder)
local file = join_path(folder, 'file.txt')
write_file(file, '')
- eq(file, eval('expand("'..folder..'/*")'))
+ eq(file, eval('expand("' .. folder .. '/*")'))
rmdir(folder)
end
end)
@@ -131,14 +131,30 @@ describe('file search', function()
test_cfile([[c:foo]], [[c]])
-- Examples from: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#example-ways-to-refer-to-the-same-file
test_cfile([[c:\temp\test-file.txt]], [[c:]], [[c:\temp\test-file.txt]])
- test_cfile([[\\127.0.0.1\c$\temp\test-file.txt]], [[127.0.0.1]], [[\\127.0.0.1\c$\temp\test-file.txt]])
- test_cfile([[\\LOCALHOST\c$\temp\test-file.txt]], [[LOCALHOST]], [[\\LOCALHOST\c$\temp\test-file.txt]])
+ test_cfile(
+ [[\\127.0.0.1\c$\temp\test-file.txt]],
+ [[127.0.0.1]],
+ [[\\127.0.0.1\c$\temp\test-file.txt]]
+ )
+ test_cfile(
+ [[\\LOCALHOST\c$\temp\test-file.txt]],
+ [[LOCALHOST]],
+ [[\\LOCALHOST\c$\temp\test-file.txt]]
+ )
-- not supported yet
test_cfile([[\\.\c:\temp\test-file.txt]], [[.]], [[\\.\c]])
-- not supported yet
test_cfile([[\\?\c:\temp\test-file.txt]], [[c:]], [[\\]])
- test_cfile([[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]], [[.]], [[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]])
- test_cfile([[\\127.0.0.1\c$\temp\test-file.txt]], [[127.0.0.1]], [[\\127.0.0.1\c$\temp\test-file.txt]])
+ test_cfile(
+ [[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]],
+ [[.]],
+ [[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]]
+ )
+ test_cfile(
+ [[\\127.0.0.1\c$\temp\test-file.txt]],
+ [[127.0.0.1]],
+ [[\\127.0.0.1\c$\temp\test-file.txt]]
+ )
end)
---@param funcname 'finddir' | 'findfile'
@@ -151,7 +167,7 @@ describe('file search', function()
else
write_file(expected, '')
end
- eq(expected, funcs[funcname](item, d:gsub(' ', [[\ ]])))
+ eq(expected, fn[funcname](item, d:gsub(' ', [[\ ]])))
end
it('finddir()', function()