From b536e0ba37addaea5507b054120e4c1e122c4405 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 15 Jan 2024 16:10:51 +0000 Subject: test: big cleanup followup Followup to 07a7c0ec --- test/functional/vimscript/ctx_functions_spec.lua | 4 ++-- test/functional/vimscript/input_spec.lua | 20 +++++++++++--------- test/functional/vimscript/timer_spec.lua | 18 ++++++++++-------- 3 files changed, 23 insertions(+), 19 deletions(-) (limited to 'test/functional/vimscript') diff --git a/test/functional/vimscript/ctx_functions_spec.lua b/test/functional/vimscript/ctx_functions_spec.lua index b8f9bbc92d..dc60a474f3 100644 --- a/test/functional/vimscript/ctx_functions_spec.lua +++ b/test/functional/vimscript/ctx_functions_spec.lua @@ -314,13 +314,13 @@ describe('context functions', function() } local with_jumps = { - ['jumps'] = eval(([[ + ['jumps'] = eval((([[ filter(map(add( getjumplist()[0], { 'bufnr': bufnr('%'), 'lnum': getcurpos()[1] }), 'filter( { "f": expand("#".v:val.bufnr.":p"), "l": v:val.lnum }, { k, v -> k != "l" || v != 1 })'), '!empty(v:val.f)') - ]]):gsub('\n', '')), + ]]):gsub('\n', ''))), } local with_bufs = { diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua index 6dd22078d6..b749d5a7f0 100644 --- a/test/functional/vimscript/input_spec.lua +++ b/test/functional/vimscript/input_spec.lua @@ -414,19 +414,19 @@ describe('confirm()', function() -- screen:expect() calls are needed to avoid feeding input too early 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:.+: }' }) feed('o') screen:expect({ any = '%[No Name%]' }) 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:.+: }' }) feed('y') screen:expect({ any = '%[No Name%]' }) 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:.+: }' }) feed('n') 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. -- 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:.+: }' }) feed('') screen:expect({ any = '%[No Name%]' }) eq(0, api.nvim_get_var('a')) -- Default choice is returned when pressing . - 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:.+: }' }) feed('') screen:expect({ any = '%[No Name%]' }) 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:.+: }' }) feed('') screen:expect({ any = '%[No Name%]' }) 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:.+: }' }) feed('') screen:expect({ any = '%[No Name%]' }) @@ -462,7 +462,9 @@ describe('confirm()', function() -- Test with the {type} 4th argument 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:.+: }' }) feed('y') screen:expect({ any = '%[No Name%]' }) @@ -518,7 +520,7 @@ describe('confirm()', function() feed(':call nvim_command("edit x")') check_and_clear(':call nvim_command("edit |\n') - async_meths.command('edit x') + async_meths.nvim_command('edit x') check_and_clear(' |\n') end) end) diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua index 3f53c21e7a..046d451888 100644 --- a/test/functional/vimscript/timer_spec.lua +++ b/test/functional/vimscript/timer_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') 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 exc_exec = helpers.exc_exec local api = helpers.api @@ -52,9 +52,9 @@ describe('timers', function() endfunc ]]) 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. - nvim_async('command', 'let g:val = 0') + async_meths.nvim_command('let g:val = 0') run(nil, nil, nil, load_adjust(20)) retry(nil, nil, function() eq(2, eval('g:val')) @@ -70,7 +70,7 @@ describe('timers', function() end) 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 eq(0, eval("[timer_start(10, 'MyHandler', {'repeat': 2}), g:val][1]")) run(nil, nil, nil, load_adjust(20)) @@ -94,7 +94,7 @@ describe('timers', function() it('are triggered in blocking getchar() call', function() 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() local val = eval('g:val') ok(val >= 2, '>= 2', tostring(val)) @@ -128,8 +128,10 @@ describe('timers', function() redraw endfunc ]]) - nvim_async('command', 'let g:c2 = getchar()') - nvim_async('command', 'call timer_start(' .. load_adjust(100) .. ", 'AddItem', {'repeat': -1})") + async_meths.nvim_command('let g:c2 = getchar()') + async_meths.nvim_command( + 'call timer_start(' .. load_adjust(100) .. ", 'AddItem', {'repeat': -1})" + ) screen:expect([[ ^ITEM 1 | @@ -137,7 +139,7 @@ describe('timers', function() {1:~ }|*3 | ]]) - nvim_async('command', 'let g:cont = 1') + async_meths.nvim_command('let g:cont = 1') screen:expect([[ ^ITEM 1 | -- cgit