aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-11-11 22:15:19 +0100
committerbfredl <bjorn.linse@gmail.com>2024-11-14 12:40:57 +0100
commite61228a214ebda9845db9462dad0a8c362d3963f (patch)
treefc5908c85c0cc6affc3bc325cd75f6efaeea95d8 /test/functional/vimscript
parent40dee8a2dcba996badaa6182eb34fde1694f92a3 (diff)
downloadrneovim-e61228a214ebda9845db9462dad0a8c362d3963f.tar.gz
rneovim-e61228a214ebda9845db9462dad0a8c362d3963f.tar.bz2
rneovim-e61228a214ebda9845db9462dad0a8c362d3963f.zip
fix(tests): needing two calls to setup a screen is cringe
Before calling "attach" a screen object is just a dummy container for (row, col) values whose purpose is to be sent as part of the "attach" function call anyway. Just create the screen in an attached state directly. Keep the complete (row, col, options) config together. It is still completely valid to later detach and re-attach as needed, including to another session.
Diffstat (limited to 'test/functional/vimscript')
-rw-r--r--test/functional/vimscript/api_functions_spec.lua3
-rw-r--r--test/functional/vimscript/eval_spec.lua7
-rw-r--r--test/functional/vimscript/execute_spec.lua4
-rw-r--r--test/functional/vimscript/has_spec.lua9
-rw-r--r--test/functional/vimscript/input_spec.lua1
-rw-r--r--test/functional/vimscript/match_functions_spec.lua1
-rw-r--r--test/functional/vimscript/system_spec.lua8
-rw-r--r--test/functional/vimscript/timer_spec.lua3
8 files changed, 7 insertions, 29 deletions
diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua
index 0dbbace8f8..5db8c24120 100644
--- a/test/functional/vimscript/api_functions_spec.lua
+++ b/test/functional/vimscript/api_functions_spec.lua
@@ -129,8 +129,6 @@ describe('eval-API', function()
end)
it('use buffer numbers and windows ids as handles', function()
- local screen = Screen.new(40, 8)
- screen:attach()
local bnr = eval("bufnr('')")
local bhnd = eval('nvim_get_current_buf()')
local wid = eval('win_getid()')
@@ -192,7 +190,6 @@ describe('eval-API', function()
it('are highlighted by vim.vim syntax file', function()
local screen = Screen.new(40, 8)
- screen:attach()
command('set ft=vim')
command('set rtp^=build/runtime/')
diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua
index 840e311dd8..de1a3d7c73 100644
--- a/test/functional/vimscript/eval_spec.lua
+++ b/test/functional/vimscript/eval_spec.lua
@@ -189,7 +189,6 @@ describe('uncaught exception', function()
it('multiline exception remains multiline #25350', function()
local screen = Screen.new(80, 11)
- screen:attach()
exec_lua([[
function _G.Oops()
error("oops")
@@ -230,8 +229,7 @@ describe('listing functions using :function', function()
end)
it('does not crash if another function is deleted while listing', function()
- local screen = Screen.new(80, 24)
- screen:attach()
+ local _ = Screen.new(80, 24)
matches(
'Vim%(function%):E454: Function list was modified$',
pcall_err(
@@ -264,8 +262,7 @@ describe('listing functions using :function', function()
end)
it('does not crash if the same function is deleted while listing', function()
- local screen = Screen.new(80, 24)
- screen:attach()
+ local _ = Screen.new(80, 24)
matches(
'Vim%(function%):E454: Function list was modified$',
pcall_err(
diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua
index 8caaea39a7..2404538e77 100644
--- a/test/functional/vimscript/execute_spec.lua
+++ b/test/functional/vimscript/execute_spec.lua
@@ -114,7 +114,6 @@ describe('execute()', function()
it('does not corrupt the command display #5422', function()
local screen = Screen.new(70, 7)
- screen:attach()
feed(':echo execute("hi ErrorMsg")<CR>')
screen:expect(
[[
@@ -136,7 +135,6 @@ describe('execute()', function()
it('places cursor correctly #6035', function()
local screen = Screen.new(40, 6)
- screen:attach()
source([=[
" test 1: non-silenced output goes as usual
function! Test1()
@@ -263,7 +261,6 @@ describe('execute()', function()
describe('{silent} argument', function()
it('captures & displays output for ""', function()
local screen = Screen.new(40, 5)
- screen:attach()
command('let g:mes = execute("echon 42", "")')
screen:expect([[
^ |
@@ -287,7 +284,6 @@ describe('execute()', function()
it('captures but does not display output for "silent"', function()
local screen = Screen.new(40, 5)
- screen:attach()
command('let g:mes = execute("echon 42")')
screen:expect([[
^ |
diff --git a/test/functional/vimscript/has_spec.lua b/test/functional/vimscript/has_spec.lua
index 1d2187be6b..ff90edfe30 100644
--- a/test/functional/vimscript/has_spec.lua
+++ b/test/functional/vimscript/has_spec.lua
@@ -4,6 +4,7 @@ local Screen = require('test.functional.ui.screen')
local clear = n.clear
local connect = n.connect
+local get_session = n.get_session
local eq = t.eq
local fn = n.fn
local is_os = t.is_os
@@ -74,12 +75,12 @@ describe('has()', function()
it('"gui_running"', function()
eq(0, fn.has('gui_running'))
- local tui = Screen.new(50, 15)
+ local tui_session = get_session()
local gui_session = connect(fn.serverstart())
- local gui = Screen.new(50, 15)
eq(0, fn.has('gui_running'))
- tui:attach({ ext_linegrid = true, rgb = true, stdin_tty = true, stdout_tty = true })
- gui:attach({ ext_multigrid = true, rgb = true }, gui_session)
+ local tui = Screen.new(50, 5, { rgb = true, stdin_tty = true, stdout_tty = true }, tui_session)
+ eq(0, fn.has('gui_running'))
+ local gui = Screen.new(50, 15, { ext_multigrid = true, rgb = true }, gui_session)
eq(1, fn.has('gui_running'))
tui:detach()
eq(1, fn.has('gui_running'))
diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua
index 0b774404eb..1995b033b9 100644
--- a/test/functional/vimscript/input_spec.lua
+++ b/test/functional/vimscript/input_spec.lua
@@ -17,7 +17,6 @@ local screen
before_each(function()
clear()
screen = Screen.new(25, 5)
- screen:attach()
source([[
hi Test ctermfg=Red guifg=Red term=bold
function CustomCompl(...)
diff --git a/test/functional/vimscript/match_functions_spec.lua b/test/functional/vimscript/match_functions_spec.lua
index 87c57f1c15..46c876da99 100644
--- a/test/functional/vimscript/match_functions_spec.lua
+++ b/test/functional/vimscript/match_functions_spec.lua
@@ -174,7 +174,6 @@ describe('matchaddpos()', function()
end)
it('works with zero length', function()
local screen = Screen.new(40, 5)
- screen:attach()
fn.setline(1, 'abcdef')
command('hi PreProc guifg=Red')
eq(4, fn.matchaddpos('PreProc', { { 1, 2, 0 } }, 3, 4))
diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua
index 792e4c46c3..b5c4972d7b 100644
--- a/test/functional/vimscript/system_spec.lua
+++ b/test/functional/vimscript/system_spec.lua
@@ -132,7 +132,6 @@ describe('system()', function()
before_each(function()
screen = Screen.new()
- screen:attach()
end)
if is_os('win') then
@@ -430,11 +429,6 @@ describe('systemlist()', function()
before_each(function()
screen = Screen.new()
- screen:attach()
- end)
-
- after_each(function()
- screen:detach()
end)
it('`echo` and waits for its return', function()
@@ -567,7 +561,6 @@ describe('shell :!', function()
it(':{range}! with powershell filter/redirect #16271 #19250', function()
local screen = Screen.new(500, 8)
- screen:attach()
local found = n.set_shell_powershell(true)
insert([[
3
@@ -598,7 +591,6 @@ describe('shell :!', function()
it(':{range}! without redirecting to buffer', function()
local screen = Screen.new(500, 10)
- screen:attach()
insert([[
3
1
diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua
index 1e484c9ff9..d1b8bfe5d9 100644
--- a/test/functional/vimscript/timer_spec.lua
+++ b/test/functional/vimscript/timer_spec.lua
@@ -108,7 +108,6 @@ describe('timers', function()
it('can invoke redraw in blocking getchar() call', function()
local screen = Screen.new(40, 6)
- screen:attach()
api.nvim_buf_set_lines(0, 0, -1, true, { 'ITEM 1', 'ITEM 2' })
source([[
@@ -225,7 +224,6 @@ describe('timers', function()
it("doesn't mess up the cmdline", function()
local screen = Screen.new(40, 6)
- screen:attach()
source([[
let g:val = 0
func! MyHandler(timer)
@@ -263,7 +261,6 @@ describe('timers', function()
it('can be triggered after an empty string <expr> mapping #17257', function()
local screen = Screen.new(40, 6)
- screen:attach()
command([=[imap <expr> <F2> [timer_start(0, { _ -> execute("throw 'x'", "") }), ''][-1]]=])
feed('i<F2>')
screen:expect({ any = 'E605: Exception not caught: x' })