aboutsummaryrefslogtreecommitdiff
path: root/test/functional/autocmd
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-01-12 13:11:28 +0000
committerLewis Russell <lewis6991@gmail.com>2024-01-12 17:53:27 +0000
commit4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e (patch)
tree0cbb2cf8dac8b4f43109dc6f7a4051dfbea23f12 /test/functional/autocmd
parentc30f2e3182e3b50e7c03932027ac55edfc8ada4a (diff)
downloadrneovim-4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e.tar.gz
rneovim-4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e.tar.bz2
rneovim-4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e.zip
test: normalise nvim bridge functions
- remove helpers.cur*meths - remove helpers.nvim
Diffstat (limited to 'test/functional/autocmd')
-rw-r--r--test/functional/autocmd/autocmd_spec.lua3
-rw-r--r--test/functional/autocmd/searchwrapped_spec.lua4
-rw-r--r--test/functional/autocmd/tabclose_spec.lua73
-rw-r--r--test/functional/autocmd/tabnewentered_spec.lua38
-rw-r--r--test/functional/autocmd/termxx_spec.lua16
-rw-r--r--test/functional/autocmd/textyankpost_spec.lua4
6 files changed, 67 insertions, 71 deletions
diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua
index 5088ef8031..9ed3c5fbad 100644
--- a/test/functional/autocmd/autocmd_spec.lua
+++ b/test/functional/autocmd/autocmd_spec.lua
@@ -17,7 +17,6 @@ local expect = helpers.expect
local command = helpers.command
local exc_exec = helpers.exc_exec
local exec_lua = helpers.exec_lua
-local curbufmeths = helpers.curbufmeths
local retry = helpers.retry
local source = helpers.source
@@ -144,7 +143,7 @@ describe('autocmd', function()
describe('BufLeave autocommand', function()
it('can wipe out the buffer created by :edit which triggered autocmd', function()
meths.nvim_set_option_value('hidden', true, {})
- curbufmeths.set_lines(0, 1, false, {
+ meths.nvim_buf_set_lines(0, 0, 1, false, {
'start of test file xx',
'end of test file xx',
})
diff --git a/test/functional/autocmd/searchwrapped_spec.lua b/test/functional/autocmd/searchwrapped_spec.lua
index 83600f6689..8d25106680 100644
--- a/test/functional/autocmd/searchwrapped_spec.lua
+++ b/test/functional/autocmd/searchwrapped_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command = helpers.command
-local curbufmeths = helpers.curbufmeths
+local meths = helpers.meths
local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
@@ -13,7 +13,7 @@ describe('autocmd SearchWrapped', function()
command('set ignorecase')
command('let g:test = 0')
command('autocmd! SearchWrapped * let g:test += 1')
- curbufmeths.set_lines(0, 1, false, {
+ meths.nvim_buf_set_lines(0, 0, 1, false, {
'The quick brown fox',
'jumps over the lazy dog',
})
diff --git a/test/functional/autocmd/tabclose_spec.lua b/test/functional/autocmd/tabclose_spec.lua
index c5a2b42273..34f5178158 100644
--- a/test/functional/autocmd/tabclose_spec.lua
+++ b/test/functional/autocmd/tabclose_spec.lua
@@ -1,5 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
-local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
+local clear, eq = helpers.clear, helpers.eq
+local meths = helpers.meths
+local command = helpers.command
describe('TabClosed', function()
before_each(clear)
@@ -7,75 +9,70 @@ describe('TabClosed', function()
describe('au TabClosed', function()
describe('with * as <afile>', function()
it('matches when closing any tab', function()
- nvim(
- 'command',
+ command(
'au! TabClosed * echom "tabclosed:".expand("<afile>").":".expand("<amatch>").":".tabpagenr()'
)
repeat
- nvim('command', 'tabnew')
- until nvim('eval', 'tabpagenr()') == 6 -- current tab is now 6
- eq('tabclosed:6:6:5', nvim('exec', 'tabclose', true)) -- close last 6, current tab is now 5
- eq('tabclosed:5:5:4', nvim('exec', 'close', true)) -- close last window on tab, closes tab
- eq('tabclosed:2:2:3', nvim('exec', '2tabclose', true)) -- close tab 2, current tab is now 3
- eq('tabclosed:1:1:2\ntabclosed:1:1:1', nvim('exec', 'tabonly', true)) -- close tabs 1 and 2
+ command('tabnew')
+ until meths.nvim_eval('tabpagenr()') == 6 -- current tab is now 6
+ eq('tabclosed:6:6:5', meths.nvim_exec('tabclose', true)) -- close last 6, current tab is now 5
+ eq('tabclosed:5:5:4', meths.nvim_exec('close', true)) -- close last window on tab, closes tab
+ eq('tabclosed:2:2:3', meths.nvim_exec('2tabclose', true)) -- close tab 2, current tab is now 3
+ eq('tabclosed:1:1:2\ntabclosed:1:1:1', meths.nvim_exec('tabonly', true)) -- close tabs 1 and 2
end)
it('is triggered when closing a window via bdelete from another tab', function()
- nvim(
- 'command',
+ command(
'au! TabClosed * echom "tabclosed:".expand("<afile>").":".expand("<amatch>").":".tabpagenr()'
)
- nvim('command', '1tabedit Xtestfile')
- nvim('command', '1tabedit Xtestfile')
- nvim('command', 'normal! 1gt')
- eq({ 1, 3 }, nvim('eval', '[tabpagenr(), tabpagenr("$")]'))
- eq('tabclosed:2:2:1\ntabclosed:2:2:1', nvim('exec', 'bdelete Xtestfile', true))
- eq({ 1, 1 }, nvim('eval', '[tabpagenr(), tabpagenr("$")]'))
+ command('1tabedit Xtestfile')
+ command('1tabedit Xtestfile')
+ command('normal! 1gt')
+ eq({ 1, 3 }, meths.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
+ eq('tabclosed:2:2:1\ntabclosed:2:2:1', meths.nvim_exec('bdelete Xtestfile', true))
+ eq({ 1, 1 }, meths.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
end)
it('is triggered when closing a window via bdelete from current tab', function()
- nvim(
- 'command',
+ command(
'au! TabClosed * echom "tabclosed:".expand("<afile>").":".expand("<amatch>").":".tabpagenr()'
)
- nvim('command', 'file Xtestfile1')
- nvim('command', '1tabedit Xtestfile2')
- nvim('command', '1tabedit Xtestfile2')
+ command('file Xtestfile1')
+ command('1tabedit Xtestfile2')
+ command('1tabedit Xtestfile2')
-- Only one tab is closed, and the alternate file is used for the other.
- eq({ 2, 3 }, nvim('eval', '[tabpagenr(), tabpagenr("$")]'))
- eq('tabclosed:2:2:2', nvim('exec', 'bdelete Xtestfile2', true))
- eq('Xtestfile1', nvim('eval', 'bufname("")'))
+ eq({ 2, 3 }, meths.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
+ eq('tabclosed:2:2:2', meths.nvim_exec('bdelete Xtestfile2', true))
+ eq('Xtestfile1', meths.nvim_eval('bufname("")'))
end)
end)
describe('with NR as <afile>', function()
it('matches when closing a tab whose index is NR', function()
- nvim(
- 'command',
+ command(
'au! TabClosed * echom "tabclosed:".expand("<afile>").":".expand("<amatch>").":".tabpagenr()'
)
- nvim('command', 'au! TabClosed 2 echom "tabclosed:match"')
+ command('au! TabClosed 2 echom "tabclosed:match"')
repeat
- nvim('command', 'tabnew')
- until nvim('eval', 'tabpagenr()') == 7 -- current tab is now 7
+ command('tabnew')
+ until meths.nvim_eval('tabpagenr()') == 7 -- current tab is now 7
-- sanity check, we shouldn't match on tabs with numbers other than 2
- eq('tabclosed:7:7:6', nvim('exec', 'tabclose', true))
+ eq('tabclosed:7:7:6', meths.nvim_exec('tabclose', true))
-- close tab page 2, current tab is now 5
- eq('tabclosed:2:2:5\ntabclosed:match', nvim('exec', '2tabclose', true))
+ eq('tabclosed:2:2:5\ntabclosed:match', meths.nvim_exec('2tabclose', true))
end)
end)
describe('with close', function()
it('is triggered', function()
- nvim(
- 'command',
+ command(
'au! TabClosed * echom "tabclosed:".expand("<afile>").":".expand("<amatch>").":".tabpagenr()'
)
- nvim('command', 'tabedit Xtestfile')
- eq({ 2, 2 }, nvim('eval', '[tabpagenr(), tabpagenr("$")]'))
- eq('tabclosed:2:2:1', nvim('exec', 'close', true))
- eq({ 1, 1 }, nvim('eval', '[tabpagenr(), tabpagenr("$")]'))
+ command('tabedit Xtestfile')
+ eq({ 2, 2 }, meths.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
+ eq('tabclosed:2:2:1', meths.nvim_exec('close', true))
+ eq({ 1, 1 }, meths.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
end)
end)
end)
diff --git a/test/functional/autocmd/tabnewentered_spec.lua b/test/functional/autocmd/tabnewentered_spec.lua
index fd4a16a298..cdde9ad247 100644
--- a/test/functional/autocmd/tabnewentered_spec.lua
+++ b/test/functional/autocmd/tabnewentered_spec.lua
@@ -6,7 +6,7 @@ local dedent = helpers.dedent
local eval = helpers.eval
local eq = helpers.eq
local feed = helpers.feed
-local nvim = helpers.nvim
+local meths = helpers.meths
local exec_capture = helpers.exec_capture
describe('TabNewEntered', function()
@@ -14,33 +14,33 @@ describe('TabNewEntered', function()
describe('with * as <afile>', function()
it('matches when entering any new tab', function()
clear()
- nvim('command', 'au! TabNewEntered * echom "tabnewentered:".tabpagenr().":".bufnr("")')
- eq('tabnewentered:2:2', nvim('exec', 'tabnew', true))
- eq('tabnewentered:3:3', nvim('exec', 'tabnew test.x2', true))
+ command('au! TabNewEntered * echom "tabnewentered:".tabpagenr().":".bufnr("")')
+ eq('tabnewentered:2:2', meths.nvim_exec('tabnew', true))
+ eq('tabnewentered:3:3', meths.nvim_exec('tabnew test.x2', true))
end)
end)
describe('with FILE as <afile>', function()
it('matches when opening a new tab for FILE', function()
clear()
- nvim('command', 'au! TabNewEntered Xtest-tabnewentered echom "tabnewentered:match"')
- eq('tabnewentered:match', nvim('exec', 'tabnew Xtest-tabnewentered', true))
+ command('au! TabNewEntered Xtest-tabnewentered echom "tabnewentered:match"')
+ eq('tabnewentered:match', meths.nvim_exec('tabnew Xtest-tabnewentered', true))
end)
end)
describe('with CTRL-W T', function()
it('works when opening a new tab with CTRL-W T', function()
clear()
- nvim('command', 'au! TabNewEntered * echom "entered"')
- nvim('command', 'tabnew test.x2')
- nvim('command', 'split')
- eq('entered', nvim('exec', 'execute "normal \\<C-W>T"', true))
+ command('au! TabNewEntered * echom "entered"')
+ command('tabnew test.x2')
+ command('split')
+ eq('entered', meths.nvim_exec('execute "normal \\<C-W>T"', true))
end)
end)
describe('with tab split #4334', function()
it('works when create a tab by using tab split command', function()
clear()
- nvim('command', 'au! TabNewEntered * let b:entered = "entered"')
- nvim('command', 'tab split')
- eq('entered', nvim('exec', 'echo b:entered', true))
+ command('au! TabNewEntered * let b:entered = "entered"')
+ command('tab split')
+ eq('entered', meths.nvim_exec('echo b:entered', true))
end)
end)
end)
@@ -50,20 +50,20 @@ describe('TabEnter', function()
before_each(clear)
it('has correct previous tab when entering any new tab', function()
command('augroup TEMP')
- nvim('command', 'au! TabEnter * echom "tabenter:".tabpagenr().":".tabpagenr(\'#\')')
+ command('au! TabEnter * echom "tabenter:".tabpagenr().":".tabpagenr(\'#\')')
command('augroup END')
- eq('tabenter:2:1', nvim('exec', 'tabnew', true))
- eq('tabenter:3:2', nvim('exec', 'tabnew test.x2', true))
+ eq('tabenter:2:1', meths.nvim_exec('tabnew', true))
+ eq('tabenter:3:2', meths.nvim_exec('tabnew test.x2', true))
command('augroup! TEMP')
end)
it('has correct previous tab when entering any preexisting tab', function()
command('tabnew')
command('tabnew')
command('augroup TEMP')
- nvim('command', 'au! TabEnter * echom "tabenter:".tabpagenr().":".tabpagenr(\'#\')')
+ command('au! TabEnter * echom "tabenter:".tabpagenr().":".tabpagenr(\'#\')')
command('augroup END')
- eq('tabenter:1:3', nvim('exec', 'tabnext', true))
- eq('tabenter:2:1', nvim('exec', 'tabnext', true))
+ eq('tabenter:1:3', meths.nvim_exec('tabnext', true))
+ eq('tabenter:2:1', meths.nvim_exec('tabnext', true))
command('augroup! TEMP')
end)
end)
diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua
index caa7209de1..0243fdf600 100644
--- a/test/functional/autocmd/termxx_spec.lua
+++ b/test/functional/autocmd/termxx_spec.lua
@@ -2,7 +2,7 @@ local uv = vim.uv
local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
-local clear, command, nvim, testprg = helpers.clear, helpers.command, helpers.nvim, helpers.testprg
+local clear, command, testprg = helpers.clear, helpers.command, helpers.testprg
local eval, eq, neq, retry = helpers.eval, helpers.eq, helpers.neq, helpers.retry
local matches = helpers.matches
local ok = helpers.ok
@@ -16,13 +16,13 @@ local is_os = helpers.is_os
describe('autocmd TermClose', function()
before_each(function()
clear()
- nvim('set_option_value', 'shell', testprg('shell-test'), {})
+ meths.nvim_set_option_value('shell', testprg('shell-test'), {})
command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=')
end)
local function test_termclose_delete_own_buf()
-- The terminal process needs to keep running so that TermClose isn't triggered immediately.
- nvim('set_option_value', 'shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
+ meths.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
command('autocmd TermClose * bdelete!')
command('terminal')
matches(
@@ -56,7 +56,7 @@ describe('autocmd TermClose', function()
it('triggers when long-running terminal job gets stopped', function()
skip(is_os('win'))
- nvim('set_option_value', 'shell', is_os('win') and 'cmd.exe' or 'sh', {})
+ meths.nvim_set_option_value('shell', is_os('win') and 'cmd.exe' or 'sh', {})
command('autocmd TermClose * let g:test_termclose = 23')
command('terminal')
command('call jobstop(b:terminal_job_id)')
@@ -67,8 +67,8 @@ describe('autocmd TermClose', function()
it('kills job trapping SIGTERM', function()
skip(is_os('win'))
- nvim('set_option_value', 'shell', 'sh', {})
- nvim('set_option_value', 'shellcmdflag', '-c', {})
+ meths.nvim_set_option_value('shell', 'sh', {})
+ meths.nvim_set_option_value('shellcmdflag', '-c', {})
command(
[[ let g:test_job = jobstart('trap "" TERM && echo 1 && sleep 60', { ]]
.. [[ 'on_stdout': {-> execute('let g:test_job_started = 1')}, ]]
@@ -93,8 +93,8 @@ describe('autocmd TermClose', function()
it('kills PTY job trapping SIGHUP and SIGTERM', function()
skip(is_os('win'))
- nvim('set_option_value', 'shell', 'sh', {})
- nvim('set_option_value', 'shellcmdflag', '-c', {})
+ meths.nvim_set_option_value('shell', 'sh', {})
+ meths.nvim_set_option_value('shellcmdflag', '-c', {})
command(
[[ let g:test_job = jobstart('trap "" HUP TERM && echo 1 && sleep 60', { ]]
.. [[ 'pty': 1,]]
diff --git a/test/functional/autocmd/textyankpost_spec.lua b/test/functional/autocmd/textyankpost_spec.lua
index 4250c54834..964b5c0be4 100644
--- a/test/functional/autocmd/textyankpost_spec.lua
+++ b/test/functional/autocmd/textyankpost_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq
local feed, command, expect = helpers.feed, helpers.command, helpers.expect
-local curbufmeths, funcs, neq = helpers.curbufmeths, helpers.funcs, helpers.neq
+local meths, funcs, neq = helpers.meths, helpers.funcs, helpers.neq
describe('TextYankPost', function()
before_each(function()
@@ -14,7 +14,7 @@ describe('TextYankPost', function()
command('autocmd TextYankPost * let g:event = copy(v:event)')
command('autocmd TextYankPost * let g:count += 1')
- curbufmeths.set_lines(0, -1, true, {
+ meths.nvim_buf_set_lines(0, 0, -1, true, {
'foo\0bar',
'baz text',
})