mirror of
https://github.com/neovim/neovim.git
synced 2026-05-24 13:50:06 +00:00
refactor(test): drop deprecated exc_exec #39242
This commit is contained in:
@@ -6,7 +6,6 @@ local clear = n.clear
|
||||
local fn = n.fn
|
||||
local api = n.api
|
||||
local command = n.command
|
||||
local exc_exec = n.exc_exec
|
||||
local get_pathsep = n.get_pathsep
|
||||
local rmdir = n.rmdir
|
||||
local pcall_err = t.pcall_err
|
||||
@@ -34,30 +33,30 @@ for _, func in ipairs({
|
||||
for _, var in ipairs({ 'v:true', 'v:false' }) do
|
||||
eq(
|
||||
'Vim(call):E5299: Expected a Number or a String, Boolean found',
|
||||
exc_exec('call ' .. func:format(var))
|
||||
pcall_err(command, 'call ' .. func:format(var))
|
||||
)
|
||||
end
|
||||
eq(
|
||||
'Vim(call):E5300: Expected a Number or a String',
|
||||
exc_exec('call ' .. func:format('v:null'))
|
||||
pcall_err(command, 'call ' .. func:format('v:null'))
|
||||
)
|
||||
end)
|
||||
it('errors out when receives invalid argument', function()
|
||||
eq(
|
||||
'Vim(call):E745: Expected a Number or a String, List found',
|
||||
exc_exec('call ' .. func:format('[]'))
|
||||
pcall_err(command, 'call ' .. func:format('[]'))
|
||||
)
|
||||
eq(
|
||||
'Vim(call):E728: Expected a Number or a String, Dictionary found',
|
||||
exc_exec('call ' .. func:format('{}'))
|
||||
pcall_err(command, 'call ' .. func:format('{}'))
|
||||
)
|
||||
eq(
|
||||
'Vim(call):E805: Expected a Number or a String, Float found',
|
||||
exc_exec('call ' .. func:format('0.0'))
|
||||
pcall_err(command, 'call ' .. func:format('0.0'))
|
||||
)
|
||||
eq(
|
||||
'Vim(call):E703: Expected a Number or a String, Funcref found',
|
||||
exc_exec('call ' .. func:format('function("tr")'))
|
||||
pcall_err(command, 'call ' .. func:format('function("tr")'))
|
||||
)
|
||||
end)
|
||||
end)
|
||||
@@ -267,17 +266,17 @@ end)
|
||||
describe('setbufvar() function', function()
|
||||
it('throws the error or ignores the input when buffer was not found', function()
|
||||
command('file ' .. fname)
|
||||
eq(0, exc_exec('call setbufvar(2, "&autoindent", 0)'))
|
||||
command('call setbufvar(2, "&autoindent", 0)')
|
||||
eq(
|
||||
'Vim(call):E94: No matching buffer for non-existent-buffer',
|
||||
exc_exec('call setbufvar("non-existent-buffer", "&autoindent", 0)')
|
||||
pcall_err(command, 'call setbufvar("non-existent-buffer", "&autoindent", 0)')
|
||||
)
|
||||
eq(0, exc_exec('call setbufvar("#", "&autoindent", 0)'))
|
||||
command('call setbufvar("#", "&autoindent", 0)')
|
||||
command('edit ' .. fname2)
|
||||
eq(2, fn.bufnr('%'))
|
||||
eq(
|
||||
'Vim(call):E93: More than one match for X',
|
||||
exc_exec('call setbufvar("X", "&autoindent", 0)')
|
||||
pcall_err(command, 'call setbufvar("X", "&autoindent", 0)')
|
||||
)
|
||||
end)
|
||||
it('may set options, including window-local and global values', function()
|
||||
@@ -300,7 +299,7 @@ describe('setbufvar() function', function()
|
||||
eq(false, api.nvim_get_option_value('autoindent', { buf = buf1 }))
|
||||
fn.setbufvar(1, '&autoindent', true)
|
||||
eq(true, api.nvim_get_option_value('autoindent', { buf = buf1 }))
|
||||
eq('Vim(call):E355: Unknown option: xxx', exc_exec('call setbufvar(1, "&xxx", 0)'))
|
||||
eq('Vim(call):E355: Unknown option: xxx', pcall_err(command, 'call setbufvar(1, "&xxx", 0)'))
|
||||
end)
|
||||
it('may set variables', function()
|
||||
local buf1 = api.nvim_get_current_buf()
|
||||
@@ -309,7 +308,7 @@ describe('setbufvar() function', function()
|
||||
eq(2, api.nvim_buf_get_number(0))
|
||||
fn.setbufvar(1, 'number', true)
|
||||
eq(true, api.nvim_buf_get_var(buf1, 'number'))
|
||||
eq('Vim(call):E461: Illegal variable name: b:', exc_exec('call setbufvar(1, "", 0)'))
|
||||
eq('Vim(call):E461: Illegal variable name: b:', pcall_err(command, 'call setbufvar(1, "", 0)'))
|
||||
eq(true, api.nvim_buf_get_var(buf1, 'number'))
|
||||
eq(
|
||||
'Vim:E46: Cannot change read-only variable "b:changedtick"',
|
||||
|
||||
Reference in New Issue
Block a user