aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2024-04-08 11:03:20 +0200
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2024-04-08 22:51:00 +0200
commit7035125b2b26aa68fcfb7cda39377ac79926a0f9 (patch)
treed194a3556a367b42505f9e7d26637e7cb3674928 /test/functional/api
parent978962f9a00ce75216d2c36b79397ef3d2b54096 (diff)
downloadrneovim-7035125b2b26aa68fcfb7cda39377ac79926a0f9.tar.gz
rneovim-7035125b2b26aa68fcfb7cda39377ac79926a0f9.tar.bz2
rneovim-7035125b2b26aa68fcfb7cda39377ac79926a0f9.zip
test: improve test conventions
Work on https://github.com/neovim/neovim/issues/27004.
Diffstat (limited to 'test/functional/api')
-rw-r--r--test/functional/api/autocmd_spec.lua22
-rw-r--r--test/functional/api/buffer_spec.lua32
-rw-r--r--test/functional/api/buffer_updates_spec.lua30
-rw-r--r--test/functional/api/command_spec.lua24
-rw-r--r--test/functional/api/extmark_spec.lua26
-rw-r--r--test/functional/api/highlight_spec.lua20
-rw-r--r--test/functional/api/keymap_spec.lua40
-rw-r--r--test/functional/api/menu_spec.lua8
-rw-r--r--test/functional/api/proc_spec.lua18
-rw-r--r--test/functional/api/server_notifications_spec.lua17
-rw-r--r--test/functional/api/server_requests_spec.lua28
-rw-r--r--test/functional/api/tabpage_spec.lua18
-rw-r--r--test/functional/api/ui_spec.lua20
-rw-r--r--test/functional/api/version_spec.lua6
-rw-r--r--test/functional/api/vim_spec.lua121
-rw-r--r--test/functional/api/window_spec.lua44
16 files changed, 235 insertions, 239 deletions
diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua
index e89abf6c64..b97647850c 100644
--- a/test/functional/api/autocmd_spec.lua
+++ b/test/functional/api/autocmd_spec.lua
@@ -1,14 +1,14 @@
-local helpers = require('test.functional.helpers')(after_each)
-
-local clear = helpers.clear
-local command = helpers.command
-local eq = helpers.eq
-local neq = helpers.neq
-local exec_lua = helpers.exec_lua
-local matches = helpers.matches
-local api = helpers.api
-local source = helpers.source
-local pcall_err = helpers.pcall_err
+local t = require('test.functional.testutil')(after_each)
+
+local clear = t.clear
+local command = t.command
+local eq = t.eq
+local neq = t.neq
+local exec_lua = t.exec_lua
+local matches = t.matches
+local api = t.api
+local source = t.source
+local pcall_err = t.pcall_err
before_each(clear)
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua
index 25b0405571..de56c16bd8 100644
--- a/test/functional/api/buffer_spec.lua
+++ b/test/functional/api/buffer_spec.lua
@@ -1,21 +1,21 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local clear = helpers.clear
-local eq = helpers.eq
-local ok = helpers.ok
-local describe_lua_and_rpc = helpers.describe_lua_and_rpc(describe)
-local api = helpers.api
-local fn = helpers.fn
-local request = helpers.request
-local exc_exec = helpers.exc_exec
-local exec_lua = helpers.exec_lua
-local feed_command = helpers.feed_command
-local insert = helpers.insert
+local clear = t.clear
+local eq = t.eq
+local ok = t.ok
+local describe_lua_and_rpc = t.describe_lua_and_rpc(describe)
+local api = t.api
+local fn = t.fn
+local request = t.request
+local exc_exec = t.exc_exec
+local exec_lua = t.exec_lua
+local feed_command = t.feed_command
+local insert = t.insert
local NIL = vim.NIL
-local command = helpers.command
-local feed = helpers.feed
-local pcall_err = helpers.pcall_err
-local assert_alive = helpers.assert_alive
+local command = t.command
+local feed = t.feed
+local pcall_err = t.pcall_err
+local assert_alive = t.assert_alive
describe('api/buf', function()
before_each(clear)
diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua
index 262ca40e28..715c469c76 100644
--- a/test/functional/api/buffer_updates_spec.lua
+++ b/test/functional/api/buffer_updates_spec.lua
@@ -1,13 +1,13 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
-local eq, ok = helpers.eq, helpers.ok
-local fn = helpers.fn
-local api = helpers.api
-local command, eval, next_msg = helpers.command, helpers.eval, helpers.next_msg
-local nvim_prog = helpers.nvim_prog
-local pcall_err = helpers.pcall_err
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
+local eq, ok = t.eq, t.ok
+local fn = t.fn
+local api = t.api
+local command, eval, next_msg = t.command, t.eval, t.next_msg
+local nvim_prog = t.nvim_prog
+local pcall_err = t.pcall_err
local sleep = vim.uv.sleep
-local write_file = helpers.write_file
+local write_file = t.write_file
local origlines = {
'original line 1',
@@ -34,7 +34,7 @@ local function sendkeys(keys)
end
local function open(activate, lines)
- local filename = helpers.tmpname()
+ local filename = t.tmpname()
write_file(filename, table.concat(lines, '\n') .. '\n', true)
command('edit ' .. filename)
local b = api.nvim_get_current_buf()
@@ -511,11 +511,11 @@ describe('API: buffer events:', function()
-- create several new sessions, in addition to our main API
local sessions = {}
- local pipe = helpers.new_pipename()
+ local pipe = t.new_pipename()
eval("serverstart('" .. pipe .. "')")
- sessions[1] = helpers.connect(pipe)
- sessions[2] = helpers.connect(pipe)
- sessions[3] = helpers.connect(pipe)
+ sessions[1] = t.connect(pipe)
+ sessions[2] = t.connect(pipe)
+ sessions[3] = t.connect(pipe)
local function request(sessionnr, method, ...)
local status, rv = sessions[sessionnr]:request(method, ...)
@@ -814,7 +814,7 @@ describe('API: buffer events:', function()
clear()
sleep(250)
-- response
- eq(true, helpers.request('nvim_buf_attach', 0, false, {}))
+ eq(true, t.request('nvim_buf_attach', 0, false, {}))
-- notification
eq({
[1] = 'notification',
diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua
index f73b9c8b13..29d96a1ff5 100644
--- a/test/functional/api/command_spec.lua
+++ b/test/functional/api/command_spec.lua
@@ -1,17 +1,17 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local NIL = vim.NIL
-local clear = helpers.clear
-local command = helpers.command
-local eq = helpers.eq
-local api = helpers.api
-local matches = helpers.matches
-local source = helpers.source
-local pcall_err = helpers.pcall_err
-local exec_lua = helpers.exec_lua
-local assert_alive = helpers.assert_alive
-local feed = helpers.feed
-local fn = helpers.fn
+local clear = t.clear
+local command = t.command
+local eq = t.eq
+local api = t.api
+local matches = t.matches
+local source = t.source
+local pcall_err = t.pcall_err
+local exec_lua = t.exec_lua
+local assert_alive = t.assert_alive
+local feed = t.feed
+local fn = t.fn
describe('nvim_get_commands', function()
local cmd_dict = {
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index 4cf96a4af6..1a96510d3d 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -1,20 +1,20 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local request = helpers.request
-local eq = helpers.eq
-local ok = helpers.ok
-local pcall_err = helpers.pcall_err
-local insert = helpers.insert
-local feed = helpers.feed
-local clear = helpers.clear
-local command = helpers.command
-local exec = helpers.exec
-local api = helpers.api
-local assert_alive = helpers.assert_alive
+local request = t.request
+local eq = t.eq
+local ok = t.ok
+local pcall_err = t.pcall_err
+local insert = t.insert
+local feed = t.feed
+local clear = t.clear
+local command = t.command
+local exec = t.exec
+local api = t.api
+local assert_alive = t.assert_alive
local function expect(contents)
- return eq(contents, helpers.curbuf_contents())
+ return eq(contents, t.curbuf_contents())
end
local function set_extmark(ns_id, id, line, col, opts)
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index 1973d3e1c7..4156af5901 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -1,14 +1,14 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
local Screen = require('test.functional.ui.screen')
-local eq, eval = helpers.eq, helpers.eval
-local command = helpers.command
-local exec_capture = helpers.exec_capture
-local api = helpers.api
-local fn = helpers.fn
-local pcall_err = helpers.pcall_err
-local ok = helpers.ok
-local assert_alive = helpers.assert_alive
+local eq, eval = t.eq, t.eval
+local command = t.command
+local exec_capture = t.exec_capture
+local api = t.api
+local fn = t.fn
+local pcall_err = t.pcall_err
+local ok = t.ok
+local assert_alive = t.assert_alive
describe('API: highlight', function()
clear()
diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua
index 4380e76486..d6a8b592d7 100644
--- a/test/functional/api/keymap_spec.lua
+++ b/test/functional/api/keymap_spec.lua
@@ -1,17 +1,17 @@
-local helpers = require('test.functional.helpers')(after_each)
-
-local clear = helpers.clear
-local command = helpers.command
-local eq, neq = helpers.eq, helpers.neq
-local exec_lua = helpers.exec_lua
-local exec = helpers.exec
-local feed = helpers.feed
-local fn = helpers.fn
-local api = helpers.api
-local source = helpers.source
-local pcall_err = helpers.pcall_err
-
-local shallowcopy = helpers.shallowcopy
+local t = require('test.functional.testutil')(after_each)
+
+local clear = t.clear
+local command = t.command
+local eq, neq = t.eq, t.neq
+local exec_lua = t.exec_lua
+local exec = t.exec
+local feed = t.feed
+local fn = t.fn
+local api = t.api
+local source = t.source
+local pcall_err = t.pcall_err
+
+local shallowcopy = t.shallowcopy
local sleep = vim.uv.sleep
local sid_api_client = -9
@@ -1114,7 +1114,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
feed('asdf\n')
eq(1, exec_lua [[return GlobalCount]])
- eq('\nNo mapping found', helpers.exec_capture('nmap asdf'))
+ eq('\nNo mapping found', t.exec_capture('nmap asdf'))
end)
it('no double-free when unmapping simplifiable lua mappings', function()
@@ -1138,13 +1138,13 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
feed('<C-I>\n')
eq(1, exec_lua [[return GlobalCount]])
- eq('\nNo mapping found', helpers.exec_capture('nmap <C-I>'))
+ eq('\nNo mapping found', t.exec_capture('nmap <C-I>'))
end)
it('can set descriptions on mappings', function()
api.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
eq(generate_mapargs('n', 'lhs', 'rhs', { desc = 'map description' }), get_mapargs('n', 'lhs'))
- eq('\nn lhs rhs\n map description', helpers.exec_capture('nmap lhs'))
+ eq('\nn lhs rhs\n map description', t.exec_capture('nmap lhs'))
end)
it('can define !-mode abbreviations with lua callbacks', function()
@@ -1290,7 +1290,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
it('does not crash when setting mapping in a non-existing buffer #13541', function()
pcall_err(api.nvim_buf_set_keymap, 100, '', 'lsh', 'irhs<Esc>', {})
- helpers.assert_alive()
+ t.assert_alive()
end)
it('can make lua mappings', function()
@@ -1372,7 +1372,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
feed('asdf\n')
eq(1, exec_lua [[return GlobalCount]])
- eq('\nNo mapping found', helpers.exec_capture('nmap asdf'))
+ eq('\nNo mapping found', t.exec_capture('nmap asdf'))
end)
it('no double-free when unmapping simplifiable lua mappings', function()
@@ -1396,6 +1396,6 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
feed('<C-I>\n')
eq(1, exec_lua [[return GlobalCount]])
- eq('\nNo mapping found', helpers.exec_capture('nmap <C-I>'))
+ eq('\nNo mapping found', t.exec_capture('nmap <C-I>'))
end)
end)
diff --git a/test/functional/api/menu_spec.lua b/test/functional/api/menu_spec.lua
index 44b9039393..97d0f43d64 100644
--- a/test/functional/api/menu_spec.lua
+++ b/test/functional/api/menu_spec.lua
@@ -1,9 +1,9 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local clear = helpers.clear
-local command = helpers.command
-local feed = helpers.feed
+local clear = t.clear
+local command = t.command
+local feed = t.feed
describe('update_menu notification', function()
local screen
diff --git a/test/functional/api/proc_spec.lua b/test/functional/api/proc_spec.lua
index 50c441792c..85e55d0cfb 100644
--- a/test/functional/api/proc_spec.lua
+++ b/test/functional/api/proc_spec.lua
@@ -1,14 +1,14 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
-local clear = helpers.clear
-local eq = helpers.eq
-local fn = helpers.fn
-local neq = helpers.neq
-local nvim_argv = helpers.nvim_argv
-local request = helpers.request
-local retry = helpers.retry
+local clear = t.clear
+local eq = t.eq
+local fn = t.fn
+local neq = t.neq
+local nvim_argv = t.nvim_argv
+local request = t.request
+local retry = t.retry
local NIL = vim.NIL
-local is_os = helpers.is_os
+local is_os = t.is_os
describe('API', function()
before_each(clear)
diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua
index 9b411c0c3f..ee2e401dd5 100644
--- a/test/functional/api/server_notifications_spec.lua
+++ b/test/functional/api/server_notifications_spec.lua
@@ -1,12 +1,11 @@
-local helpers = require('test.functional.helpers')(after_each)
-local assert_log = helpers.assert_log
-local eq, clear, eval, command, next_msg =
- helpers.eq, helpers.clear, helpers.eval, helpers.command, helpers.next_msg
-local api = helpers.api
-local exec_lua = helpers.exec_lua
-local retry = helpers.retry
-local assert_alive = helpers.assert_alive
-local check_close = helpers.check_close
+local t = require('test.functional.testutil')(after_each)
+local assert_log = t.assert_log
+local eq, clear, eval, command, next_msg = t.eq, t.clear, t.eval, t.command, t.next_msg
+local api = t.api
+local exec_lua = t.exec_lua
+local retry = t.retry
+local assert_alive = t.assert_alive
+local check_close = t.check_close
local testlog = 'Xtest-server-notify-log'
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index 562eeae951..3a925dcbe2 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -1,17 +1,17 @@
-- Test server -> client RPC scenarios. Note: unlike `rpcnotify`, to evaluate
-- `rpcrequest` calls we need the client event loop to be running.
-local helpers = require('test.functional.helpers')(after_each)
-
-local clear, eval = helpers.clear, helpers.eval
-local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop
-local nvim_prog, command, fn = helpers.nvim_prog, helpers.command, helpers.fn
-local source, next_msg = helpers.source, helpers.next_msg
-local ok = helpers.ok
-local api = helpers.api
-local spawn, merge_args = helpers.spawn, helpers.merge_args
-local set_session = helpers.set_session
-local pcall_err = helpers.pcall_err
-local assert_alive = helpers.assert_alive
+local t = require('test.functional.testutil')(after_each)
+
+local clear, eval = t.clear, t.eval
+local eq, neq, run, stop = t.eq, t.neq, t.run, t.stop
+local nvim_prog, command, fn = t.nvim_prog, t.command, t.fn
+local source, next_msg = t.source, t.next_msg
+local ok = t.ok
+local api = t.api
+local spawn, merge_args = t.spawn, t.merge_args
+local set_session = t.set_session
+local pcall_err = t.pcall_err
+local assert_alive = t.assert_alive
describe('server -> client', function()
local cid
@@ -259,7 +259,7 @@ describe('server -> client', function()
pcall(fn.jobstop, jobid)
end)
- if helpers.skip(helpers.is_os('win')) then
+ if t.skip(t.is_os('win')) then
return
end
@@ -280,7 +280,7 @@ describe('server -> client', function()
end)
describe('connecting to another (peer) nvim', function()
- local nvim_argv = merge_args(helpers.nvim_argv, { '--headless' })
+ local nvim_argv = merge_args(t.nvim_argv, { '--headless' })
local function connect_test(server, mode, address)
local serverpid = fn.getpid()
local client = spawn(nvim_argv, false, nil, true)
diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua
index f7e6eed047..6ed5daca0f 100644
--- a/test/functional/api/tabpage_spec.lua
+++ b/test/functional/api/tabpage_spec.lua
@@ -1,13 +1,13 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok
-local exec = helpers.exec
-local feed = helpers.feed
-local api = helpers.api
-local fn = helpers.fn
-local request = helpers.request
+local t = require('test.functional.testutil')(after_each)
+local clear, eq, ok = t.clear, t.eq, t.ok
+local exec = t.exec
+local feed = t.feed
+local api = t.api
+local fn = t.fn
+local request = t.request
local NIL = vim.NIL
-local pcall_err = helpers.pcall_err
-local command = helpers.command
+local pcall_err = t.pcall_err
+local command = t.command
describe('api/tabpage', function()
before_each(clear)
diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua
index 3e1f1ec965..89eeeaa189 100644
--- a/test/functional/api/ui_spec.lua
+++ b/test/functional/api/ui_spec.lua
@@ -1,14 +1,14 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local clear = helpers.clear
-local command = helpers.command
-local eq = helpers.eq
-local eval = helpers.eval
-local exec = helpers.exec
-local feed = helpers.feed
-local api = helpers.api
-local request = helpers.request
-local pcall_err = helpers.pcall_err
+local clear = t.clear
+local command = t.command
+local eq = t.eq
+local eval = t.eval
+local exec = t.exec
+local feed = t.feed
+local api = t.api
+local request = t.request
+local pcall_err = t.pcall_err
describe('nvim_ui_attach()', function()
before_each(function()
diff --git a/test/functional/api/version_spec.lua b/test/functional/api/version_spec.lua
index c304f1aa88..7ab27be298 100644
--- a/test/functional/api/version_spec.lua
+++ b/test/functional/api/version_spec.lua
@@ -1,6 +1,6 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear, fn, eq = helpers.clear, helpers.fn, helpers.eq
-local api = helpers.api
+local t = require('test.functional.testutil')(after_each)
+local clear, fn, eq = t.clear, t.fn, t.eq
+local api = t.api
local function read_mpack_file(fname)
local fd = io.open(fname, 'rb')
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index dc36926641..82d5480997 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1,42 +1,42 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local uv = vim.uv
local fmt = string.format
-local dedent = helpers.dedent
-local assert_alive = helpers.assert_alive
+local dedent = t.dedent
+local assert_alive = t.assert_alive
local NIL = vim.NIL
-local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
-local command = helpers.command
-local command_output = helpers.api.nvim_command_output
-local exec = helpers.exec
-local exec_capture = helpers.exec_capture
-local eval = helpers.eval
-local expect = helpers.expect
-local fn = helpers.fn
-local api = helpers.api
-local matches = helpers.matches
+local clear, eq, neq = t.clear, t.eq, t.neq
+local command = t.command
+local command_output = t.api.nvim_command_output
+local exec = t.exec
+local exec_capture = t.exec_capture
+local eval = t.eval
+local expect = t.expect
+local fn = t.fn
+local api = t.api
+local matches = t.matches
local pesc = vim.pesc
-local mkdir_p = helpers.mkdir_p
-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 parse_context = helpers.parse_context
-local request = helpers.request
-local rmdir = helpers.rmdir
-local source = helpers.source
-local next_msg = helpers.next_msg
-local tmpname = helpers.tmpname
-local write_file = helpers.write_file
-local exec_lua = helpers.exec_lua
-local exc_exec = helpers.exc_exec
-local insert = helpers.insert
-local skip = helpers.skip
-
-local pcall_err = helpers.pcall_err
+local mkdir_p = t.mkdir_p
+local ok, nvim_async, feed = t.ok, t.nvim_async, t.feed
+local async_meths = t.async_meths
+local is_os = t.is_os
+local parse_context = t.parse_context
+local request = t.request
+local rmdir = t.rmdir
+local source = t.source
+local next_msg = t.next_msg
+local tmpname = t.tmpname
+local write_file = t.write_file
+local exec_lua = t.exec_lua
+local exc_exec = t.exc_exec
+local insert = t.insert
+local skip = t.skip
+
+local pcall_err = t.pcall_err
local format_string = require('test.format_string').format_string
-local intchar2lua = helpers.intchar2lua
-local mergedicts_copy = helpers.mergedicts_copy
+local intchar2lua = t.intchar2lua
+local mergedicts_copy = t.mergedicts_copy
local endswith = vim.endswith
describe('API', function()
@@ -702,12 +702,12 @@ describe('API', function()
end)
after_each(function()
- helpers.rmdir('Xtestdir')
+ t.rmdir('Xtestdir')
end)
it('works', function()
api.nvim_set_current_dir('Xtestdir')
- eq(start_dir .. helpers.get_pathsep() .. 'Xtestdir', fn.getcwd())
+ eq(start_dir .. t.get_pathsep() .. 'Xtestdir', fn.getcwd())
end)
it('sets previous directory', function()
@@ -1467,7 +1467,7 @@ describe('API', function()
eq(NIL, api.nvim_get_var('Unknown_script_func'))
-- Check if autoload works properly
- local pathsep = helpers.get_pathsep()
+ local pathsep = t.get_pathsep()
local xconfig = 'Xhome' .. pathsep .. 'Xconfig'
local xdata = 'Xhome' .. pathsep .. 'Xdata'
local autoload_folder = table.concat({ xconfig, 'nvim', 'autoload' }, pathsep)
@@ -1951,7 +1951,7 @@ describe('API', function()
describe('RPC (K_EVENT)', function()
it('does not complete ("interrupt") normal-mode operator-pending #6166', function()
- helpers.insert([[
+ t.insert([[
FIRST LINE
SECOND LINE]])
api.nvim_input('gg')
@@ -1988,7 +1988,7 @@ describe('API', function()
it('does not complete ("interrupt") normal-mode map-pending #6166', function()
command("nnoremap dd :let g:foo='it worked...'<CR>")
- helpers.insert([[
+ t.insert([[
FIRST LINE
SECOND LINE]])
api.nvim_input('gg')
@@ -2000,13 +2000,13 @@ describe('API', function()
expect([[
FIRST LINE
SECOND LINE]])
- eq('it worked...', helpers.eval('g:foo'))
+ eq('it worked...', t.eval('g:foo'))
end)
it('does not complete ("interrupt") insert-mode map-pending #6166', function()
command('inoremap xx foo')
command('set timeoutlen=9999')
- helpers.insert([[
+ t.insert([[
FIRST LINE
SECOND LINE]])
api.nvim_input('ix')
@@ -2153,35 +2153,32 @@ describe('API', function()
describe('nvim_replace_termcodes', function()
it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function()
- eq('\128\254X', helpers.api.nvim_replace_termcodes('\128', true, true, true))
+ eq('\128\254X', t.api.nvim_replace_termcodes('\128', true, true, true))
end)
it('leaves non-K_SPECIAL string unchanged', function()
- eq('abc', helpers.api.nvim_replace_termcodes('abc', true, true, true))
+ eq('abc', t.api.nvim_replace_termcodes('abc', true, true, true))
end)
it('converts <expressions>', function()
- eq('\\', helpers.api.nvim_replace_termcodes('<Leader>', true, true, true))
+ eq('\\', t.api.nvim_replace_termcodes('<Leader>', true, true, true))
end)
it('converts <LeftMouse> to K_SPECIAL KS_EXTRA KE_LEFTMOUSE', function()
-- K_SPECIAL KS_EXTRA KE_LEFTMOUSE
-- 0x80 0xfd 0x2c
-- 128 253 44
- eq('\128\253\44', helpers.api.nvim_replace_termcodes('<LeftMouse>', true, true, true))
+ eq('\128\253\44', t.api.nvim_replace_termcodes('<LeftMouse>', true, true, true))
end)
it('converts keycodes', function()
- eq(
- '\nx\27x\rx<x',
- helpers.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, true)
- )
+ eq('\nx\27x\rx<x', t.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, true))
end)
it('does not convert keycodes if special=false', function()
eq(
'<NL>x<Esc>x<CR>x<lt>x',
- helpers.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, false)
+ t.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, false)
)
end)
@@ -2210,18 +2207,18 @@ describe('API', function()
api.nvim_feedkeys(':let x1="…"\n', '', true)
-- Both nvim_replace_termcodes and nvim_feedkeys escape \x80
- local inp = helpers.api.nvim_replace_termcodes(':let x2="…"<CR>', true, true, true)
+ local inp = t.api.nvim_replace_termcodes(':let x2="…"<CR>', true, true, true)
api.nvim_feedkeys(inp, '', true) -- escape_ks=true
-- nvim_feedkeys with K_SPECIAL escaping disabled
- inp = helpers.api.nvim_replace_termcodes(':let x3="…"<CR>', true, true, true)
+ inp = t.api.nvim_replace_termcodes(':let x3="…"<CR>', true, true, true)
api.nvim_feedkeys(inp, '', false) -- escape_ks=false
- helpers.stop()
+ t.stop()
end
-- spin the loop a bit
- helpers.run(nil, nil, on_setup)
+ t.run(nil, nil, on_setup)
eq('…', api.nvim_get_var('x1'))
-- Because of the double escaping this is neq
@@ -2364,7 +2361,7 @@ describe('API', function()
{0:~ }|*6
{1:very fail} |
]])
- helpers.poke_eventloop()
+ t.poke_eventloop()
-- shows up to &cmdheight lines
async_meths.nvim_err_write('more fail\ntoo fail\n')
@@ -2676,7 +2673,7 @@ describe('API', function()
describe('nvim_list_runtime_paths', function()
setup(function()
- local pathsep = helpers.get_pathsep()
+ local pathsep = t.get_pathsep()
mkdir_p('Xtest' .. pathsep .. 'a')
mkdir_p('Xtest' .. pathsep .. 'b')
end)
@@ -3183,7 +3180,7 @@ describe('API', function()
end)
describe('nvim_get_runtime_file', function()
- local p = helpers.alter_slashes
+ local p = t.alter_slashes
it('can find files', function()
eq({}, api.nvim_get_runtime_file('bork.borkbork', false))
eq({}, api.nvim_get_runtime_file('bork.borkbork', true))
@@ -3410,13 +3407,13 @@ describe('API', function()
{desc="(global option, fallback requested) points to global", linenr=9, sid=1, args={'completeopt', {}}},
}
- for _, t in pairs(tests) do
- it(t.desc, function()
+ for _, test in pairs(tests) do
+ it(test.desc, function()
-- Switch to the target buffer/window so that curbuf/curwin are used.
api.nvim_set_current_win(wins[2])
- local info = api.nvim_get_option_info2(unpack(t.args))
- eq(t.linenr, info.last_set_linenr)
- eq(t.sid, info.last_set_sid)
+ local info = api.nvim_get_option_info2(unpack(test.args))
+ eq(test.linenr, info.last_set_linenr)
+ eq(test.sid, info.last_set_sid)
end)
end
@@ -3537,9 +3534,9 @@ describe('API', function()
false,
{ width = 79, height = 31, row = 1, col = 1, relative = 'editor' }
)
- local t = api.nvim_open_term(b, {})
+ local term = api.nvim_open_term(b, {})
- api.nvim_chan_send(t, io.open('test/functional/fixtures/smile2.cat', 'r'):read('*a'))
+ api.nvim_chan_send(term, io.open('test/functional/fixtures/smile2.cat', 'r'):read('*a'))
screen:expect {
grid = [[
^ |
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index 721148faaa..43f1a05414 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -1,27 +1,27 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, curbuf, curbuf_contents, curwin, eq, neq, matches, ok, feed, insert, eval =
- helpers.clear,
- helpers.api.nvim_get_current_buf,
- helpers.curbuf_contents,
- helpers.api.nvim_get_current_win,
- helpers.eq,
- helpers.neq,
- helpers.matches,
- helpers.ok,
- helpers.feed,
- helpers.insert,
- helpers.eval
-local poke_eventloop = helpers.poke_eventloop
-local exec = helpers.exec
-local exec_lua = helpers.exec_lua
-local fn = helpers.fn
-local request = helpers.request
+ t.clear,
+ t.api.nvim_get_current_buf,
+ t.curbuf_contents,
+ t.api.nvim_get_current_win,
+ t.eq,
+ t.neq,
+ t.matches,
+ t.ok,
+ t.feed,
+ t.insert,
+ t.eval
+local poke_eventloop = t.poke_eventloop
+local exec = t.exec
+local exec_lua = t.exec_lua
+local fn = t.fn
+local request = t.request
local NIL = vim.NIL
-local api = helpers.api
-local command = helpers.command
-local pcall_err = helpers.pcall_err
-local assert_alive = helpers.assert_alive
+local api = t.api
+local command = t.command
+local pcall_err = t.pcall_err
+local assert_alive = t.assert_alive
describe('API/win', function()
before_each(clear)
@@ -1297,7 +1297,7 @@ describe('API/win', function()
local tab1 = api.nvim_get_current_tabpage()
local tab1_win = api.nvim_get_current_win()
- helpers.command('tabnew')
+ t.command('tabnew')
local tab2 = api.nvim_get_current_tabpage()
local tab2_win = api.nvim_get_current_win()