test: big cleanup followup

Followup to 07a7c0ec
This commit is contained in:
Lewis Russell 2024-01-15 16:10:51 +00:00
parent b3e5587b7f
commit b536e0ba37
10 changed files with 73 additions and 85 deletions

View File

@ -8,7 +8,7 @@ local assert_alive = helpers.assert_alive
local NIL = vim.NIL local NIL = vim.NIL
local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
local command = helpers.command local command = helpers.command
local command_output = helpers.api.command_output local command_output = helpers.api.nvim_command_output
local exec = helpers.exec local exec = helpers.exec
local exec_capture = helpers.exec_capture local exec_capture = helpers.exec_capture
local eval = helpers.eval local eval = helpers.eval
@ -19,6 +19,7 @@ local matches = helpers.matches
local pesc = vim.pesc local pesc = vim.pesc
local mkdir_p = helpers.mkdir_p local mkdir_p = helpers.mkdir_p
local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed
local async_meths = helpers.async_meths
local is_os = helpers.is_os local is_os = helpers.is_os
local parse_context = helpers.parse_context local parse_context = helpers.parse_context
local request = helpers.request local request = helpers.request
@ -76,7 +77,7 @@ describe('API', function()
eq({ eq({
'notification', 'notification',
'nvim_error_event', 'nvim_error_event',
{ error_types.Exception.id, 'Invalid method: nvim_bogus' }, { error_types.Exception.id, 'Invalid method: bogus' },
}, next_msg()) }, next_msg())
-- error didn't close channel. -- error didn't close channel.
assert_alive() assert_alive()
@ -84,7 +85,7 @@ describe('API', function()
it('failed async request emits nvim_error_event', function() it('failed async request emits nvim_error_event', function()
local error_types = api.nvim_get_api_info()[2].error_types local error_types = api.nvim_get_api_info()[2].error_types
nvim_async('command', 'bogus') async_meths.nvim_command('bogus')
eq({ eq({
'notification', 'notification',
'nvim_error_event', 'nvim_error_event',
@ -2081,13 +2082,13 @@ describe('API', function()
{ ['rc'] = { 'hjkl' }, ['n'] = 97 }, { ['rc'] = { 'hjkl' }, ['n'] = 97 },
}, },
['jumps'] = eval(([[ ['jumps'] = eval((([[
filter(map(add( filter(map(add(
getjumplist()[0], { 'bufnr': bufnr('%'), 'lnum': getcurpos()[1] }), getjumplist()[0], { 'bufnr': bufnr('%'), 'lnum': getcurpos()[1] }),
'filter( 'filter(
{ "f": expand("#".v:val.bufnr.":p"), "l": v:val.lnum }, { "f": expand("#".v:val.bufnr.":p"), "l": v:val.lnum },
{ k, v -> k != "l" || v != 1 })'), '!empty(v:val.f)') { k, v -> k != "l" || v != 1 })'), '!empty(v:val.f)')
]]):gsub('\n', '')), ]]):gsub('\n', ''))),
['bufs'] = eval([[ ['bufs'] = eval([[
filter(map(getbufinfo(), '{ "f": v:val.name }'), '!empty(v:val.f)') filter(map(getbufinfo(), '{ "f": v:val.name }'), '!empty(v:val.f)')
@ -2301,7 +2302,7 @@ describe('API', function()
end) end)
it('can show one line', function() it('can show one line', function()
nvim_async('err_write', 'has bork\n') async_meths.nvim_err_write('has bork\n')
screen:expect([[ screen:expect([[
^ | ^ |
{0:~ }|*6 {0:~ }|*6
@ -2310,7 +2311,7 @@ describe('API', function()
end) end)
it('shows return prompt when more than &cmdheight lines', function() it('shows return prompt when more than &cmdheight lines', function()
nvim_async('err_write', 'something happened\nvery bad\n') async_meths.nvim_err_write('something happened\nvery bad\n')
screen:expect([[ screen:expect([[
| |
{0:~ }|*3 {0:~ }|*3
@ -2322,7 +2323,7 @@ describe('API', function()
end) end)
it('shows return prompt after all lines are shown', function() it('shows return prompt after all lines are shown', function()
nvim_async('err_write', 'FAILURE\nERROR\nEXCEPTION\nTRACEBACK\n') async_meths.nvim_err_write('FAILURE\nERROR\nEXCEPTION\nTRACEBACK\n')
screen:expect([[ screen:expect([[
| |
{0:~ }| {0:~ }|
@ -2337,8 +2338,8 @@ describe('API', function()
it('handles multiple calls', function() it('handles multiple calls', function()
-- without linebreak text is joined to one line -- without linebreak text is joined to one line
nvim_async('err_write', 'very ') async_meths.nvim_err_write('very ')
nvim_async('err_write', 'fail\n') async_meths.nvim_err_write('fail\n')
screen:expect([[ screen:expect([[
^ | ^ |
{0:~ }|*6 {0:~ }|*6
@ -2347,7 +2348,7 @@ describe('API', function()
helpers.poke_eventloop() helpers.poke_eventloop()
-- shows up to &cmdheight lines -- shows up to &cmdheight lines
nvim_async('err_write', 'more fail\ntoo fail\n') async_meths.nvim_err_write('more fail\ntoo fail\n')
screen:expect([[ screen:expect([[
| |
{0:~ }|*3 {0:~ }|*3
@ -2360,7 +2361,7 @@ describe('API', function()
end) end)
it('NUL bytes in message', function() it('NUL bytes in message', function()
nvim_async('err_write', 'aaa\0bbb\0\0ccc\nddd\0\0\0eee\n') async_meths.nvim_err_write('aaa\0bbb\0\0ccc\nddd\0\0\0eee\n')
screen:expect { screen:expect {
grid = [[ grid = [[
| |
@ -2389,7 +2390,7 @@ describe('API', function()
end) end)
it('shows only one return prompt after all lines are shown', function() it('shows only one return prompt after all lines are shown', function()
nvim_async('err_writeln', 'FAILURE\nERROR\nEXCEPTION\nTRACEBACK') async_meths.nvim_err_writeln('FAILURE\nERROR\nEXCEPTION\nTRACEBACK')
screen:expect([[ screen:expect([[
| |
{0:~ }| {0:~ }|
@ -3394,8 +3395,7 @@ describe('API', function()
end) end)
it('can show highlighted line', function() it('can show highlighted line', function()
nvim_async( async_meths.nvim_echo(
'echo',
{ { 'msg_a' }, { 'msg_b', 'Statement' }, { 'msg_c', 'Special' } }, { { 'msg_a' }, { 'msg_b', 'Statement' }, { 'msg_c', 'Special' } },
true, true,
{} {}
@ -3410,7 +3410,7 @@ describe('API', function()
end) end)
it('can show highlighted multiline', function() it('can show highlighted multiline', function()
nvim_async('echo', { { 'msg_a\nmsg_a', 'Statement' }, { 'msg_b', 'Special' } }, true, {}) async_meths.nvim_echo({ { 'msg_a\nmsg_a', 'Statement' }, { 'msg_b', 'Special' } }, true, {})
screen:expect { screen:expect {
grid = [[ grid = [[
| |
@ -3431,7 +3431,7 @@ describe('API', function()
it('can disable saving message history', function() it('can disable saving message history', function()
command('set cmdheight=2') -- suppress Press ENTER command('set cmdheight=2') -- suppress Press ENTER
nvim_async('echo', { { 'msg\nmsg' }, { 'msg' } }, false, {}) async_meths.nvim_echo({ { 'msg\nmsg' }, { 'msg' } }, false, {})
eq('', exec_capture('messages')) eq('', exec_capture('messages'))
end) end)
end) end)

View File

@ -222,7 +222,7 @@ describe('swapfile detection', function()
screen2:expect(expected_no_dialog) screen2:expect(expected_no_dialog)
-- With API call and shortmess+=F -- With API call and shortmess+=F
async_meths.command('edit %') async_meths.nvim_command('edit %')
screen2:expect { screen2:expect {
any = [[Found a swap file by the name ".*]] any = [[Found a swap file by the name ".*]]
.. [[Xtest_swapdialog_dir[/\].*]] .. [[Xtest_swapdialog_dir[/\].*]]

View File

@ -311,18 +311,6 @@ function module.expect_exit(fn_or_timeout, ...)
end end
end end
-- Evaluates a Vimscript expression.
-- Fails on Vimscript error, but does not update v:errmsg.
function module.eval(expr)
return module.request('nvim_eval', expr)
end
-- Executes a Vimscript function via RPC.
-- Fails on Vimscript error, but does not update v:errmsg.
function module.call(name, ...)
return module.request('nvim_call_function', name, { ... })
end
-- Executes a Vimscript function via Lua. -- Executes a Vimscript function via Lua.
-- Fails on Vimscript error, but does not update v:errmsg. -- Fails on Vimscript error, but does not update v:errmsg.
function module.call_lua(name, ...) function module.call_lua(name, ...)
@ -598,8 +586,7 @@ function module.set_shell_powershell(fake)
end end
function module.create_callindex(func) function module.create_callindex(func)
local table = {} return setmetatable({}, {
setmetatable(table, {
__index = function(tbl, arg1) __index = function(tbl, arg1)
local ret = function(...) local ret = function(...)
return func(arg1, ...) return func(arg1, ...)
@ -608,36 +595,29 @@ function module.create_callindex(func)
return ret return ret
end, end,
}) })
return table
end
local function ui(method, ...)
return module.request('nvim_ui_' .. method, ...)
end end
function module.nvim_async(method, ...) function module.nvim_async(method, ...)
session:notify('nvim_' .. method, ...) session:notify(method, ...)
end
-- Executes a Vimscript function via RPC.
-- Fails on Vimscript error, but does not update v:errmsg.
function module.call(name, ...)
return module.request('nvim_call_function', name, { ... })
end end
module.async_meths = module.create_callindex(module.nvim_async) module.async_meths = module.create_callindex(module.nvim_async)
module.uimeths = module.create_callindex(ui)
local function create_bridge(request, call) module.rpc = {
local function nvim(method, ...) fn = module.create_callindex(module.call),
if vim.startswith(method, 'nvim_') then api = module.create_callindex(module.request),
return request(method, ...) }
end
return request('nvim_' .. method, ...)
end
return { module.lua = {
fn = module.create_callindex(call), fn = module.create_callindex(module.call_lua),
api = module.create_callindex(nvim), api = module.create_callindex(module.request_lua),
} }
end
module.rpc = create_bridge(module.request, module.call)
module.lua = create_bridge(module.request_lua, module.call_lua)
module.describe_lua_and_rpc = function(describe) module.describe_lua_and_rpc = function(describe)
return function(what, tests) return function(what, tests)
@ -664,10 +644,14 @@ end
-- v:errmsg will not be updated. -- v:errmsg will not be updated.
module.command = module.api.nvim_command module.command = module.api.nvim_command
-- Evaluates a Vimscript expression.
-- Fails on Vimscript error, but does not update v:errmsg.
module.eval = module.api.nvim_eval
function module.poke_eventloop() function module.poke_eventloop()
-- Execute 'nvim_eval' (a deferred function) to -- Execute 'nvim_eval' (a deferred function) to
-- force at least one main_loop iteration -- force at least one main_loop iteration
session:request('nvim_eval', '1') module.api.nvim_eval('1')
end end
function module.buf_lines(bufnr) function module.buf_lines(bufnr)
@ -832,7 +816,7 @@ end
--- @param code string --- @param code string
--- @return any --- @return any
function module.exec_lua(code, ...) function module.exec_lua(code, ...)
return module.api.exec_lua(code, { ... }) return module.api.nvim_exec_lua(code, { ... })
end end
function module.get_pathsep() function module.get_pathsep()

View File

@ -162,7 +162,7 @@ describe('luaeval()', function()
return sp('map', '[' .. val .. ']') return sp('map', '[' .. val .. ']')
end end
local function luaevalarg(argexpr, expr) local function luaevalarg(argexpr, expr)
return eval(([=[ return eval((([=[
[ [
extend(g:, {'_ret': luaeval(%s, %s)})._ret, extend(g:, {'_ret': luaeval(%s, %s)})._ret,
type(g:_ret)==type({})&&has_key(g:_ret, '_TYPE') type(g:_ret)==type({})&&has_key(g:_ret, '_TYPE')
@ -172,7 +172,7 @@ describe('luaeval()', function()
get(g:_ret, '_VAL', g:_ret) get(g:_ret, '_VAL', g:_ret)
] ]
: [0, g:_ret]][1] : [0, g:_ret]][1]
]=]):format(expr or '"_A"', argexpr):gsub('\n', '')) ]=]):format(expr or '"_A"', argexpr):gsub('\n', '')))
end end
it('correctly passes special dictionaries', function() it('correctly passes special dictionaries', function()

View File

@ -151,7 +151,7 @@ describe('no crash when TermOpen autocommand', function()
it('processes job exit event when using termopen()', function() it('processes job exit event when using termopen()', function()
command([[autocmd TermOpen * call input('')]]) command([[autocmd TermOpen * call input('')]])
async_meths.command('terminal foobar') async_meths.nvim_command('terminal foobar')
screen:expect { screen:expect {
grid = [[ grid = [[
| |
@ -181,7 +181,7 @@ describe('no crash when TermOpen autocommand', function()
it('wipes buffer and processes events when using termopen()', function() it('wipes buffer and processes events when using termopen()', function()
command([[autocmd TermOpen * bwipe! | call input('')]]) command([[autocmd TermOpen * bwipe! | call input('')]])
async_meths.command('terminal foobar') async_meths.nvim_command('terminal foobar')
screen:expect { screen:expect {
grid = [[ grid = [[
| |
@ -202,7 +202,7 @@ describe('no crash when TermOpen autocommand', function()
it('wipes buffer and processes events when using nvim_open_term()', function() it('wipes buffer and processes events when using nvim_open_term()', function()
command([[autocmd TermOpen * bwipe! | call input('')]]) command([[autocmd TermOpen * bwipe! | call input('')]])
async_meths.open_term(0, {}) async_meths.nvim_open_term(0, {})
screen:expect { screen:expect {
grid = [[ grid = [[
| |

View File

@ -1039,7 +1039,7 @@ stack traceback:
end) end)
it('supports nvim_echo messages with multiple attrs', function() it('supports nvim_echo messages with multiple attrs', function()
async_meths.echo( async_meths.nvim_echo(
{ { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } }, { { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } },
true, true,
{} {}
@ -1403,7 +1403,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
end) end)
it('supports nvim_echo messages with multiple attrs', function() it('supports nvim_echo messages with multiple attrs', function()
async_meths.echo( async_meths.nvim_echo(
{ { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } }, { { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } },
true, true,
{} {}
@ -1521,7 +1521,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
end) end)
it('consecutive calls to win_move_statusline() work after multiline message #21014', function() it('consecutive calls to win_move_statusline() work after multiline message #21014', function()
async_meths.exec( async_meths.nvim_exec(
[[ [[
echo "\n" echo "\n"
call win_move_statusline(0, -4) call win_move_statusline(0, -4)
@ -2196,7 +2196,7 @@ aliquip ex ea commodo consequat.]]
} }
-- not processed while command is executing -- not processed while command is executing
async_meths.ui_try_resize(35, 5) async_meths.nvim_ui_try_resize(35, 5)
-- TODO(bfredl): ideally it should be processed just -- TODO(bfredl): ideally it should be processed just
-- before the "press ENTER" prompt though -- before the "press ENTER" prompt though

View File

@ -2527,7 +2527,7 @@ describe('builtin popupmenu', function()
]]) ]])
end end
feed('<C-E>') feed('<C-E>')
async_meths.call_function('input', { '', '', 'sign' }) async_meths.nvim_call_function('input', { '', '', 'sign' })
if multigrid then if multigrid then
screen:expect { screen:expect {
grid = [[ grid = [[

View File

@ -314,13 +314,13 @@ describe('context functions', function()
} }
local with_jumps = { local with_jumps = {
['jumps'] = eval(([[ ['jumps'] = eval((([[
filter(map(add( filter(map(add(
getjumplist()[0], { 'bufnr': bufnr('%'), 'lnum': getcurpos()[1] }), getjumplist()[0], { 'bufnr': bufnr('%'), 'lnum': getcurpos()[1] }),
'filter( 'filter(
{ "f": expand("#".v:val.bufnr.":p"), "l": v:val.lnum }, { "f": expand("#".v:val.bufnr.":p"), "l": v:val.lnum },
{ k, v -> k != "l" || v != 1 })'), '!empty(v:val.f)') { k, v -> k != "l" || v != 1 })'), '!empty(v:val.f)')
]]):gsub('\n', '')), ]]):gsub('\n', ''))),
} }
local with_bufs = { local with_bufs = {

View File

@ -414,19 +414,19 @@ describe('confirm()', function()
-- screen:expect() calls are needed to avoid feeding input too early -- screen:expect() calls are needed to avoid feeding input too early
screen:expect({ any = '%[No Name%]' }) screen:expect({ any = '%[No Name%]' })
async_meths.command([[let a = confirm('Press O to proceed')]]) async_meths.nvim_command([[let a = confirm('Press O to proceed')]])
screen:expect({ any = '{CONFIRM:.+: }' }) screen:expect({ any = '{CONFIRM:.+: }' })
feed('o') feed('o')
screen:expect({ any = '%[No Name%]' }) screen:expect({ any = '%[No Name%]' })
eq(1, api.nvim_get_var('a')) eq(1, api.nvim_get_var('a'))
async_meths.command([[let a = 'Are you sure?'->confirm("&Yes\n&No")]]) async_meths.nvim_command([[let a = 'Are you sure?'->confirm("&Yes\n&No")]])
screen:expect({ any = '{CONFIRM:.+: }' }) screen:expect({ any = '{CONFIRM:.+: }' })
feed('y') feed('y')
screen:expect({ any = '%[No Name%]' }) screen:expect({ any = '%[No Name%]' })
eq(1, api.nvim_get_var('a')) eq(1, api.nvim_get_var('a'))
async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No")]]) async_meths.nvim_command([[let a = confirm('Are you sure?', "&Yes\n&No")]])
screen:expect({ any = '{CONFIRM:.+: }' }) screen:expect({ any = '{CONFIRM:.+: }' })
feed('n') feed('n')
screen:expect({ any = '%[No Name%]' }) screen:expect({ any = '%[No Name%]' })
@ -435,26 +435,26 @@ describe('confirm()', function()
-- Not possible to match Vim's CTRL-C test here as CTRL-C always sets got_int in Nvim. -- Not possible to match Vim's CTRL-C test here as CTRL-C always sets got_int in Nvim.
-- confirm() should return 0 when pressing ESC. -- confirm() should return 0 when pressing ESC.
async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No")]]) async_meths.nvim_command([[let a = confirm('Are you sure?', "&Yes\n&No")]])
screen:expect({ any = '{CONFIRM:.+: }' }) screen:expect({ any = '{CONFIRM:.+: }' })
feed('<Esc>') feed('<Esc>')
screen:expect({ any = '%[No Name%]' }) screen:expect({ any = '%[No Name%]' })
eq(0, api.nvim_get_var('a')) eq(0, api.nvim_get_var('a'))
-- Default choice is returned when pressing <CR>. -- Default choice is returned when pressing <CR>.
async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No")]]) async_meths.nvim_command([[let a = confirm('Are you sure?', "&Yes\n&No")]])
screen:expect({ any = '{CONFIRM:.+: }' }) screen:expect({ any = '{CONFIRM:.+: }' })
feed('<CR>') feed('<CR>')
screen:expect({ any = '%[No Name%]' }) screen:expect({ any = '%[No Name%]' })
eq(1, api.nvim_get_var('a')) eq(1, api.nvim_get_var('a'))
async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No", 2)]]) async_meths.nvim_command([[let a = confirm('Are you sure?', "&Yes\n&No", 2)]])
screen:expect({ any = '{CONFIRM:.+: }' }) screen:expect({ any = '{CONFIRM:.+: }' })
feed('<CR>') feed('<CR>')
screen:expect({ any = '%[No Name%]' }) screen:expect({ any = '%[No Name%]' })
eq(2, api.nvim_get_var('a')) eq(2, api.nvim_get_var('a'))
async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No", 0)]]) async_meths.nvim_command([[let a = confirm('Are you sure?', "&Yes\n&No", 0)]])
screen:expect({ any = '{CONFIRM:.+: }' }) screen:expect({ any = '{CONFIRM:.+: }' })
feed('<CR>') feed('<CR>')
screen:expect({ any = '%[No Name%]' }) screen:expect({ any = '%[No Name%]' })
@ -462,7 +462,9 @@ describe('confirm()', function()
-- Test with the {type} 4th argument -- Test with the {type} 4th argument
for _, type in ipairs({ 'Error', 'Question', 'Info', 'Warning', 'Generic' }) do for _, type in ipairs({ 'Error', 'Question', 'Info', 'Warning', 'Generic' }) do
async_meths.command(([[let a = confirm('Are you sure?', "&Yes\n&No", 1, '%s')]]):format(type)) async_meths.nvim_command(
([[let a = confirm('Are you sure?', "&Yes\n&No", 1, '%s')]]):format(type)
)
screen:expect({ any = '{CONFIRM:.+: }' }) screen:expect({ any = '{CONFIRM:.+: }' })
feed('y') feed('y')
screen:expect({ any = '%[No Name%]' }) screen:expect({ any = '%[No Name%]' })
@ -518,7 +520,7 @@ describe('confirm()', function()
feed(':call nvim_command("edit x")<cr>') feed(':call nvim_command("edit x")<cr>')
check_and_clear(':call nvim_command("edit |\n') check_and_clear(':call nvim_command("edit |\n')
async_meths.command('edit x') async_meths.nvim_command('edit x')
check_and_clear(' |\n') check_and_clear(' |\n')
end) end)
end) end)

View File

@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local feed, eq, eval, ok = helpers.feed, helpers.eq, helpers.eval, helpers.ok local feed, eq, eval, ok = helpers.feed, helpers.eq, helpers.eval, helpers.ok
local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run local source, async_meths, run = helpers.source, helpers.async_meths, helpers.run
local clear, command, fn = helpers.clear, helpers.command, helpers.fn local clear, command, fn = helpers.clear, helpers.command, helpers.fn
local exc_exec = helpers.exc_exec local exc_exec = helpers.exc_exec
local api = helpers.api local api = helpers.api
@ -52,9 +52,9 @@ describe('timers', function()
endfunc endfunc
]]) ]])
eval("timer_start(10, 'MyHandler', {'repeat': -1})") eval("timer_start(10, 'MyHandler', {'repeat': -1})")
nvim_async('command', 'sleep 10') async_meths.nvim_command('sleep 10')
eq(-1, eval('g:val')) -- timer did nothing yet. eq(-1, eval('g:val')) -- timer did nothing yet.
nvim_async('command', 'let g:val = 0') async_meths.nvim_command('let g:val = 0')
run(nil, nil, nil, load_adjust(20)) run(nil, nil, nil, load_adjust(20))
retry(nil, nil, function() retry(nil, nil, function()
eq(2, eval('g:val')) eq(2, eval('g:val'))
@ -70,7 +70,7 @@ describe('timers', function()
end) end)
it('can be started during sleep', function() it('can be started during sleep', function()
nvim_async('command', 'sleep 10') async_meths.nvim_command('sleep 10')
-- this also tests that remote requests works during sleep -- this also tests that remote requests works during sleep
eq(0, eval("[timer_start(10, 'MyHandler', {'repeat': 2}), g:val][1]")) eq(0, eval("[timer_start(10, 'MyHandler', {'repeat': 2}), g:val][1]"))
run(nil, nil, nil, load_adjust(20)) run(nil, nil, nil, load_adjust(20))
@ -94,7 +94,7 @@ describe('timers', function()
it('are triggered in blocking getchar() call', function() it('are triggered in blocking getchar() call', function()
command("call timer_start(5, 'MyHandler', {'repeat': -1})") command("call timer_start(5, 'MyHandler', {'repeat': -1})")
nvim_async('command', 'let g:val = 0 | let g:c = getchar()') async_meths.nvim_command('let g:val = 0 | let g:c = getchar()')
retry(nil, nil, function() retry(nil, nil, function()
local val = eval('g:val') local val = eval('g:val')
ok(val >= 2, '>= 2', tostring(val)) ok(val >= 2, '>= 2', tostring(val))
@ -128,8 +128,10 @@ describe('timers', function()
redraw redraw
endfunc endfunc
]]) ]])
nvim_async('command', 'let g:c2 = getchar()') async_meths.nvim_command('let g:c2 = getchar()')
nvim_async('command', 'call timer_start(' .. load_adjust(100) .. ", 'AddItem', {'repeat': -1})") async_meths.nvim_command(
'call timer_start(' .. load_adjust(100) .. ", 'AddItem', {'repeat': -1})"
)
screen:expect([[ screen:expect([[
^ITEM 1 | ^ITEM 1 |
@ -137,7 +139,7 @@ describe('timers', function()
{1:~ }|*3 {1:~ }|*3
| |
]]) ]])
nvim_async('command', 'let g:cont = 1') async_meths.nvim_command('let g:cont = 1')
screen:expect([[ screen:expect([[
^ITEM 1 | ^ITEM 1 |