test: add tests for executing commands with backwards range

This commit is contained in:
zeertzjq
2023-05-05 19:03:08 +08:00
parent 4a098b97e5
commit 3a1e17e3a1
2 changed files with 15 additions and 0 deletions

View File

@@ -361,6 +361,12 @@ describe('API', function()
eq('', eval('v:errmsg')) -- v:errmsg was not updated.
eq('', eval('v:exception'))
end)
it('gives E493 instead of prompting on backwards range', function()
command('split')
eq('Vim(windo):E493: Backwards range given: 2,1windo echo',
pcall_err(command, '2,1windo echo'))
end)
end)
describe('nvim_command_output', function()

View File

@@ -4,6 +4,7 @@ local eval = helpers.eval
local clear = helpers.clear
local source = helpers.source
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
local funcs = helpers.funcs
local Screen = require('test.functional.ui.screen')
local command = helpers.command
@@ -284,6 +285,14 @@ describe('execute()', function()
eq('42', eval('g:mes'))
end)
it('gives E493 instead of prompting on backwards range for ""', function()
command('split')
eq('Vim(windo):E493: Backwards range given: 2,1windo echo',
pcall_err(funcs.execute, '2,1windo echo', ''))
eq('Vim(windo):E493: Backwards range given: 2,1windo echo',
pcall_err(funcs.execute, {'2,1windo echo'}, ''))
end)
it('captures but does not display output for "silent"', function()
local screen = Screen.new(40, 5)
screen:attach()