mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 05:28:33 +00:00
test: remove a few more redundant clear() calls (#35903)
This commit is contained in:
@@ -1171,8 +1171,6 @@ describe('autocmd api', function()
|
|||||||
|
|
||||||
describe('nvim_create_augroup', function()
|
describe('nvim_create_augroup', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
|
||||||
|
|
||||||
api.nvim_set_var('executed', 0)
|
api.nvim_set_var('executed', 0)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -57,7 +57,6 @@ local function editoriginal(activate, lines)
|
|||||||
lines = origlines
|
lines = origlines
|
||||||
end
|
end
|
||||||
-- load up the file with the correct contents
|
-- load up the file with the correct contents
|
||||||
clear()
|
|
||||||
return open(activate, lines)
|
return open(activate, lines)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -507,8 +506,6 @@ describe('API: buffer events:', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('can notify several channels at once', function()
|
it('can notify several channels at once', function()
|
||||||
clear()
|
|
||||||
|
|
||||||
-- create several new sessions, in addition to our main API
|
-- create several new sessions, in addition to our main API
|
||||||
local sessions = {}
|
local sessions = {}
|
||||||
local pipe = n.new_pipename()
|
local pipe = n.new_pipename()
|
||||||
@@ -781,8 +778,6 @@ describe('API: buffer events:', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('detaches if the buffer is unloaded/deleted/wiped', function()
|
it('detaches if the buffer is unloaded/deleted/wiped', function()
|
||||||
-- start with a blank nvim
|
|
||||||
clear()
|
|
||||||
-- need to make a new window with a buffer because :bunload doesn't let you
|
-- need to make a new window with a buffer because :bunload doesn't let you
|
||||||
-- unload the last buffer
|
-- unload the last buffer
|
||||||
for _, cmd in ipairs({ 'bunload', 'bdelete', 'bwipeout' }) do
|
for _, cmd in ipairs({ 'bunload', 'bdelete', 'bwipeout' }) do
|
||||||
@@ -798,20 +793,17 @@ describe('API: buffer events:', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not send the buffer content if not requested', function()
|
it('does not send the buffer content if not requested', function()
|
||||||
clear()
|
|
||||||
local b, tick = editoriginal(false)
|
local b, tick = editoriginal(false)
|
||||||
ok(api.nvim_buf_attach(b, false, {}))
|
ok(api.nvim_buf_attach(b, false, {}))
|
||||||
expectn('nvim_buf_changedtick_event', { b, tick })
|
expectn('nvim_buf_changedtick_event', { b, tick })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns a proper error on nonempty options dict', function()
|
it('returns a proper error on nonempty options dict', function()
|
||||||
clear()
|
|
||||||
local b = editoriginal(false)
|
local b = editoriginal(false)
|
||||||
eq("Invalid key: 'builtin'", pcall_err(api.nvim_buf_attach, b, false, { builtin = 'asfd' }))
|
eq("Invalid key: 'builtin'", pcall_err(api.nvim_buf_attach, b, false, { builtin = 'asfd' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('nvim_buf_attach returns response after delay #8634', function()
|
it('nvim_buf_attach returns response after delay #8634', function()
|
||||||
clear()
|
|
||||||
sleep(250)
|
sleep(250)
|
||||||
-- response
|
-- response
|
||||||
eq(true, n.request('nvim_buf_attach', 0, false, {}))
|
eq(true, n.request('nvim_buf_attach', 0, false, {}))
|
||||||
|
@@ -48,8 +48,6 @@ describe("api_info()['version']", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('api metadata', function()
|
describe('api metadata', function()
|
||||||
before_each(clear)
|
|
||||||
|
|
||||||
local function name_table(entries)
|
local function name_table(entries)
|
||||||
local by_name = {}
|
local by_name = {}
|
||||||
for _, e in ipairs(entries) do
|
for _, e in ipairs(entries) do
|
||||||
@@ -149,6 +147,8 @@ describe('api metadata', function()
|
|||||||
clean_level_0(old_api[level])
|
clean_level_0(old_api[level])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- No Nvim session will be used in the following tests.
|
||||||
|
n.check_close()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('functions are compatible with old metadata or have new level', function()
|
it('functions are compatible with old metadata or have new level', function()
|
||||||
|
@@ -13,7 +13,6 @@ describe('CompleteDone', function()
|
|||||||
|
|
||||||
describe('sets v:event.reason', function()
|
describe('sets v:event.reason', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
|
||||||
command('autocmd CompleteDone * let g:donereason = v:event.reason')
|
command('autocmd CompleteDone * let g:donereason = v:event.reason')
|
||||||
feed('i')
|
feed('i')
|
||||||
call('complete', call('col', '.'), { 'foo', 'bar' })
|
call('complete', call('col', '.'), { 'foo', 'bar' })
|
||||||
|
@@ -58,6 +58,7 @@ end)
|
|||||||
describe(':cquit', function()
|
describe(':cquit', function()
|
||||||
local function test_cq(cmdline, exit_code, redir_msg)
|
local function test_cq(cmdline, exit_code, redir_msg)
|
||||||
if redir_msg then
|
if redir_msg then
|
||||||
|
n.clear()
|
||||||
eq(
|
eq(
|
||||||
redir_msg,
|
redir_msg,
|
||||||
pcall_err(function()
|
pcall_err(function()
|
||||||
@@ -66,16 +67,13 @@ describe(':cquit', function()
|
|||||||
)
|
)
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
assert_alive()
|
assert_alive()
|
||||||
|
n.check_close()
|
||||||
else
|
else
|
||||||
local p = n.spawn_wait('--cmd', cmdline)
|
local p = n.spawn_wait('--cmd', cmdline)
|
||||||
eq(exit_code, p.status)
|
eq(exit_code, p.status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before_each(function()
|
|
||||||
n.clear()
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('exits with non-zero after :cquit', function()
|
it('exits with non-zero after :cquit', function()
|
||||||
test_cq('cquit', 1, nil)
|
test_cq('cquit', 1, nil)
|
||||||
end)
|
end)
|
||||||
|
@@ -53,7 +53,7 @@ local tests_windows_paths = {
|
|||||||
'c:\\users\\foo\\bar\\..\\',
|
'c:\\users\\foo\\bar\\..\\',
|
||||||
}
|
}
|
||||||
|
|
||||||
before_each(clear)
|
setup(clear)
|
||||||
|
|
||||||
describe('vim.fs', function()
|
describe('vim.fs', function()
|
||||||
describe('parents()', function()
|
describe('parents()', function()
|
||||||
@@ -354,6 +354,10 @@ describe('vim.fs', function()
|
|||||||
command('edit test/functional/fixtures/tty-test.c')
|
command('edit test/functional/fixtures/tty-test.c')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
after_each(function()
|
||||||
|
command('bwipe!')
|
||||||
|
end)
|
||||||
|
|
||||||
it('works with a single marker', function()
|
it('works with a single marker', function()
|
||||||
eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
|
eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
|
||||||
end)
|
end)
|
||||||
@@ -466,8 +470,9 @@ describe('vim.fs', function()
|
|||||||
eq(
|
eq(
|
||||||
xdg_config_home .. '/nvim',
|
xdg_config_home .. '/nvim',
|
||||||
exec_lua(function()
|
exec_lua(function()
|
||||||
vim.env.XDG_CONFIG_HOME = xdg_config_home
|
return vim._with({ env = { XDG_CONFIG_HOME = xdg_config_home } }, function()
|
||||||
return vim.fs.normalize('$XDG_CONFIG_HOME/nvim')
|
return vim.fs.normalize('$XDG_CONFIG_HOME/nvim')
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
@@ -1,15 +1,10 @@
|
|||||||
local t = require('test.testutil')
|
local t = require('test.testutil')
|
||||||
local n = require('test.functional.testnvim')()
|
|
||||||
|
|
||||||
local eq = t.eq
|
local eq = t.eq
|
||||||
|
|
||||||
describe('glob', function()
|
describe('glob', function()
|
||||||
before_each(n.clear)
|
|
||||||
|
|
||||||
local match = function(pattern, str)
|
local match = function(pattern, str)
|
||||||
return n.exec_lua(function()
|
return require('vim.glob').to_lpeg(pattern):match(str) ~= nil
|
||||||
return require('vim.glob').to_lpeg(pattern):match(str) ~= nil
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('glob matching', function()
|
describe('glob matching', function()
|
||||||
|
@@ -1,12 +1,8 @@
|
|||||||
local t = require('test.testutil')
|
local t = require('test.testutil')
|
||||||
local n = require('test.functional.testnvim')()
|
|
||||||
|
|
||||||
local clear = n.clear
|
|
||||||
local eq = t.eq
|
local eq = t.eq
|
||||||
|
|
||||||
describe('vim.text', function()
|
describe('vim.text', function()
|
||||||
before_each(clear)
|
|
||||||
|
|
||||||
describe('indent()', function()
|
describe('indent()', function()
|
||||||
it('validation', function()
|
it('validation', function()
|
||||||
t.matches('size%: expected number, got string', t.pcall_err(vim.text.indent, 'x', 'x'))
|
t.matches('size%: expected number, got string', t.pcall_err(vim.text.indent, 'x', 'x'))
|
||||||
|
@@ -9,7 +9,6 @@ local exec_capture, dedent = n.exec_capture, t.dedent
|
|||||||
-- First test it's implemented using the :lmap and :lnoremap commands, then
|
-- First test it's implemented using the :lmap and :lnoremap commands, then
|
||||||
-- check those mappings behave as expected.
|
-- check those mappings behave as expected.
|
||||||
describe("'keymap' / :lmap", function()
|
describe("'keymap' / :lmap", function()
|
||||||
clear()
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
insert('lllaaa')
|
insert('lllaaa')
|
||||||
|
@@ -184,7 +184,6 @@ describe('vim.lsp.util', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
n.clear()
|
|
||||||
local _ = Screen.new(80, 80)
|
local _ = Screen.new(80, 80)
|
||||||
feed('79i<CR><Esc>') -- fill screen with empty lines
|
feed('79i<CR><Esc>') -- fill screen with empty lines
|
||||||
end)
|
end)
|
||||||
@@ -280,7 +279,6 @@ describe('vim.lsp.util', function()
|
|||||||
|
|
||||||
describe('open_floating_preview', function()
|
describe('open_floating_preview', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
n.clear()
|
|
||||||
Screen.new(10, 10)
|
Screen.new(10, 10)
|
||||||
feed('9i<CR><Esc>G4k')
|
feed('9i<CR><Esc>G4k')
|
||||||
end)
|
end)
|
||||||
|
@@ -14,8 +14,6 @@ local poke_eventloop = n.poke_eventloop
|
|||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
describe('treesitter foldexpr', function()
|
describe('treesitter foldexpr', function()
|
||||||
clear()
|
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
-- open folds to avoid deleting entire folded region
|
-- open folds to avoid deleting entire folded region
|
||||||
exec_lua([[vim.opt.foldlevel = 9]])
|
exec_lua([[vim.opt.foldlevel = 9]])
|
||||||
|
@@ -14,8 +14,6 @@ local function lua_eval(lua_expr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe('treesitter node API', function()
|
describe('treesitter node API', function()
|
||||||
clear()
|
|
||||||
|
|
||||||
it('double free tree', function()
|
it('double free tree', function()
|
||||||
insert('F')
|
insert('F')
|
||||||
exec_lua(function()
|
exec_lua(function()
|
||||||
|
@@ -9,8 +9,6 @@ local exec_lua = n.exec_lua
|
|||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
describe('treesitter utils', function()
|
describe('treesitter utils', function()
|
||||||
before_each(clear)
|
|
||||||
|
|
||||||
it('can find an ancestor', function()
|
it('can find an ancestor', function()
|
||||||
insert([[
|
insert([[
|
||||||
int main() {
|
int main() {
|
||||||
|
@@ -16,6 +16,5 @@ local is_os = t.is_os
|
|||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('windowsversion()', function()
|
it('windowsversion()', function()
|
||||||
clear()
|
|
||||||
matches(is_os('win') and '^%d+%.%d+$' or '^$', eval('windowsversion()'))
|
matches(is_os('win') and '^%d+%.%d+$' or '^$', eval('windowsversion()'))
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user