refactor: format test/*

This commit is contained in:
Justin M. Keyes
2024-01-03 02:09:18 +01:00
parent 59d117ec99
commit 04f2f864e2
363 changed files with 30631 additions and 20833 deletions

View File

@@ -15,20 +15,24 @@ local file_base = 'Xtest-functional-ex_cmds-quickfix_commands'
before_each(clear)
for _, c in ipairs({'l', 'c'}) do
for _, c in ipairs({ 'l', 'c' }) do
local file = ('%s.%s'):format(file_base, c)
local filecmd = c .. 'file'
local getfcmd = c .. 'getfile'
local addfcmd = c .. 'addfile'
local getlist = (c == 'c') and funcs.getqflist or (
function() return funcs.getloclist(0) end)
local getlist = (c == 'c') and funcs.getqflist or function()
return funcs.getloclist(0)
end
describe((':%s*file commands'):format(c), function()
before_each(function()
write_file(file, ([[
write_file(
file,
([[
%s-1.res:700:10:Line 700
%s-2.res:800:15:Line 800
]]):format(file, file))
]]):format(file, file)
)
end)
after_each(function()
os.remove(file)
@@ -39,10 +43,34 @@ for _, c in ipairs({'l', 'c'}) do
-- Second line of each entry (i.e. `nr=-1, …`) was obtained from actual
-- results. First line (i.e. `{lnum=…`) was obtained from legacy test.
local list = {
{lnum=700, end_lnum=0, col=10, end_col=0, text='Line 700', module='',
nr=-1, bufnr=2, valid=1, pattern='', vcol=0, ['type']=''},
{lnum=800, end_lnum=0, col=15, end_col=0, text='Line 800', module='',
nr=-1, bufnr=3, valid=1, pattern='', vcol=0, ['type']=''},
{
lnum = 700,
end_lnum = 0,
col = 10,
end_col = 0,
text = 'Line 700',
module = '',
nr = -1,
bufnr = 2,
valid = 1,
pattern = '',
vcol = 0,
['type'] = '',
},
{
lnum = 800,
end_lnum = 0,
col = 15,
end_col = 0,
text = 'Line 800',
module = '',
nr = -1,
bufnr = 3,
valid = 1,
pattern = '',
vcol = 0,
['type'] = '',
},
}
eq(list, getlist())
eq(('%s-1.res'):format(file), funcs.bufname(list[1].bufnr))
@@ -51,33 +79,74 @@ for _, c in ipairs({'l', 'c'}) do
-- Run cfile/lfile from a modified buffer
command('set nohidden')
command('enew!')
curbufmeths.set_lines(1, 1, true, {'Quickfix'})
eq(('Vim(%s):E37: No write since last change (add ! to override)'):format(
filecmd),
exc_exec(('%s %s'):format(filecmd, file)))
curbufmeths.set_lines(1, 1, true, { 'Quickfix' })
eq(
('Vim(%s):E37: No write since last change (add ! to override)'):format(filecmd),
exc_exec(('%s %s'):format(filecmd, file))
)
write_file(file, ([[
write_file(
file,
([[
%s-3.res:900:30:Line 900
]]):format(file))
]]):format(file)
)
command(('%s %s'):format(addfcmd, file))
list[#list + 1] = {
lnum=900, end_lnum=0, col=30, end_col=0, text='Line 900', module='',
nr=-1, bufnr=5, valid=1, pattern='', vcol=0, ['type']='',
lnum = 900,
end_lnum = 0,
col = 30,
end_col = 0,
text = 'Line 900',
module = '',
nr = -1,
bufnr = 5,
valid = 1,
pattern = '',
vcol = 0,
['type'] = '',
}
eq(list, getlist())
eq(('%s-3.res'):format(file), funcs.bufname(list[3].bufnr))
write_file(file, ([[
write_file(
file,
([[
%s-1.res:222:77:Line 222
%s-2.res:333:88:Line 333
]]):format(file, file))
]]):format(file, file)
)
command('enew!')
command(('%s %s'):format(getfcmd, file))
list = {
{lnum=222, end_lnum=0, col=77, end_col=0, text='Line 222', module='',
nr=-1, bufnr=2, valid=1, pattern='', vcol=0, ['type']=''},
{lnum=333, end_lnum=0, col=88, end_col=0, text='Line 333', module='',
nr=-1, bufnr=3, valid=1, pattern='', vcol=0, ['type']=''},
{
lnum = 222,
end_lnum = 0,
col = 77,
end_col = 0,
text = 'Line 222',
module = '',
nr = -1,
bufnr = 2,
valid = 1,
pattern = '',
vcol = 0,
['type'] = '',
},
{
lnum = 333,
end_lnum = 0,
col = 88,
end_col = 0,
text = 'Line 333',
module = '',
nr = -1,
bufnr = 3,
valid = 1,
pattern = '',
vcol = 0,
['type'] = '',
},
}
eq(list, getlist())
eq(('%s-1.res'):format(file), funcs.bufname(list[1].bufnr))
@@ -109,7 +178,7 @@ describe('quickfix', function()
call append(0, ['New line 1', 'New line 2', 'New line 3'])
silent ll
]])
eq({0, 6, 1, 0, 1}, funcs.getcurpos())
eq({ 0, 6, 1, 0, 1 }, funcs.getcurpos())
end)
it('BufAdd does not cause E16 when reusing quickfix buffer #18135', function()
@@ -127,11 +196,14 @@ describe('quickfix', function()
end)
it(':vimgrep can specify Unicode pattern without delimiters', function()
eq('Vim(vimgrep):E480: No match: →', exc_exec('vimgrep → test/functional/fixtures/tty-test.c'))
eq(
'Vim(vimgrep):E480: No match: →',
exc_exec('vimgrep → test/functional/fixtures/tty-test.c')
)
local screen = Screen.new(40, 6)
screen:set_default_attr_ids({
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
[1] = {reverse = true}, -- IncSearch
[0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
[1] = { reverse = true }, -- IncSearch
})
screen:attach()
feed('i→<Esc>:vimgrep →')