mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor(test): cleanup #25614
- unnecessary separate describe() group - clear() wasn't called in the describe() group - unnecessary indirection in function parameters
This commit is contained in:
parent
9c2270b834
commit
2c9f22e7e4
@ -82,10 +82,20 @@ describe('expand wildcard', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('file search (gf, <cfile>)', function()
|
describe('file search', function()
|
||||||
|
local testdir = 'Xtest_path_spec'
|
||||||
|
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('find multibyte file name in line #20517', function()
|
setup(function()
|
||||||
|
mkdir(testdir)
|
||||||
|
end)
|
||||||
|
|
||||||
|
teardown(function()
|
||||||
|
rmdir(testdir)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('gf finds multibyte filename in line #20517', function()
|
||||||
command('cd test/functional/fixtures')
|
command('cd test/functional/fixtures')
|
||||||
insert('filename_with_unicode_ααα')
|
insert('filename_with_unicode_ααα')
|
||||||
eq('', eval('expand("%")'))
|
eq('', eval('expand("%")'))
|
||||||
@ -93,7 +103,7 @@ describe('file search (gf, <cfile>)', function()
|
|||||||
eq('filename_with_unicode_ααα', eval('expand("%:t")'))
|
eq('filename_with_unicode_ααα', eval('expand("%:t")'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('matches Windows drive-letter filepaths (without ":" in &isfname)', function()
|
it('gf/<cfile> matches Windows drive-letter filepaths (without ":" in &isfname)', function()
|
||||||
local iswin = is_os('win')
|
local iswin = is_os('win')
|
||||||
local function test_cfile(input, expected, expected_win)
|
local function test_cfile(input, expected, expected_win)
|
||||||
expected = (iswin and expected_win or expected) or input
|
expected = (iswin and expected_win or expected) or input
|
||||||
@ -130,41 +140,29 @@ describe('file search (gf, <cfile>)', function()
|
|||||||
test_cfile([[\\.\UNC\LOCALHOST\c$\temp\test-file.txt]], [[.]], [[\\.\UNC\LOCALHOST\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]])
|
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)
|
end)
|
||||||
end)
|
|
||||||
|
|
||||||
describe('file search with vim functions', function()
|
---@param funcname 'finddir' | 'findfile'
|
||||||
local test_folder = "path_spec_folder"
|
local function test_find_func(funcname, folder, item)
|
||||||
|
local d = join_path(testdir, folder)
|
||||||
setup(function()
|
mkdir(d)
|
||||||
mkdir(test_folder)
|
local expected = join_path(d, item)
|
||||||
end)
|
if funcname == 'finddir' then
|
||||||
|
|
||||||
teardown(function()
|
|
||||||
rmdir(test_folder)
|
|
||||||
end)
|
|
||||||
|
|
||||||
---@param option "dir" | "file"
|
|
||||||
local function test_find_func(option, folder, item)
|
|
||||||
local folder_path = join_path(test_folder, folder)
|
|
||||||
mkdir(folder_path)
|
|
||||||
local expected = join_path(folder_path, item)
|
|
||||||
if option == "dir" then
|
|
||||||
mkdir(expected)
|
mkdir(expected)
|
||||||
else
|
else
|
||||||
write_file(expected, '')
|
write_file(expected, '')
|
||||||
end
|
end
|
||||||
eq(expected, funcs['find' .. option](item, folder_path:gsub(' ', [[\ ]])))
|
eq(expected, funcs[funcname](item, d:gsub(' ', [[\ ]])))
|
||||||
end
|
end
|
||||||
|
|
||||||
it('finddir()', function()
|
it('finddir()', function()
|
||||||
test_find_func('dir', 'directory', 'folder')
|
test_find_func('finddir', 'directory', 'folder')
|
||||||
test_find_func('dir', 'directory', 'folder name')
|
test_find_func('finddir', 'directory', 'folder name')
|
||||||
test_find_func('dir', 'fold#er name', 'directory')
|
test_find_func('finddir', 'fold#er name', 'directory')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('findfile()', function()
|
it('findfile()', function()
|
||||||
test_find_func('file', 'directory', 'file.txt')
|
test_find_func('findfile', 'directory', 'file.txt')
|
||||||
test_find_func('file', 'directory', 'file name.txt')
|
test_find_func('findfile', 'directory', 'file name.txt')
|
||||||
test_find_func('file', 'fold#er name', 'file.txt')
|
test_find_func('findfile', 'fold#er name', 'file.txt')
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user