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