aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
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/lua
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/lua')
-rw-r--r--test/functional/lua/api_spec.lua18
-rw-r--r--test/functional/lua/base64_spec.lua12
-rw-r--r--test/functional/lua/buffer_updates_spec.lua30
-rw-r--r--test/functional/lua/command_line_completion_spec.lua8
-rw-r--r--test/functional/lua/commands_spec.lua34
-rw-r--r--test/functional/lua/comment_spec.lua16
-rw-r--r--test/functional/lua/diagnostic_spec.lua36
-rw-r--r--test/functional/lua/ffi_spec.lua8
-rw-r--r--test/functional/lua/filetype_spec.lua20
-rw-r--r--test/functional/lua/fs_spec.lua26
-rw-r--r--test/functional/lua/glob_spec.lua10
-rw-r--r--test/functional/lua/highlight_spec.lua18
-rw-r--r--test/functional/lua/inspector_spec.lua10
-rw-r--r--test/functional/lua/iter_spec.lua182
-rw-r--r--test/functional/lua/json_spec.lua10
-rw-r--r--test/functional/lua/loader_spec.lua28
-rw-r--r--test/functional/lua/loop_spec.lua20
-rw-r--r--test/functional/lua/luaeval_spec.lua28
-rw-r--r--test/functional/lua/mpack_spec.lua8
-rw-r--r--test/functional/lua/overrides_spec.lua24
-rw-r--r--test/functional/lua/runtime_spec.lua20
-rw-r--r--test/functional/lua/secure_spec.lua40
-rw-r--r--test/functional/lua/snippet_spec.lua26
-rw-r--r--test/functional/lua/spell_spec.lua10
-rw-r--r--test/functional/lua/system_spec.lua8
-rw-r--r--test/functional/lua/text_spec.lua6
-rw-r--r--test/functional/lua/thread_spec.lua16
-rw-r--r--test/functional/lua/ui_event_spec.lua20
-rw-r--r--test/functional/lua/ui_spec.lua20
-rw-r--r--test/functional/lua/uri_spec.lua16
-rw-r--r--test/functional/lua/version_spec.lua16
-rw-r--r--test/functional/lua/vim_spec.lua70
-rw-r--r--test/functional/lua/watch_spec.lua23
-rw-r--r--test/functional/lua/xdiff_spec.lua10
34 files changed, 418 insertions, 429 deletions
diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua
index acd56a0ddb..0aa63327ad 100644
--- a/test/functional/lua/api_spec.lua
+++ b/test/functional/lua/api_spec.lua
@@ -1,15 +1,15 @@
-- Test suite for testing interactions with API bindings
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
-local exc_exec = helpers.exc_exec
-local remove_trace = helpers.remove_trace
-local fn = helpers.fn
-local clear = helpers.clear
-local eval = helpers.eval
+local exc_exec = t.exc_exec
+local remove_trace = t.remove_trace
+local fn = t.fn
+local clear = t.clear
+local eval = t.eval
local NIL = vim.NIL
-local eq = helpers.eq
-local exec_lua = helpers.exec_lua
-local pcall_err = helpers.pcall_err
+local eq = t.eq
+local exec_lua = t.exec_lua
+local pcall_err = t.pcall_err
before_each(clear)
diff --git a/test/functional/lua/base64_spec.lua b/test/functional/lua/base64_spec.lua
index 21fd536a98..9410a6fd6f 100644
--- a/test/functional/lua/base64_spec.lua
+++ b/test/functional/lua/base64_spec.lua
@@ -1,9 +1,9 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
-local pcall_err = helpers.pcall_err
-local matches = helpers.matches
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
+local exec_lua = t.exec_lua
+local eq = t.eq
+local pcall_err = t.pcall_err
+local matches = t.matches
describe('vim.base64', function()
before_each(clear)
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 01dc8c2f02..490177b96b 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -1,18 +1,18 @@
-- Test suite for testing interactions with API bindings
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local command = helpers.command
-local api = helpers.api
-local fn = helpers.fn
-local clear = helpers.clear
-local eq = helpers.eq
-local fail = helpers.fail
-local exec_lua = helpers.exec_lua
-local feed = helpers.feed
-local expect_events = helpers.expect_events
-local write_file = helpers.write_file
-local dedent = helpers.dedent
+local command = t.command
+local api = t.api
+local fn = t.fn
+local clear = t.clear
+local eq = t.eq
+local fail = t.fail
+local exec_lua = t.exec_lua
+local feed = t.feed
+local expect_events = t.expect_events
+local write_file = t.write_file
+local dedent = t.dedent
local origlines = {
'original line 1',
@@ -292,11 +292,11 @@ describe('lua buffer event callbacks: on_lines', function()
exec_lua(code)
command('q!')
- helpers.assert_alive()
+ t.assert_alive()
exec_lua(code)
command('bd!')
- helpers.assert_alive()
+ t.assert_alive()
end)
it('#12718 lnume', function()
@@ -965,7 +965,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
command('e! Xtest-undofile')
command('set undodir=. | set undofile')
- local ns = helpers.request('nvim_create_namespace', 'ns1')
+ local ns = t.request('nvim_create_namespace', 'ns1')
api.nvim_buf_set_extmark(0, ns, 0, 0, {})
eq({ '12345', 'hello world' }, api.nvim_buf_get_lines(0, 0, -1, true))
diff --git a/test/functional/lua/command_line_completion_spec.lua b/test/functional/lua/command_line_completion_spec.lua
index b88a38082f..41e807f086 100644
--- a/test/functional/lua/command_line_completion_spec.lua
+++ b/test/functional/lua/command_line_completion_spec.lua
@@ -1,8 +1,8 @@
-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 exec_lua = helpers.exec_lua
+local clear = t.clear
+local eq = t.eq
+local exec_lua = t.exec_lua
local get_completions = function(input, env)
return exec_lua('return {vim._expand_pat(...)}', input, env)
diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua
index b8d0638ce5..04188281bc 100644
--- a/test/functional/lua/commands_spec.lua
+++ b/test/functional/lua/commands_spec.lua
@@ -1,24 +1,24 @@
-- Test suite for checking :lua* commands
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local eq = helpers.eq
+local eq = t.eq
local NIL = vim.NIL
-local eval = helpers.eval
-local feed = helpers.feed
-local clear = helpers.clear
-local matches = helpers.matches
-local api = helpers.api
-local exec_lua = helpers.exec_lua
-local exec_capture = helpers.exec_capture
-local fn = helpers.fn
-local source = helpers.source
-local dedent = helpers.dedent
-local command = helpers.command
-local exc_exec = helpers.exc_exec
-local pcall_err = helpers.pcall_err
-local write_file = helpers.write_file
-local remove_trace = helpers.remove_trace
+local eval = t.eval
+local feed = t.feed
+local clear = t.clear
+local matches = t.matches
+local api = t.api
+local exec_lua = t.exec_lua
+local exec_capture = t.exec_capture
+local fn = t.fn
+local source = t.source
+local dedent = t.dedent
+local command = t.command
+local exc_exec = t.exc_exec
+local pcall_err = t.pcall_err
+local write_file = t.write_file
+local remove_trace = t.remove_trace
before_each(clear)
diff --git a/test/functional/lua/comment_spec.lua b/test/functional/lua/comment_spec.lua
index 72935c47d5..3b230780ad 100644
--- a/test/functional/lua/comment_spec.lua
+++ b/test/functional/lua/comment_spec.lua
@@ -1,11 +1,11 @@
-local helpers = require('test.functional.helpers')(after_each)
-
-local api = helpers.api
-local clear = helpers.clear
-local eq = helpers.eq
-local exec_capture = helpers.exec_capture
-local exec_lua = helpers.exec_lua
-local feed = helpers.feed
+local t = require('test.functional.testutil')(after_each)
+
+local api = t.api
+local clear = t.clear
+local eq = t.eq
+local exec_capture = t.exec_capture
+local exec_lua = t.exec_lua
+local feed = t.feed
-- Reference text
-- aa
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index f648c0b215..152258dd8c 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -1,14 +1,14 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local NIL = vim.NIL
-local command = helpers.command
-local clear = helpers.clear
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
-local matches = helpers.matches
-local api = helpers.api
-local pcall_err = helpers.pcall_err
-local fn = helpers.fn
+local command = t.command
+local clear = t.clear
+local exec_lua = t.exec_lua
+local eq = t.eq
+local matches = t.matches
+local api = t.api
+local pcall_err = t.pcall_err
+local fn = t.fn
describe('vim.diagnostic', function()
before_each(function()
@@ -1826,20 +1826,12 @@ describe('vim.diagnostic', function()
it('respects legacy signs placed with :sign define or sign_define #26618', function()
-- Legacy signs for diagnostics were deprecated in 0.10 and will be removed in 0.12
- eq(0, helpers.fn.has('nvim-0.12'))
+ eq(0, t.fn.has('nvim-0.12'))
- helpers.command(
- 'sign define DiagnosticSignError text= texthl= linehl=ErrorMsg numhl=ErrorMsg'
- )
- helpers.command(
- 'sign define DiagnosticSignWarn text= texthl= linehl=WarningMsg numhl=WarningMsg'
- )
- helpers.command(
- 'sign define DiagnosticSignInfo text= texthl= linehl=Underlined numhl=Underlined'
- )
- helpers.command(
- 'sign define DiagnosticSignHint text= texthl= linehl=Underlined numhl=Underlined'
- )
+ t.command('sign define DiagnosticSignError text= texthl= linehl=ErrorMsg numhl=ErrorMsg')
+ t.command('sign define DiagnosticSignWarn text= texthl= linehl=WarningMsg numhl=WarningMsg')
+ t.command('sign define DiagnosticSignInfo text= texthl= linehl=Underlined numhl=Underlined')
+ t.command('sign define DiagnosticSignHint text= texthl= linehl=Underlined numhl=Underlined')
local result = exec_lua [[
vim.diagnostic.config({
diff --git a/test/functional/lua/ffi_spec.lua b/test/functional/lua/ffi_spec.lua
index 4229e4af9b..2cde9f4f2a 100644
--- a/test/functional/lua/ffi_spec.lua
+++ b/test/functional/lua/ffi_spec.lua
@@ -1,7 +1,7 @@
-local helpers = require('test.functional.helpers')(after_each)
-local eq = helpers.eq
-local exec_lua = helpers.exec_lua
-local clear = helpers.clear
+local t = require('test.functional.testutil')(after_each)
+local eq = t.eq
+local exec_lua = t.exec_lua
+local clear = t.clear
before_each(clear)
diff --git a/test/functional/lua/filetype_spec.lua b/test/functional/lua/filetype_spec.lua
index 3ef650a1d2..677d039b81 100644
--- a/test/functional/lua/filetype_spec.lua
+++ b/test/functional/lua/filetype_spec.lua
@@ -1,13 +1,13 @@
-local helpers = require('test.functional.helpers')(after_each)
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
-local api = helpers.api
-local clear = helpers.clear
-local pathroot = helpers.pathroot
-local command = helpers.command
-local mkdir = helpers.mkdir
-local rmdir = helpers.rmdir
-local write_file = helpers.write_file
+local t = require('test.functional.testutil')(after_each)
+local exec_lua = t.exec_lua
+local eq = t.eq
+local api = t.api
+local clear = t.clear
+local pathroot = t.pathroot
+local command = t.command
+local mkdir = t.mkdir
+local rmdir = t.rmdir
+local write_file = t.write_file
local uv = vim.uv
local root = pathroot()
diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua
index 6e7811908b..a0df71b20a 100644
--- a/test/functional/lua/fs_spec.lua
+++ b/test/functional/lua/fs_spec.lua
@@ -1,16 +1,16 @@
-local helpers = require('test.functional.helpers')(after_each)
-
-local clear = helpers.clear
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
-local mkdir_p = helpers.mkdir_p
-local rmdir = helpers.rmdir
-local nvim_dir = helpers.nvim_dir
-local test_build_dir = helpers.paths.test_build_dir
-local test_source_path = helpers.paths.test_source_path
-local nvim_prog = helpers.nvim_prog
-local is_os = helpers.is_os
-local mkdir = helpers.mkdir
+local t = require('test.functional.testutil')(after_each)
+
+local clear = t.clear
+local exec_lua = t.exec_lua
+local eq = t.eq
+local mkdir_p = t.mkdir_p
+local rmdir = t.rmdir
+local nvim_dir = t.nvim_dir
+local test_build_dir = t.paths.test_build_dir
+local test_source_path = t.paths.test_source_path
+local nvim_prog = t.nvim_prog
+local is_os = t.is_os
+local mkdir = t.mkdir
local nvim_prog_basename = is_os('win') and 'nvim.exe' or 'nvim'
diff --git a/test/functional/lua/glob_spec.lua b/test/functional/lua/glob_spec.lua
index 1eac037575..dbe1079092 100644
--- a/test/functional/lua/glob_spec.lua
+++ b/test/functional/lua/glob_spec.lua
@@ -1,10 +1,10 @@
-local helpers = require('test.functional.helpers')(after_each)
-local eq = helpers.eq
-local exec_lua = helpers.exec_lua
+local t = require('test.functional.testutil')(after_each)
+local eq = t.eq
+local exec_lua = t.exec_lua
describe('glob', function()
- before_each(helpers.clear)
- after_each(helpers.clear)
+ before_each(t.clear)
+ after_each(t.clear)
local match = function(...)
return exec_lua(
diff --git a/test/functional/lua/highlight_spec.lua b/test/functional/lua/highlight_spec.lua
index 197f3139f3..dc80a1672a 100644
--- a/test/functional/lua/highlight_spec.lua
+++ b/test/functional/lua/highlight_spec.lua
@@ -1,11 +1,11 @@
-local helpers = require('test.functional.helpers')(after_each)
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
-local neq = helpers.neq
-local eval = helpers.eval
-local command = helpers.command
-local clear = helpers.clear
-local api = helpers.api
+local t = require('test.functional.testutil')(after_each)
+local exec_lua = t.exec_lua
+local eq = t.eq
+local neq = t.neq
+local eval = t.eval
+local command = t.command
+local clear = t.clear
+local api = t.api
describe('vim.highlight.on_yank', function()
before_each(function()
@@ -19,7 +19,7 @@ describe('vim.highlight.on_yank', function()
vim.cmd('bwipeout!')
]])
vim.uv.sleep(10)
- helpers.feed('<cr>') -- avoid hang if error message exists
+ t.feed('<cr>') -- avoid hang if error message exists
eq('', eval('v:errmsg'))
end)
diff --git a/test/functional/lua/inspector_spec.lua b/test/functional/lua/inspector_spec.lua
index ad8b5a45a8..efc710d0d7 100644
--- a/test/functional/lua/inspector_spec.lua
+++ b/test/functional/lua/inspector_spec.lua
@@ -1,8 +1,8 @@
-local helpers = require('test.functional.helpers')(after_each)
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
-local eval = helpers.eval
-local clear = helpers.clear
+local t = require('test.functional.testutil')(after_each)
+local exec_lua = t.exec_lua
+local eq = t.eq
+local eval = t.eval
+local clear = t.clear
describe('vim.inspect_pos', function()
before_each(function()
diff --git a/test/functional/lua/iter_spec.lua b/test/functional/lua/iter_spec.lua
index 6d8a37f022..237710242d 100644
--- a/test/functional/lua/iter_spec.lua
+++ b/test/functional/lua/iter_spec.lua
@@ -1,7 +1,7 @@
-local helpers = require('test.functional.helpers')(after_each)
-local eq = helpers.eq
-local matches = helpers.matches
-local pcall_err = helpers.pcall_err
+local t = require('test.functional.testutil')(after_each)
+local eq = t.eq
+local matches = t.matches
+local pcall_err = t.pcall_err
describe('vim.iter', function()
it('new() on iterable class instance', function()
@@ -18,12 +18,12 @@ describe('vim.iter', function()
return v % 2 ~= 0
end
- local t = { 1, 2, 3, 4, 5 }
- eq({ 1, 3, 5 }, vim.iter(t):filter(odd):totable())
+ local q = { 1, 2, 3, 4, 5 }
+ eq({ 1, 3, 5 }, vim.iter(q):filter(odd):totable())
eq(
{ 2, 4 },
vim
- .iter(t)
+ .iter(q)
:filter(function(v)
return not odd(v)
end)
@@ -32,7 +32,7 @@ describe('vim.iter', function()
eq(
{},
vim
- .iter(t)
+ .iter(q)
:filter(function(v)
return v > 5
end)
@@ -40,7 +40,7 @@ describe('vim.iter', function()
)
do
- local it = vim.iter(ipairs(t))
+ local it = vim.iter(ipairs(q))
it:filter(function(i, v)
return i > 1 and v < 5
end)
@@ -60,11 +60,11 @@ describe('vim.iter', function()
end)
it('map()', function()
- local t = { 1, 2, 3, 4, 5 }
+ local q = { 1, 2, 3, 4, 5 }
eq(
{ 2, 4, 6, 8, 10 },
vim
- .iter(t)
+ .iter(q)
:map(function(v)
return 2 * v
end)
@@ -96,10 +96,10 @@ describe('vim.iter', function()
end)
it('for loops', function()
- local t = { 1, 2, 3, 4, 5 }
+ local q = { 1, 2, 3, 4, 5 }
local acc = 0
for v in
- vim.iter(t):map(function(v)
+ vim.iter(q):map(function(v)
return v * 3
end)
do
@@ -146,13 +146,13 @@ describe('vim.iter', function()
it('skip()', function()
do
- local t = { 4, 3, 2, 1 }
- eq(t, vim.iter(t):skip(0):totable())
- eq({ 3, 2, 1 }, vim.iter(t):skip(1):totable())
- eq({ 2, 1 }, vim.iter(t):skip(2):totable())
- eq({ 1 }, vim.iter(t):skip(#t - 1):totable())
- eq({}, vim.iter(t):skip(#t):totable())
- eq({}, vim.iter(t):skip(#t + 1):totable())
+ local q = { 4, 3, 2, 1 }
+ eq(q, vim.iter(q):skip(0):totable())
+ eq({ 3, 2, 1 }, vim.iter(q):skip(1):totable())
+ eq({ 2, 1 }, vim.iter(q):skip(2):totable())
+ eq({ 1 }, vim.iter(q):skip(#q - 1):totable())
+ eq({}, vim.iter(q):skip(#q):totable())
+ eq({}, vim.iter(q):skip(#q + 1):totable())
end
do
@@ -170,13 +170,13 @@ describe('vim.iter', function()
it('skipback()', function()
do
- local t = { 4, 3, 2, 1 }
- eq(t, vim.iter(t):skipback(0):totable())
- eq({ 4, 3, 2 }, vim.iter(t):skipback(1):totable())
- eq({ 4, 3 }, vim.iter(t):skipback(2):totable())
- eq({ 4 }, vim.iter(t):skipback(#t - 1):totable())
- eq({}, vim.iter(t):skipback(#t):totable())
- eq({}, vim.iter(t):skipback(#t + 1):totable())
+ local q = { 4, 3, 2, 1 }
+ eq(q, vim.iter(q):skipback(0):totable())
+ eq({ 4, 3, 2 }, vim.iter(q):skipback(1):totable())
+ eq({ 4, 3 }, vim.iter(q):skipback(2):totable())
+ eq({ 4 }, vim.iter(q):skipback(#q - 1):totable())
+ eq({}, vim.iter(q):skipback(#q):totable())
+ eq({}, vim.iter(q):skipback(#q + 1):totable())
end
local it = vim.iter(vim.gsplit('a|b|c|d', '|'))
@@ -184,14 +184,14 @@ describe('vim.iter', function()
end)
it('slice()', function()
- local t = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
- eq({ 3, 4, 5, 6, 7 }, vim.iter(t):slice(3, 7):totable())
- eq({}, vim.iter(t):slice(6, 5):totable())
- eq({}, vim.iter(t):slice(0, 0):totable())
- eq({ 1 }, vim.iter(t):slice(1, 1):totable())
- eq({ 1, 2 }, vim.iter(t):slice(1, 2):totable())
- eq({ 10 }, vim.iter(t):slice(10, 10):totable())
- eq({ 8, 9, 10 }, vim.iter(t):slice(8, 11):totable())
+ local q = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
+ eq({ 3, 4, 5, 6, 7 }, vim.iter(q):slice(3, 7):totable())
+ eq({}, vim.iter(q):slice(6, 5):totable())
+ eq({}, vim.iter(q):slice(0, 0):totable())
+ eq({ 1 }, vim.iter(q):slice(1, 1):totable())
+ eq({ 1, 2 }, vim.iter(q):slice(1, 2):totable())
+ eq({ 10 }, vim.iter(q):slice(10, 10):totable())
+ eq({ 8, 9, 10 }, vim.iter(q):slice(8, 11):totable())
local it = vim.iter(vim.gsplit('a|b|c|d', '|'))
matches('slice%(%) requires a list%-like table', pcall_err(it.slice, it, 1, 3))
@@ -199,13 +199,13 @@ describe('vim.iter', function()
it('nth()', function()
do
- local t = { 4, 3, 2, 1 }
- eq(nil, vim.iter(t):nth(0))
- eq(4, vim.iter(t):nth(1))
- eq(3, vim.iter(t):nth(2))
- eq(2, vim.iter(t):nth(3))
- eq(1, vim.iter(t):nth(4))
- eq(nil, vim.iter(t):nth(5))
+ local q = { 4, 3, 2, 1 }
+ eq(nil, vim.iter(q):nth(0))
+ eq(4, vim.iter(q):nth(1))
+ eq(3, vim.iter(q):nth(2))
+ eq(2, vim.iter(q):nth(3))
+ eq(1, vim.iter(q):nth(4))
+ eq(nil, vim.iter(q):nth(5))
end
do
@@ -223,13 +223,13 @@ describe('vim.iter', function()
it('nthback()', function()
do
- local t = { 4, 3, 2, 1 }
- eq(nil, vim.iter(t):nthback(0))
- eq(1, vim.iter(t):nthback(1))
- eq(2, vim.iter(t):nthback(2))
- eq(3, vim.iter(t):nthback(3))
- eq(4, vim.iter(t):nthback(4))
- eq(nil, vim.iter(t):nthback(5))
+ local q = { 4, 3, 2, 1 }
+ eq(nil, vim.iter(q):nthback(0))
+ eq(1, vim.iter(q):nthback(1))
+ eq(2, vim.iter(q):nthback(2))
+ eq(3, vim.iter(q):nthback(3))
+ eq(4, vim.iter(q):nthback(4))
+ eq(nil, vim.iter(q):nthback(5))
end
local it = vim.iter(vim.gsplit('a|b|c|d', '|'))
@@ -238,24 +238,24 @@ describe('vim.iter', function()
it('take()', function()
do
- local t = { 4, 3, 2, 1 }
- eq({}, vim.iter(t):take(0):totable())
- eq({ 4 }, vim.iter(t):take(1):totable())
- eq({ 4, 3 }, vim.iter(t):take(2):totable())
- eq({ 4, 3, 2 }, vim.iter(t):take(3):totable())
- eq({ 4, 3, 2, 1 }, vim.iter(t):take(4):totable())
- eq({ 4, 3, 2, 1 }, vim.iter(t):take(5):totable())
+ local q = { 4, 3, 2, 1 }
+ eq({}, vim.iter(q):take(0):totable())
+ eq({ 4 }, vim.iter(q):take(1):totable())
+ eq({ 4, 3 }, vim.iter(q):take(2):totable())
+ eq({ 4, 3, 2 }, vim.iter(q):take(3):totable())
+ eq({ 4, 3, 2, 1 }, vim.iter(q):take(4):totable())
+ eq({ 4, 3, 2, 1 }, vim.iter(q):take(5):totable())
end
do
- local t = { 4, 3, 2, 1 }
- eq({ 1, 2, 3 }, vim.iter(t):rev():take(3):totable())
- eq({ 2, 3, 4 }, vim.iter(t):take(3):rev():totable())
+ local q = { 4, 3, 2, 1 }
+ eq({ 1, 2, 3 }, vim.iter(q):rev():take(3):totable())
+ eq({ 2, 3, 4 }, vim.iter(q):take(3):rev():totable())
end
do
- local t = { 4, 3, 2, 1 }
- local it = vim.iter(t)
+ local q = { 4, 3, 2, 1 }
+ local it = vim.iter(q)
eq({ 4, 3 }, it:take(2):totable())
-- tail is already set from the previous take()
eq({ 4, 3 }, it:take(3):totable())
@@ -275,13 +275,13 @@ describe('vim.iter', function()
end
do
- local t = { 4, 8, 9, 10 }
- eq(true, vim.iter(t):any(odd))
+ local q = { 4, 8, 9, 10 }
+ eq(true, vim.iter(q):any(odd))
end
do
- local t = { 4, 8, 10 }
- eq(false, vim.iter(t):any(odd))
+ local q = { 4, 8, 10 }
+ eq(false, vim.iter(q):any(odd))
end
do
@@ -306,13 +306,13 @@ describe('vim.iter', function()
end
do
- local t = { 3, 5, 7, 9 }
- eq(true, vim.iter(t):all(odd))
+ local q = { 3, 5, 7, 9 }
+ eq(true, vim.iter(q):all(odd))
end
do
- local t = { 3, 5, 7, 10 }
- eq(false, vim.iter(t):all(odd))
+ local q = { 3, 5, 7, 10 }
+ eq(false, vim.iter(q):all(odd))
end
do
@@ -360,18 +360,18 @@ describe('vim.iter', function()
end)
it('find()', function()
- local t = { 3, 6, 9, 12 }
- eq(12, vim.iter(t):find(12))
- eq(nil, vim.iter(t):find(15))
+ local q = { 3, 6, 9, 12 }
+ eq(12, vim.iter(q):find(12))
+ eq(nil, vim.iter(q):find(15))
eq(
12,
- vim.iter(t):find(function(v)
+ vim.iter(q):find(function(v)
return v % 4 == 0
end)
)
do
- local it = vim.iter(t)
+ local it = vim.iter(q)
local pred = function(v)
return v % 3 == 0
end
@@ -395,16 +395,16 @@ describe('vim.iter', function()
end)
it('rfind()', function()
- local t = { 1, 2, 3, 2, 1 }
+ local q = { 1, 2, 3, 2, 1 }
do
- local it = vim.iter(t)
+ local it = vim.iter(q)
eq(1, it:rfind(1))
eq(1, it:rfind(1))
eq(nil, it:rfind(1))
end
do
- local it = vim.iter(t):enumerate()
+ local it = vim.iter(q):enumerate()
local pred = function(i)
return i % 2 ~= 0
end
@@ -452,16 +452,16 @@ describe('vim.iter', function()
end)
it('fold()', function()
- local t = { 1, 2, 3, 4, 5 }
+ local q = { 1, 2, 3, 4, 5 }
eq(
115,
- vim.iter(t):fold(100, function(acc, v)
+ vim.iter(q):fold(100, function(acc, v)
return acc + v
end)
)
eq(
{ 5, 4, 3, 2, 1 },
- vim.iter(t):fold({}, function(acc, v)
+ vim.iter(q):fold({}, function(acc, v)
table.insert(acc, 1, v)
return acc
end)
@@ -469,14 +469,14 @@ describe('vim.iter', function()
end)
it('flatten()', function()
- local t = { { 1, { 2 } }, { { { { 3 } } }, { 4 } }, { 5 } }
+ local q = { { 1, { 2 } }, { { { { 3 } } }, { 4 } }, { 5 } }
- eq(t, vim.iter(t):flatten(-1):totable())
- eq(t, vim.iter(t):flatten(0):totable())
- eq({ 1, { 2 }, { { { 3 } } }, { 4 }, 5 }, vim.iter(t):flatten():totable())
- eq({ 1, 2, { { 3 } }, 4, 5 }, vim.iter(t):flatten(2):totable())
- eq({ 1, 2, { 3 }, 4, 5 }, vim.iter(t):flatten(3):totable())
- eq({ 1, 2, 3, 4, 5 }, vim.iter(t):flatten(4):totable())
+ eq(q, vim.iter(q):flatten(-1):totable())
+ eq(q, vim.iter(q):flatten(0):totable())
+ eq({ 1, { 2 }, { { { 3 } } }, { 4 }, 5 }, vim.iter(q):flatten():totable())
+ eq({ 1, 2, { { 3 } }, 4, 5 }, vim.iter(q):flatten(2):totable())
+ eq({ 1, 2, { 3 }, 4, 5 }, vim.iter(q):flatten(3):totable())
+ eq({ 1, 2, 3, 4, 5 }, vim.iter(q):flatten(4):totable())
local m = { a = 1, b = { 2, 3 }, d = { 4 } }
local it = vim.iter(m)
@@ -507,11 +507,11 @@ describe('vim.iter', function()
end
end)
- local t = it:fold({}, function(t, k, v)
- t[k] = v
- return t
+ local q = it:fold({}, function(q, k, v)
+ q[k] = v
+ return q
end)
- eq({ A = 2, C = 6 }, t)
+ eq({ A = 2, C = 6 }, q)
end)
it('handles table values mid-pipeline', function()
diff --git a/test/functional/lua/json_spec.lua b/test/functional/lua/json_spec.lua
index d348e2de3c..af545fdfdf 100644
--- a/test/functional/lua/json_spec.lua
+++ b/test/functional/lua/json_spec.lua
@@ -1,8 +1,8 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
-local pcall_err = helpers.pcall_err
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
+local exec_lua = t.exec_lua
+local eq = t.eq
+local pcall_err = t.pcall_err
describe('vim.json.decode()', function()
before_each(function()
diff --git a/test/functional/lua/loader_spec.lua b/test/functional/lua/loader_spec.lua
index 6f74385e45..89be7a4c09 100644
--- a/test/functional/lua/loader_spec.lua
+++ b/test/functional/lua/loader_spec.lua
@@ -1,10 +1,10 @@
-- Test suite for testing interactions with API bindings
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
-local exec_lua = helpers.exec_lua
-local command = helpers.command
-local clear = helpers.clear
-local eq = helpers.eq
+local exec_lua = t.exec_lua
+local command = t.command
+local clear = t.clear
+local eq = t.eq
describe('vim.loader', function()
before_each(clear)
@@ -35,7 +35,7 @@ describe('vim.loader', function()
vim.loader.enable()
]]
- local tmp = helpers.tmpname()
+ local tmp = t.tmpname()
command('edit ' .. tmp)
eq(
@@ -73,15 +73,15 @@ describe('vim.loader', function()
vim.loader.enable()
]]
- local t = helpers.tmpname()
- assert(os.remove(t))
- assert(helpers.mkdir(t))
- assert(helpers.mkdir(t .. '/%'))
- local tmp1 = t .. '/%/x'
- local tmp2 = t .. '/%%x'
+ local tmp = t.tmpname()
+ assert(os.remove(tmp))
+ assert(t.mkdir(tmp))
+ assert(t.mkdir(tmp .. '/%'))
+ local tmp1 = tmp .. '/%/x'
+ local tmp2 = tmp .. '/%%x'
- helpers.write_file(tmp1, 'return 1', true)
- helpers.write_file(tmp2, 'return 2', true)
+ t.write_file(tmp1, 'return 1', true)
+ t.write_file(tmp2, 'return 2', true)
vim.uv.fs_utime(tmp1, 0, 0)
vim.uv.fs_utime(tmp2, 0, 0)
eq(1, exec_lua('return loadfile(...)()', tmp1))
diff --git a/test/functional/lua/loop_spec.lua b/test/functional/lua/loop_spec.lua
index 71eaf29009..13ffb97fbb 100644
--- a/test/functional/lua/loop_spec.lua
+++ b/test/functional/lua/loop_spec.lua
@@ -1,16 +1,16 @@
-- Test suite for testing interactions with API bindings
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local fn = helpers.fn
-local api = helpers.api
-local clear = helpers.clear
+local fn = t.fn
+local api = t.api
+local clear = t.clear
local sleep = vim.uv.sleep
-local feed = helpers.feed
-local eq = helpers.eq
-local eval = helpers.eval
-local matches = helpers.matches
-local exec_lua = helpers.exec_lua
-local retry = helpers.retry
+local feed = t.feed
+local eq = t.eq
+local eval = t.eval
+local matches = t.matches
+local exec_lua = t.exec_lua
+local retry = t.retry
before_each(clear)
diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua
index b28cfa4dd2..67d5da28a1 100644
--- a/test/functional/lua/luaeval_spec.lua
+++ b/test/functional/lua/luaeval_spec.lua
@@ -1,19 +1,19 @@
-- Test suite for testing luaeval() function
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local pcall_err = helpers.pcall_err
-local exc_exec = helpers.exc_exec
-local remove_trace = helpers.remove_trace
-local exec_lua = helpers.exec_lua
-local command = helpers.command
-local api = helpers.api
-local fn = helpers.fn
-local clear = helpers.clear
-local eval = helpers.eval
-local feed = helpers.feed
+local pcall_err = t.pcall_err
+local exc_exec = t.exc_exec
+local remove_trace = t.remove_trace
+local exec_lua = t.exec_lua
+local command = t.command
+local api = t.api
+local fn = t.fn
+local clear = t.clear
+local eval = t.eval
+local feed = t.feed
local NIL = vim.NIL
-local eq = helpers.eq
+local eq = t.eq
before_each(clear)
@@ -38,8 +38,8 @@ describe('luaeval()', function()
describe('second argument', function()
it('is successfully received', function()
- local t = {t=true, f=false, --[[n=NIL,]] d={l={'string', 42, 0.42}}}
- eq(t, fn.luaeval("_A", t))
+ local q = {t=true, f=false, --[[n=NIL,]] d={l={'string', 42, 0.42}}}
+ eq(q, fn.luaeval("_A", q))
-- Not tested: nil, funcrefs, returned object identity: behaviour will
-- most likely change.
end)
diff --git a/test/functional/lua/mpack_spec.lua b/test/functional/lua/mpack_spec.lua
index 0b6a6d60bd..28a316dd97 100644
--- a/test/functional/lua/mpack_spec.lua
+++ b/test/functional/lua/mpack_spec.lua
@@ -1,9 +1,9 @@
-- Test suite for testing interactions with API bindings
-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 exec_lua = helpers.exec_lua
+local clear = t.clear
+local eq = t.eq
+local exec_lua = t.exec_lua
describe('lua vim.mpack', function()
before_each(clear)
diff --git a/test/functional/lua/overrides_spec.lua b/test/functional/lua/overrides_spec.lua
index 428b2e0921..9b69857cd4 100644
--- a/test/functional/lua/overrides_spec.lua
+++ b/test/functional/lua/overrides_spec.lua
@@ -1,19 +1,19 @@
-- Test for Vim overrides of lua built-ins
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local eq = helpers.eq
+local eq = t.eq
local NIL = vim.NIL
-local feed = helpers.feed
-local clear = helpers.clear
-local fn = helpers.fn
-local api = helpers.api
-local command = helpers.command
-local write_file = helpers.write_file
-local exec_capture = helpers.exec_capture
-local exec_lua = helpers.exec_lua
-local pcall_err = helpers.pcall_err
-local is_os = helpers.is_os
+local feed = t.feed
+local clear = t.clear
+local fn = t.fn
+local api = t.api
+local command = t.command
+local write_file = t.write_file
+local exec_capture = t.exec_capture
+local exec_lua = t.exec_lua
+local pcall_err = t.pcall_err
+local is_os = t.is_os
local fname = 'Xtest-functional-lua-overrides-luafile'
diff --git a/test/functional/lua/runtime_spec.lua b/test/functional/lua/runtime_spec.lua
index 6f36ccfb9e..6acf6ce305 100644
--- a/test/functional/lua/runtime_spec.lua
+++ b/test/functional/lua/runtime_spec.lua
@@ -1,17 +1,17 @@
-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 eval = helpers.eval
-local exec = helpers.exec
-local fn = helpers.fn
-local mkdir_p = helpers.mkdir_p
-local rmdir = helpers.rmdir
-local write_file = helpers.write_file
+local clear = t.clear
+local eq = t.eq
+local eval = t.eval
+local exec = t.exec
+local fn = t.fn
+local mkdir_p = t.mkdir_p
+local rmdir = t.rmdir
+local write_file = t.write_file
describe('runtime:', function()
local plug_dir = 'Test_Plugin'
- local sep = helpers.get_pathsep()
+ local sep = t.get_pathsep()
local init = 'dummy_init.lua'
setup(function()
diff --git a/test/functional/lua/secure_spec.lua b/test/functional/lua/secure_spec.lua
index 20e73b9693..0a5c67ef38 100644
--- a/test/functional/lua/secure_spec.lua
+++ b/test/functional/lua/secure_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 eq = helpers.eq
-local clear = helpers.clear
-local command = helpers.command
-local pathsep = helpers.get_pathsep()
-local is_os = helpers.is_os
-local api = helpers.api
-local exec_lua = helpers.exec_lua
-local feed_command = helpers.feed_command
-local feed = helpers.feed
-local fn = helpers.fn
+local eq = t.eq
+local clear = t.clear
+local command = t.command
+local pathsep = t.get_pathsep()
+local is_os = t.is_os
+local api = t.api
+local exec_lua = t.exec_lua
+local feed_command = t.feed_command
+local feed = t.feed
+local fn = t.fn
local stdpath = fn.stdpath
-local pcall_err = helpers.pcall_err
-local matches = helpers.matches
-local read_file = helpers.read_file
+local pcall_err = t.pcall_err
+local matches = t.matches
+local read_file = t.read_file
describe('vim.secure', function()
describe('read()', function()
@@ -22,8 +22,8 @@ describe('vim.secure', function()
setup(function()
clear { env = { XDG_STATE_HOME = xstate } }
- helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
- helpers.write_file(
+ t.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
+ t.write_file(
'Xfile',
[[
let g:foobar = 42
@@ -33,7 +33,7 @@ describe('vim.secure', function()
teardown(function()
os.remove('Xfile')
- helpers.rmdir(xstate)
+ t.rmdir(xstate)
end)
it('works', function()
@@ -181,15 +181,15 @@ describe('vim.secure', function()
setup(function()
clear { env = { XDG_STATE_HOME = xstate } }
- helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
+ t.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
end)
teardown(function()
- helpers.rmdir(xstate)
+ t.rmdir(xstate)
end)
before_each(function()
- helpers.write_file('test_file', 'test')
+ t.write_file('test_file', 'test')
end)
after_each(function()
diff --git a/test/functional/lua/snippet_spec.lua b/test/functional/lua/snippet_spec.lua
index d31b8cc7d5..f1d0493f6e 100644
--- a/test/functional/lua/snippet_spec.lua
+++ b/test/functional/lua/snippet_spec.lua
@@ -1,16 +1,16 @@
-local helpers = require('test.functional.helpers')(after_each)
-
-local buf_lines = helpers.buf_lines
-local clear = helpers.clear
-local eq = helpers.eq
-local exec_lua = helpers.exec_lua
-local feed = helpers.feed
-local api = helpers.api
-local fn = helpers.fn
-local matches = helpers.matches
-local pcall_err = helpers.pcall_err
-local poke_eventloop = helpers.poke_eventloop
-local retry = helpers.retry
+local t = require('test.functional.testutil')(after_each)
+
+local buf_lines = t.buf_lines
+local clear = t.clear
+local eq = t.eq
+local exec_lua = t.exec_lua
+local feed = t.feed
+local api = t.api
+local fn = t.fn
+local matches = t.matches
+local pcall_err = t.pcall_err
+local poke_eventloop = t.poke_eventloop
+local retry = t.retry
describe('vim.snippet', function()
before_each(function()
diff --git a/test/functional/lua/spell_spec.lua b/test/functional/lua/spell_spec.lua
index e82dd7b4a0..dad223dbe3 100644
--- a/test/functional/lua/spell_spec.lua
+++ b/test/functional/lua/spell_spec.lua
@@ -1,8 +1,8 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
-local pcall_err = helpers.pcall_err
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
+local exec_lua = t.exec_lua
+local eq = t.eq
+local pcall_err = t.pcall_err
describe('vim.spell', function()
before_each(function()
diff --git a/test/functional/lua/system_spec.lua b/test/functional/lua/system_spec.lua
index cb561f0771..ba1581bc6b 100644
--- a/test/functional/lua/system_spec.lua
+++ b/test/functional/lua/system_spec.lua
@@ -1,7 +1,7 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
+local exec_lua = t.exec_lua
+local eq = t.eq
local function system_sync(cmd, opts)
return exec_lua(
diff --git a/test/functional/lua/text_spec.lua b/test/functional/lua/text_spec.lua
index e31aa63768..ecebb88af6 100644
--- a/test/functional/lua/text_spec.lua
+++ b/test/functional/lua/text_spec.lua
@@ -1,6 +1,6 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
-local eq = helpers.eq
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
+local eq = t.eq
describe('vim.text', function()
before_each(clear)
diff --git a/test/functional/lua/thread_spec.lua b/test/functional/lua/thread_spec.lua
index 9bbee73e27..6fb70c54d8 100644
--- a/test/functional/lua/thread_spec.lua
+++ b/test/functional/lua/thread_spec.lua
@@ -1,13 +1,13 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local assert_alive = helpers.assert_alive
-local clear = helpers.clear
-local feed = helpers.feed
-local eq = helpers.eq
-local exec_lua = helpers.exec_lua
-local next_msg = helpers.next_msg
+local assert_alive = t.assert_alive
+local clear = t.clear
+local feed = t.feed
+local eq = t.eq
+local exec_lua = t.exec_lua
+local next_msg = t.next_msg
local NIL = vim.NIL
-local pcall_err = helpers.pcall_err
+local pcall_err = t.pcall_err
describe('thread', function()
local screen
diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua
index 39c51d242c..1283448db5 100644
--- a/test/functional/lua/ui_event_spec.lua
+++ b/test/functional/lua/ui_event_spec.lua
@@ -1,12 +1,12 @@
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local eq = helpers.eq
-local exec_lua = helpers.exec_lua
-local clear = helpers.clear
-local feed = helpers.feed
-local fn = helpers.fn
-local assert_log = helpers.assert_log
-local check_close = helpers.check_close
+local eq = t.eq
+local exec_lua = t.exec_lua
+local clear = t.clear
+local feed = t.feed
+local fn = t.fn
+local assert_log = t.assert_log
+local check_close = t.check_close
local testlog = 'Xtest_lua_ui_event_log'
@@ -112,7 +112,7 @@ describe('vim.ui_attach', function()
it('does not crash on exit', function()
fn.system({
- helpers.nvim_prog,
+ t.nvim_prog,
'-u',
'NONE',
'-i',
@@ -124,7 +124,7 @@ describe('vim.ui_attach', function()
'--cmd',
'quitall!',
})
- eq(0, helpers.eval('v:shell_error'))
+ eq(0, t.eval('v:shell_error'))
end)
it('can receive accurate message kinds even if they are history', function()
diff --git a/test/functional/lua/ui_spec.lua b/test/functional/lua/ui_spec.lua
index e769843b19..eb0a58a4ee 100644
--- a/test/functional/lua/ui_spec.lua
+++ b/test/functional/lua/ui_spec.lua
@@ -1,13 +1,13 @@
-local helpers = require('test.functional.helpers')(after_each)
-local eq = helpers.eq
-local matches = helpers.matches
-local exec_lua = helpers.exec_lua
-local clear = helpers.clear
-local feed = helpers.feed
-local eval = helpers.eval
-local is_ci = helpers.is_ci
-local is_os = helpers.is_os
-local poke_eventloop = helpers.poke_eventloop
+local t = require('test.functional.testutil')(after_each)
+local eq = t.eq
+local matches = t.matches
+local exec_lua = t.exec_lua
+local clear = t.clear
+local feed = t.feed
+local eval = t.eval
+local is_ci = t.is_ci
+local is_os = t.is_os
+local poke_eventloop = t.poke_eventloop
describe('vim.ui', function()
before_each(function()
diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua
index dacaf95867..b759e9df21 100644
--- a/test/functional/lua/uri_spec.lua
+++ b/test/functional/lua/uri_spec.lua
@@ -1,10 +1,10 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
-local is_os = helpers.is_os
-local skip = helpers.skip
-local write_file = require('test.helpers').write_file
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
+local exec_lua = t.exec_lua
+local eq = t.eq
+local is_os = t.is_os
+local skip = t.skip
+local write_file = t.write_file
describe('URI methods', function()
before_each(function()
@@ -206,7 +206,7 @@ describe('URI methods', function()
it('Windows paths should not be treated as uris', function()
skip(not is_os('win'), 'Not applicable on non-Windows')
- local file = helpers.tmpname()
+ local file = t.tmpname()
write_file(file, 'Test content')
local test_case = string.format(
[[
diff --git a/test/functional/lua/version_spec.lua b/test/functional/lua/version_spec.lua
index 9f953daa9e..6f25aa3711 100644
--- a/test/functional/lua/version_spec.lua
+++ b/test/functional/lua/version_spec.lua
@@ -1,11 +1,11 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
-local eq = helpers.eq
-local ok = helpers.ok
-local exec_lua = helpers.exec_lua
-local matches = helpers.matches
-local pcall_err = helpers.pcall_err
-local fn = helpers.fn
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
+local eq = t.eq
+local ok = t.ok
+local exec_lua = t.exec_lua
+local matches = t.matches
+local pcall_err = t.pcall_err
+local fn = t.fn
local function v(ver)
return vim.version._version(ver)
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 8722c4dbb5..3757d2843a 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -1,32 +1,32 @@
-- Test suite for testing interactions with API bindings
-local helpers = require('test.functional.helpers')(after_each)
+local t = require('test.functional.testutil')(after_each)
local Screen = require('test.functional.ui.screen')
-local nvim_prog = helpers.nvim_prog
-local fn = helpers.fn
-local api = helpers.api
-local command = helpers.command
-local dedent = helpers.dedent
-local insert = helpers.insert
-local clear = helpers.clear
-local eq = helpers.eq
-local ok = helpers.ok
+local nvim_prog = t.nvim_prog
+local fn = t.fn
+local api = t.api
+local command = t.command
+local dedent = t.dedent
+local insert = t.insert
+local clear = t.clear
+local eq = t.eq
+local ok = t.ok
local pesc = vim.pesc
-local eval = helpers.eval
-local feed = helpers.feed
-local pcall_err = helpers.pcall_err
-local exec_lua = helpers.exec_lua
-local matches = helpers.matches
-local exec = helpers.exec
+local eval = t.eval
+local feed = t.feed
+local pcall_err = t.pcall_err
+local exec_lua = t.exec_lua
+local matches = t.matches
+local exec = t.exec
local NIL = vim.NIL
-local retry = helpers.retry
-local next_msg = helpers.next_msg
-local remove_trace = helpers.remove_trace
-local mkdir_p = helpers.mkdir_p
-local rmdir = helpers.rmdir
-local write_file = helpers.write_file
-local poke_eventloop = helpers.poke_eventloop
-local assert_alive = helpers.assert_alive
+local retry = t.retry
+local next_msg = t.next_msg
+local remove_trace = t.remove_trace
+local mkdir_p = t.mkdir_p
+local rmdir = t.rmdir
+local write_file = t.write_file
+local poke_eventloop = t.poke_eventloop
+local assert_alive = t.assert_alive
describe('lua stdlib', function()
before_each(clear)
@@ -592,8 +592,8 @@ describe('lua stdlib', function()
{ 'x*yz*oo*l', '*', true, false, { 'x', 'yz', 'oo', 'l' } },
}
- for _, t in ipairs(tests) do
- eq(t[5], vim.split(t[1], t[2], { plain = t[3], trimempty = t[4] }), t[1])
+ for _, q in ipairs(tests) do
+ eq(q[5], vim.split(q[1], q[2], { plain = q[3], trimempty = q[4] }), q[1])
end
-- Test old signature
@@ -603,8 +603,8 @@ describe('lua stdlib', function()
{ 'abc', '.-' },
}
- for _, t in ipairs(loops) do
- matches('Infinite loop detected', pcall_err(vim.split, t[1], t[2]))
+ for _, q in ipairs(loops) do
+ matches('Infinite loop detected', pcall_err(vim.split, q[1], q[2]))
end
-- Validates args.
@@ -626,8 +626,8 @@ describe('lua stdlib', function()
{ 'r\n', 'r' },
}
- for _, t in ipairs(trims) do
- assert(t[2], trim(t[1]))
+ for _, q in ipairs(trims) do
+ assert(q[2], trim(q[1]))
end
-- Validates args.
@@ -636,8 +636,8 @@ describe('lua stdlib', function()
it('vim.inspect', function()
-- just make sure it basically works, it has its own test suite
- local inspect = function(t, opts)
- return exec_lua('return vim.inspect(...)', t, opts)
+ local inspect = function(q, opts)
+ return exec_lua('return vim.inspect(...)', q, opts)
end
eq('2', inspect(2))
@@ -1569,7 +1569,7 @@ describe('lua stdlib', function()
eq(NIL, exec_lua([[return vim.g.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)
@@ -4071,7 +4071,7 @@ describe('vim.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('works with buffer-local mappings', function()
@@ -4095,7 +4095,7 @@ describe('vim.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('does not mutate the opts parameter', function()
diff --git a/test/functional/lua/watch_spec.lua b/test/functional/lua/watch_spec.lua
index 0da4b3164d..392ad07572 100644
--- a/test/functional/lua/watch_spec.lua
+++ b/test/functional/lua/watch_spec.lua
@@ -1,15 +1,15 @@
-local helpers = require('test.functional.helpers')(after_each)
-local eq = helpers.eq
-local exec_lua = helpers.exec_lua
-local clear = helpers.clear
-local is_ci = helpers.is_ci
-local is_os = helpers.is_os
-local skip = helpers.skip
+local t = require('test.functional.testutil')(after_each)
+local eq = t.eq
+local exec_lua = t.exec_lua
+local clear = t.clear
+local is_ci = t.is_ci
+local is_os = t.is_os
+local skip = t.skip
-- Create a file via a rename to avoid multiple
-- events which can happen with some backends on some platforms
local function touch(path)
- local tmp = helpers.tmpname()
+ local tmp = t.tmpname()
io.open(tmp, 'w'):close()
assert(vim.uv.fs_rename(tmp, path))
end
@@ -24,10 +24,7 @@ describe('vim._watch', function()
if watchfunc == 'fswatch' then
skip(is_os('win'), 'not supported on windows')
skip(is_os('mac'), 'flaky test on mac')
- skip(
- not is_ci() and helpers.fn.executable('fswatch') == 0,
- 'fswatch not installed and not on CI'
- )
+ skip(not is_ci() and t.fn.executable('fswatch') == 0, 'fswatch not installed and not on CI')
end
if watchfunc == 'watch' then
@@ -40,7 +37,7 @@ describe('vim._watch', function()
)
end
- local root_dir = vim.uv.fs_mkdtemp(vim.fs.dirname(helpers.tmpname()) .. '/nvim_XXXXXXXXXX')
+ local root_dir = vim.uv.fs_mkdtemp(vim.fs.dirname(t.tmpname()) .. '/nvim_XXXXXXXXXX')
local expected_events = 0
diff --git a/test/functional/lua/xdiff_spec.lua b/test/functional/lua/xdiff_spec.lua
index c21309c2e4..3a264385da 100644
--- a/test/functional/lua/xdiff_spec.lua
+++ b/test/functional/lua/xdiff_spec.lua
@@ -1,8 +1,8 @@
-local helpers = require('test.functional.helpers')(after_each)
-local clear = helpers.clear
-local exec_lua = helpers.exec_lua
-local eq = helpers.eq
-local pcall_err = helpers.pcall_err
+local t = require('test.functional.testutil')(after_each)
+local clear = t.clear
+local exec_lua = t.exec_lua
+local eq = t.eq
+local pcall_err = t.pcall_err
describe('xdiff bindings', function()
before_each(function()