diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-03-09 14:57:57 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-03-09 14:57:57 -0700 |
commit | c324271b99eee4c621463f368914d57cd729bd9c (patch) | |
tree | 5d979d333a2d5f9c080991d5482fd5916f8579c6 /test/functional/core/path_spec.lua | |
parent | 931bffbda3668ddc609fc1da8f9eb576b170aa52 (diff) | |
parent | ade1b12f49c3b3914c74847d791eb90ea90b56b7 (diff) | |
download | rneovim-c324271b99eee4c621463f368914d57cd729bd9c.tar.gz rneovim-c324271b99eee4c621463f368914d57cd729bd9c.tar.bz2 rneovim-c324271b99eee4c621463f368914d57cd729bd9c.zip |
Merge remote-tracking branch 'upstream/master' into userreg
Diffstat (limited to 'test/functional/core/path_spec.lua')
-rw-r--r-- | test/functional/core/path_spec.lua | 50 |
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() |