mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 02:08:17 +00:00
test/functional: clean up according to luacheck (part 2)
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
-- vim: ft=lua
|
-- vim: ft=lua tw=80
|
||||||
|
|
||||||
|
-- Don't report globals from luajit or busted (e.g. jit.os or describe).
|
||||||
std = '+luajit +busted'
|
std = '+luajit +busted'
|
||||||
cache = true
|
|
||||||
|
-- One can't test these files properly; assume correctness.
|
||||||
exclude_files = { '*/preload.lua' }
|
exclude_files = { '*/preload.lua' }
|
||||||
|
|
||||||
|
-- Don't report unused self arguments of methods.
|
||||||
|
self = false
|
||||||
|
|
||||||
|
-- Rerun tests only if their modification time changed.
|
||||||
|
cache = true
|
||||||
|
@@ -19,7 +19,7 @@ describe("update_menu notification", function()
|
|||||||
screen:detach()
|
screen:detach()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function expect_sent(expected)
|
local function expect_sent(expected)
|
||||||
screen:wait(function()
|
screen:wait(function()
|
||||||
if screen.update_menu ~= expected then
|
if screen.update_menu ~= expected then
|
||||||
if expected then
|
if expected then
|
||||||
|
@@ -95,13 +95,13 @@ describe('server -> client', function()
|
|||||||
eq('notified!', eval('rpcrequest('..cid..', "notify")'))
|
eq('notified!', eval('rpcrequest('..cid..', "notify")'))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_request(method, args)
|
local function on_request(method)
|
||||||
eq('notify', method)
|
eq('notify', method)
|
||||||
eq(1, eval('rpcnotify('..cid..', "notification")'))
|
eq(1, eval('rpcnotify('..cid..', "notification")'))
|
||||||
return 'notified!'
|
return 'notified!'
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_notification(method, args)
|
local function on_notification(method)
|
||||||
eq('notification', method)
|
eq('notification', method)
|
||||||
if notified == expected then
|
if notified == expected then
|
||||||
stop()
|
stop()
|
||||||
|
@@ -180,6 +180,8 @@ describe('vim_* functions', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('err_write', function()
|
describe('err_write', function()
|
||||||
|
local screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
screen = Screen.new(40, 8)
|
screen = Screen.new(40, 8)
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
-- Sanity checks for window_* API calls via msgpack-rpc
|
-- Sanity checks for window_* API calls via msgpack-rpc
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, nvim, buffer, curbuf, curbuf_contents, window, curwin, eq, neq,
|
local clear, nvim, curbuf, curbuf_contents, window, curwin, eq, neq,
|
||||||
ok, feed, rawfeed, insert, eval = helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf,
|
ok, feed, insert, eval = helpers.clear, helpers.nvim, helpers.curbuf,
|
||||||
helpers.curbuf_contents, helpers.window, helpers.curwin, helpers.eq,
|
helpers.curbuf_contents, helpers.window, helpers.curwin, helpers.eq,
|
||||||
helpers.neq, helpers.ok, helpers.feed, helpers.rawfeed, helpers.insert, helpers.eval
|
helpers.neq, helpers.ok, helpers.feed, helpers.insert, helpers.eval
|
||||||
local wait = helpers.wait
|
local wait = helpers.wait
|
||||||
|
|
||||||
-- check if str is visible at the beginning of some line
|
-- check if str is visible at the beginning of some line
|
||||||
@@ -54,7 +54,7 @@ describe('window_* functions', function()
|
|||||||
insert("prologue")
|
insert("prologue")
|
||||||
feed('100o<esc>')
|
feed('100o<esc>')
|
||||||
insert("epilogue")
|
insert("epilogue")
|
||||||
win = curwin()
|
local win = curwin()
|
||||||
feed('gg')
|
feed('gg')
|
||||||
wait() -- let nvim process the 'gg' command
|
wait() -- let nvim process the 'gg' command
|
||||||
|
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
|
local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
|
||||||
helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
|
|
||||||
helpers.eq, helpers.neq, helpers.ok
|
|
||||||
|
|
||||||
describe('TabClosed', function()
|
describe('TabClosed', function()
|
||||||
describe('au TabClosed', function()
|
describe('au TabClosed', function()
|
||||||
@@ -20,7 +18,6 @@ describe('TabClosed', function()
|
|||||||
end)
|
end)
|
||||||
describe('with NR as <afile>', function()
|
describe('with NR as <afile>', function()
|
||||||
it('matches when closing a tab whose index is NR', function()
|
it('matches when closing a tab whose index is NR', function()
|
||||||
tmp_path = nvim('eval', 'tempname()')
|
|
||||||
nvim('command', 'au! TabClosed 2 echom "tabclosed:match"')
|
nvim('command', 'au! TabClosed 2 echom "tabclosed:match"')
|
||||||
repeat
|
repeat
|
||||||
nvim('command', 'tabnew')
|
nvim('command', 'tabnew')
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
|
local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
|
||||||
helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
|
|
||||||
helpers.eq, helpers.neq, helpers.ok
|
|
||||||
|
|
||||||
describe('TabNew', function()
|
describe('TabNew', function()
|
||||||
setup(clear)
|
setup(clear)
|
||||||
@@ -15,7 +13,7 @@ describe('TabNew', function()
|
|||||||
end)
|
end)
|
||||||
describe('with FILE as <afile>', function()
|
describe('with FILE as <afile>', function()
|
||||||
it('matches when opening a new tab for FILE', function()
|
it('matches when opening a new tab for FILE', function()
|
||||||
tmp_path = nvim('eval', 'tempname()')
|
local tmp_path = nvim('eval', 'tempname()')
|
||||||
nvim('command', 'au! TabNew '..tmp_path..' echom "tabnew:match"')
|
nvim('command', 'au! TabNew '..tmp_path..' echom "tabnew:match"')
|
||||||
eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path))
|
eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path))
|
||||||
end)
|
end)
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
|
local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
|
||||||
helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
|
|
||||||
helpers.eq, helpers.neq, helpers.ok
|
|
||||||
|
|
||||||
describe('TabNewEntered', function()
|
describe('TabNewEntered', function()
|
||||||
describe('au TabNewEntered', function()
|
describe('au TabNewEntered', function()
|
||||||
@@ -15,7 +13,7 @@ describe('TabNewEntered', function()
|
|||||||
end)
|
end)
|
||||||
describe('with FILE as <afile>', function()
|
describe('with FILE as <afile>', function()
|
||||||
it('matches when opening a new tab for FILE', function()
|
it('matches when opening a new tab for FILE', function()
|
||||||
tmp_path = nvim('eval', 'tempname()')
|
local tmp_path = nvim('eval', 'tempname()')
|
||||||
nvim('command', 'au! TabNewEntered '..tmp_path..' echom "tabnewentered:match"')
|
nvim('command', 'au! TabNewEntered '..tmp_path..' echom "tabnewentered:match"')
|
||||||
eq("\n\""..tmp_path.."\" [New File]\ntabnewentered:4:4\ntabnewentered:match", nvim('command_output', 'tabnew '..tmp_path))
|
eq("\n\""..tmp_path.."\" [New File]\ntabnewentered:4:4\ntabnewentered:match", nvim('command_output', 'tabnew '..tmp_path))
|
||||||
end)
|
end)
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
|
|
||||||
local clear, eval, execute, feed, nvim, nvim_dir = helpers.clear, helpers.eval,
|
local clear, execute, feed, nvim, nvim_dir = helpers.clear,
|
||||||
helpers.execute, helpers.feed, helpers.nvim, helpers.nvim_dir
|
helpers.execute, helpers.feed, helpers.nvim, helpers.nvim_dir
|
||||||
local wait = helpers.wait
|
|
||||||
|
|
||||||
describe('TermClose event', function()
|
describe('TermClose event', function()
|
||||||
|
local screen
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
nvim('set_option', 'shell', nvim_dir .. '/shell-test')
|
nvim('set_option', 'shell', nvim_dir .. '/shell-test')
|
||||||
|
@@ -4,7 +4,6 @@ local helpers = require('test.functional.helpers')
|
|||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
||||||
local execute, expect, eq, eval = helpers.execute, helpers.expect, helpers.eq, helpers.eval
|
local execute, expect, eq, eval = helpers.execute, helpers.expect, helpers.eq, helpers.eval
|
||||||
local nvim, run, stop, restart = helpers.nvim, helpers.run, helpers.stop, helpers.restart
|
|
||||||
|
|
||||||
local function basic_register_test(noblock)
|
local function basic_register_test(noblock)
|
||||||
insert("some words")
|
insert("some words")
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
local lfs = require('lfs')
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, execute, eval, eq = helpers.clear, helpers.execute, helpers.eval, helpers.eq
|
local clear, execute, eval, eq = helpers.clear, helpers.execute, helpers.eval, helpers.eq
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
|
local clear = helpers.clear
|
||||||
local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq
|
local eval, eq = helpers.eval, helpers.eq
|
||||||
local execute, source = helpers.execute, helpers.source
|
local execute = helpers.execute
|
||||||
local nvim = helpers.nvim
|
local nvim = helpers.nvim
|
||||||
local exc_exec = helpers.exc_exec
|
local exc_exec = helpers.exc_exec
|
||||||
|
|
||||||
@@ -454,9 +454,9 @@ describe('msgpackparse() function', function()
|
|||||||
it('msgpackparse(systemlist(...)) does not segfault. #3135', function()
|
it('msgpackparse(systemlist(...)) does not segfault. #3135', function()
|
||||||
local cmd = "sort(keys(msgpackparse(systemlist('"
|
local cmd = "sort(keys(msgpackparse(systemlist('"
|
||||||
..helpers.nvim_prog.." --api-info'))[0]))"
|
..helpers.nvim_prog.." --api-info'))[0]))"
|
||||||
local api_info = eval(cmd)
|
eval(cmd)
|
||||||
api_info = eval(cmd) -- do it again (try to force segfault)
|
eval(cmd) -- do it again (try to force segfault)
|
||||||
api_info = eval(cmd) -- do it again
|
local api_info = eval(cmd) -- do it again
|
||||||
eq({'error_types', 'functions', 'types'}, api_info)
|
eq({'error_types', 'functions', 'types'}, api_info)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, execute, nvim, feed, eq, ok, eval =
|
local clear, execute, feed, ok, eval =
|
||||||
helpers.clear, helpers.execute, helpers.nvim, helpers.feed,
|
helpers.clear, helpers.execute, helpers.feed, helpers.ok, helpers.eval
|
||||||
helpers.eq, helpers.ok, helpers.eval
|
|
||||||
|
|
||||||
describe(':grep', function()
|
describe(':grep', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
@@ -2,7 +2,7 @@ local Screen = require('test.functional.ui.screen')
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
|
|
||||||
local buf, eq, execute = helpers.curbufmeths, helpers.eq, helpers.execute
|
local buf, eq, execute = helpers.curbufmeths, helpers.eq, helpers.execute
|
||||||
local feed, nvim, nvim_prog = helpers.feed, helpers.nvim, helpers.nvim_prog
|
local feed, nvim_prog = helpers.feed, helpers.nvim_prog
|
||||||
local ok, set_session, spawn = helpers.ok, helpers.set_session, helpers.spawn
|
local ok, set_session, spawn = helpers.ok, helpers.set_session, helpers.spawn
|
||||||
|
|
||||||
local shada_file = 'test.shada'
|
local shada_file = 'test.shada'
|
||||||
@@ -11,9 +11,6 @@ local shada_file = 'test.shada'
|
|||||||
-- helpers.clear() uses "-i NONE", which is not useful for this test.
|
-- helpers.clear() uses "-i NONE", which is not useful for this test.
|
||||||
--
|
--
|
||||||
local function _clear()
|
local function _clear()
|
||||||
if session then
|
|
||||||
session:exit(0)
|
|
||||||
end
|
|
||||||
set_session(spawn({nvim_prog,
|
set_session(spawn({nvim_prog,
|
||||||
'-u', 'NONE',
|
'-u', 'NONE',
|
||||||
'--cmd', 'set noswapfile undodir=. directory=. viewdir=. backupdir=.',
|
'--cmd', 'set noswapfile undodir=. directory=. viewdir=. backupdir=.',
|
||||||
@@ -32,7 +29,7 @@ describe(':oldfiles', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
it('shows most recently used files', function()
|
it('shows most recently used files', function()
|
||||||
screen = Screen.new(100, 5)
|
local screen = Screen.new(100, 5)
|
||||||
screen:attach()
|
screen:attach()
|
||||||
execute('edit testfile1')
|
execute('edit testfile1')
|
||||||
execute('edit testfile2')
|
execute('edit testfile2')
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
require('os')
|
require('os')
|
||||||
require('lfs')
|
local lfs = require('lfs')
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local execute, eq, clear = helpers.execute, helpers.eq, helpers.clear
|
local clear = helpers.clear
|
||||||
|
|
||||||
describe(':qa', function()
|
describe(':qa', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
-- Tests for :recover
|
-- Tests for :recover
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
|
local lfs = require('lfs')
|
||||||
local execute, eq, clear, eval, feed, expect, source =
|
local execute, eq, clear, eval, feed, expect, source =
|
||||||
helpers.execute, helpers.eq, helpers.clear, helpers.eval, helpers.feed,
|
helpers.execute, helpers.eq, helpers.clear, helpers.eval, helpers.feed,
|
||||||
helpers.expect, helpers.source
|
helpers.expect, helpers.source
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, nvim, buffer, curbuf, curwin, eq, ok =
|
local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
|
||||||
helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
|
|
||||||
helpers.eq, helpers.ok
|
|
||||||
|
|
||||||
describe('sign', function()
|
describe('sign', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
local helpers, lfs = require('test.functional.helpers'), require('lfs')
|
local helpers, lfs = require('test.functional.helpers'), require('lfs')
|
||||||
local clear, execute, eq, neq, spawn, nvim_prog, set_session, wait, write_file
|
local execute, eq, neq, spawn, nvim_prog, set_session, wait, write_file
|
||||||
= helpers.clear, helpers.execute, helpers.eq, helpers.neq, helpers.spawn,
|
= helpers.execute, helpers.eq, helpers.neq, helpers.spawn,
|
||||||
helpers.nvim_prog, helpers.set_session, helpers.wait, helpers.write_file
|
helpers.nvim_prog, helpers.set_session, helpers.wait, helpers.write_file
|
||||||
|
|
||||||
describe(':wshada', function()
|
describe(':wshada', function()
|
||||||
@@ -13,7 +13,7 @@ describe(':wshada', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Override the default session because we need 'swapfile' for these tests.
|
-- Override the default session because we need 'swapfile' for these tests.
|
||||||
local session = spawn({nvim_prog, '-u', 'NONE', '-i', '/dev/null', '--embed',
|
session = spawn({nvim_prog, '-u', 'NONE', '-i', '/dev/null', '--embed',
|
||||||
'--cmd', 'set swapfile'})
|
'--cmd', 'set swapfile'})
|
||||||
set_session(session)
|
set_session(session)
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
require('coxpcall')
|
require('coxpcall')
|
||||||
|
local lfs = require('lfs')
|
||||||
local assert = require('luassert')
|
local assert = require('luassert')
|
||||||
local Loop = require('nvim.loop')
|
local Loop = require('nvim.loop')
|
||||||
local MsgpackStream = require('nvim.msgpack_stream')
|
local MsgpackStream = require('nvim.msgpack_stream')
|
||||||
@@ -55,7 +56,7 @@ if prepend_argv then
|
|||||||
nvim_argv = new_nvim_argv
|
nvim_argv = new_nvim_argv
|
||||||
end
|
end
|
||||||
|
|
||||||
local session, loop_running, loop_stopped, last_error
|
local session, loop_running, last_error
|
||||||
|
|
||||||
local function set_session(s)
|
local function set_session(s)
|
||||||
session = s
|
session = s
|
||||||
@@ -79,7 +80,7 @@ local function next_message()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function call_and_stop_on_error(...)
|
local function call_and_stop_on_error(...)
|
||||||
local status, result = copcall(...)
|
local status, result = copcall(...) -- luacheck: ignore
|
||||||
if not status then
|
if not status then
|
||||||
session:stop()
|
session:stop()
|
||||||
last_error = result
|
last_error = result
|
||||||
@@ -109,7 +110,6 @@ local function run(request_cb, notification_cb, setup_cb, timeout)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
loop_stopped = false
|
|
||||||
loop_running = true
|
loop_running = true
|
||||||
session:run(on_request, on_notification, on_setup, timeout)
|
session:run(on_request, on_notification, on_setup, timeout)
|
||||||
loop_running = false
|
loop_running = false
|
||||||
@@ -121,7 +121,6 @@ local function run(request_cb, notification_cb, setup_cb, timeout)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function stop()
|
local function stop()
|
||||||
loop_stopped = true
|
|
||||||
session:stop()
|
session:stop()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -197,9 +196,9 @@ local function spawn(argv, merge)
|
|||||||
local loop = Loop.new()
|
local loop = Loop.new()
|
||||||
local msgpack_stream = MsgpackStream.new(loop)
|
local msgpack_stream = MsgpackStream.new(loop)
|
||||||
local async_session = AsyncSession.new(msgpack_stream)
|
local async_session = AsyncSession.new(msgpack_stream)
|
||||||
local session = Session.new(async_session)
|
local sess = Session.new(async_session)
|
||||||
loop:spawn(merge and merge_args(prepend_argv, argv) or argv)
|
loop:spawn(merge and merge_args(prepend_argv, argv) or argv)
|
||||||
return session
|
return sess
|
||||||
end
|
end
|
||||||
|
|
||||||
local function clear(extra_cmd)
|
local function clear(extra_cmd)
|
||||||
@@ -332,14 +331,14 @@ local function rmdir(path)
|
|||||||
if file == '.' or file == '..' then
|
if file == '.' or file == '..' then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
ret, err = os.remove(path..'/'..file)
|
local ret, err = os.remove(path..'/'..file)
|
||||||
if not ret then
|
if not ret then
|
||||||
error('os.remove: '..err)
|
error('os.remove: '..err)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
ret, err = os.remove(path)
|
local ret, err = os.remove(path)
|
||||||
if not ret then
|
if not ret then
|
||||||
error('os.remove: '..err)
|
error('os.remove: '..err)
|
||||||
end
|
end
|
||||||
@@ -371,15 +370,15 @@ local function redir_exec(cmd)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function create_callindex(func)
|
local function create_callindex(func)
|
||||||
local tbl = {}
|
local table = {}
|
||||||
setmetatable(tbl, {
|
setmetatable(table, {
|
||||||
__index = function(tbl, arg1)
|
__index = function(tbl, arg1)
|
||||||
ret = function(...) return func(arg1, ...) end
|
local ret = function(...) return func(arg1, ...) end
|
||||||
tbl[arg1] = ret
|
tbl[arg1] = ret
|
||||||
return ret
|
return ret
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
return tbl
|
return table
|
||||||
end
|
end
|
||||||
|
|
||||||
local funcs = create_callindex(nvim_call)
|
local funcs = create_callindex(nvim_call)
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, eq, eval, execute, expect, feed, insert, neq, next_msg, nvim,
|
local clear, eq, eval, execute, feed, insert, neq, next_msg, nvim,
|
||||||
nvim_dir, ok, run, session, source, stop, wait, write_file = helpers.clear,
|
nvim_dir, ok, source, write_file = helpers.clear,
|
||||||
helpers.eq, helpers.eval, helpers.execute, helpers.expect, helpers.feed,
|
helpers.eq, helpers.eval, helpers.execute, helpers.feed,
|
||||||
helpers.insert, helpers.neq, helpers.next_message, helpers.nvim,
|
helpers.insert, helpers.neq, helpers.next_message, helpers.nvim,
|
||||||
helpers.nvim_dir, helpers.ok, helpers.run, helpers.session, helpers.source,
|
helpers.nvim_dir, helpers.ok, helpers.source,
|
||||||
helpers.stop, helpers.wait, helpers.write_file
|
helpers.write_file
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
|
|
||||||
|
|
||||||
@@ -370,7 +370,7 @@ describe('jobs', function()
|
|||||||
|
|
||||||
describe('running tty-test program', function()
|
describe('running tty-test program', function()
|
||||||
local function next_chunk()
|
local function next_chunk()
|
||||||
local rv = ''
|
local rv
|
||||||
while true do
|
while true do
|
||||||
local msg = next_msg()
|
local msg = next_msg()
|
||||||
local data = msg[3][2]
|
local data = msg[3][2]
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
-- in the original test. These have been converted to "it" test cases here.
|
-- in the original test. These have been converted to "it" test cases here.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local feed, insert = helpers.feed, helpers.insert
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
-- Inserts text as usual, and additionally positions the cursor on line 1 and
|
-- Inserts text as usual, and additionally positions the cursor on line 1 and
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-- Test for Bufleave autocommand that deletes the buffer we are about to edit.
|
-- Test for Bufleave autocommand that deletes the buffer we are about to edit.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, insert = helpers.clear, helpers.insert
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local execute, expect = helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('BufLeave autocommand', function()
|
describe('BufLeave autocommand', function()
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
-- Also test undo after ":%s" and formatting.
|
-- Also test undo after ":%s" and formatting.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local feed, insert = helpers.feed, helpers.insert
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('alignment', function()
|
describe('alignment', function()
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-- Tests for file with some lines ending in CTRL-M, some not
|
-- Tests for file with some lines ending in CTRL-M, some not
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, feed = helpers.clear, helpers.feed
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local execute, expect = helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('line ending', function()
|
describe('line ending', function()
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-- Tests for complicated + argument to :edit command
|
-- Tests for complicated + argument to :edit command
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, insert = helpers.clear, helpers.insert
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local execute, expect = helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe(':edit', function()
|
describe(':edit', function()
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-- Test for :execute, :while and :if
|
-- Test for :execute, :while and :if
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear = helpers.clear
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local execute, expect = helpers.execute, helpers.expect
|
||||||
local source = helpers.source
|
local source = helpers.source
|
||||||
|
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
-- Test for expanding file names
|
-- Test for expanding file names
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, feed = helpers.clear, helpers.feed
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local execute = helpers.execute
|
||||||
local curbuf_contents = helpers.curbuf_contents
|
local curbuf_contents = helpers.curbuf_contents
|
||||||
local eq, eval = helpers.eq, helpers.eval
|
local eq = helpers.eq
|
||||||
|
|
||||||
describe('expand file name', function()
|
describe('expand file name', function()
|
||||||
setup(clear)
|
setup(clear)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-- Test for joining lines with marks in them (and with 'joinspaces' set/reset)
|
-- Test for joining lines with marks in them (and with 'joinspaces' set/reset)
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local feed, insert = helpers.feed, helpers.insert
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('joining lines', function()
|
describe('joining lines', function()
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
-- :edit
|
-- :edit
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local feed, insert = helpers.feed, helpers.insert
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('Commands that close windows and/or buffers', function()
|
describe('Commands that close windows and/or buffers', function()
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-- Test Virtual replace mode.
|
-- Test Virtual replace mode.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local feed = helpers.feed
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('Virtual replace mode', function()
|
describe('Virtual replace mode', function()
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
-- This test contains both "test44" and "test99" from the old test suite.
|
-- This test contains both "test44" and "test99" from the old test suite.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local feed, insert = helpers.feed, helpers.insert
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
-- Runs the test protocol with the given 'regexpengine' setting. In the old test
|
-- Runs the test protocol with the given 'regexpengine' setting. In the old test
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local expect = helpers.expect
|
||||||
|
|
||||||
describe('multi-line regexp', function()
|
describe('multi-line regexp', function()
|
||||||
setup(clear)
|
setup(clear)
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, feed = helpers.clear, helpers.feed
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local execute, expect = helpers.execute, helpers.expect
|
||||||
local wait = helpers.wait
|
local wait = helpers.wait
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local expect = helpers.expect
|
||||||
|
|
||||||
describe('source function', function()
|
describe('source function', function()
|
||||||
setup(clear)
|
setup(clear)
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
-- Tests for the exists() and has() functions.
|
-- Tests for the exists() and has() functions.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local source = helpers.source
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, expect = helpers.clear, helpers.expect
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
|
|
||||||
describe('exists() and has() functions', function()
|
describe('exists() and has() functions', function()
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
-- Tests for undo tree and :earlier and :later.
|
-- Tests for undo tree and :earlier and :later.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source, eq, eval, clear, execute, expect, wait, write_file
|
local feed, source, eq, eval, clear, execute, expect, wait, write_file =
|
||||||
= helpers.feed, helpers.insert, helpers.source, helpers.eq, helpers.eval,
|
helpers.feed, helpers.source, helpers.eq, helpers.eval,
|
||||||
helpers.clear, helpers.execute, helpers.expect, helpers.wait,
|
helpers.clear, helpers.execute, helpers.expect, helpers.wait,
|
||||||
helpers.write_file
|
helpers.write_file
|
||||||
|
|
||||||
@@ -97,9 +97,8 @@ describe('undo tree:', function()
|
|||||||
|
|
||||||
-- Retry up to 3 times. pcall() is _not_ used for the final attempt, so
|
-- Retry up to 3 times. pcall() is _not_ used for the final attempt, so
|
||||||
-- that failure messages can bubble up.
|
-- that failure messages can bubble up.
|
||||||
local success, result = false, ''
|
for _ = 1, 2 do
|
||||||
for i = 1, 2 do
|
local success = pcall(test_earlier_later)
|
||||||
success, result = pcall(test_earlier_later)
|
|
||||||
if success then
|
if success then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local feed, insert = helpers.feed, helpers.insert
|
||||||
local eval, clear, execute, expect = helpers.eval, helpers.clear, helpers.execute
|
local eval, clear, execute = helpers.eval, helpers.clear, helpers.execute
|
||||||
local expect, eq, neq = helpers.expect, helpers.eq, helpers.neq
|
local eq, neq = helpers.eq, helpers.neq
|
||||||
local command = helpers.command
|
|
||||||
|
|
||||||
describe('063: Test for ":match", "matchadd()" and related functions', function()
|
describe('063: Test for ":match", "matchadd()" and related functions', function()
|
||||||
setup(clear)
|
setup(clear)
|
||||||
@@ -86,7 +85,7 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
|
|||||||
execute("2match MyGroup2 /HUMPPA/")
|
execute("2match MyGroup2 /HUMPPA/")
|
||||||
execute("3match MyGroup3 /VIM/")
|
execute("3match MyGroup3 /VIM/")
|
||||||
execute("let ml = getmatches()")
|
execute("let ml = getmatches()")
|
||||||
ml = eval("ml")
|
local ml = eval("ml")
|
||||||
execute("call clearmatches()")
|
execute("call clearmatches()")
|
||||||
execute("call setmatches(ml)")
|
execute("call setmatches(ml)")
|
||||||
eq(ml, eval('getmatches()'))
|
eq(ml, eval('getmatches()'))
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-- Test for floating point and logical operators.
|
-- Test for floating point and logical operators.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local insert, source = helpers.insert, helpers.source
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('floating point and logical operators', function()
|
describe('floating point and logical operators', function()
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
-- autocommands.
|
-- autocommands.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear = helpers.clear
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local execute, expect = helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('augroup when calling exists()', function()
|
describe('augroup when calling exists()', function()
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
-- undo-able pieces. Do that by setting 'undolevels'.
|
-- undo-able pieces. Do that by setting 'undolevels'.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local feed, insert = helpers.feed, helpers.insert
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('72', function()
|
describe('72', function()
|
||||||
|
@@ -13,7 +13,7 @@ describe('storing global variables in ShaDa files', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('is working', function()
|
it('is working', function()
|
||||||
local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE',
|
local nvim2 = spawn({helpers.nvim_prog, '-u', 'NONE',
|
||||||
'-i', 'Xviminfo', '--embed'})
|
'-i', 'Xviminfo', '--embed'})
|
||||||
helpers.set_session(nvim2)
|
helpers.set_session(nvim2)
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
-- Also test utf8 map with a 0x80 byte.
|
-- Also test utf8 map with a 0x80 byte.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, feed = helpers.clear, helpers.feed
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local execute, expect = helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('maparg()', function()
|
describe('maparg()', function()
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
-- If it isn't available then the test will be skipped.
|
-- If it isn't available then the test will be skipped.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
local feed = helpers.feed
|
||||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
describe('mf_hash_grow()', function()
|
describe('mf_hash_grow()', function()
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, expect, source = helpers.clear, helpers.expect, helpers.source
|
local clear, expect, source = helpers.clear, helpers.expect, helpers.source
|
||||||
local eval = helpers.eval
|
|
||||||
|
|
||||||
describe('78', function()
|
describe('78', function()
|
||||||
setup(clear)
|
setup(clear)
|
||||||
|
@@ -9,15 +9,15 @@ local additional_cmd = ''
|
|||||||
local function nvim_argv(shada_file)
|
local function nvim_argv(shada_file)
|
||||||
local rtp_value = ('\'%s/runtime\''):format(
|
local rtp_value = ('\'%s/runtime\''):format(
|
||||||
paths.test_source_path:gsub('\'', '\'\''))
|
paths.test_source_path:gsub('\'', '\'\''))
|
||||||
local nvim_argv = {nvim_prog, '-u', 'NORC', '-i', shada_file or 'NONE', '-N',
|
local nvim_args = {nvim_prog, '-u', 'NORC', '-i', shada_file or 'NONE', '-N',
|
||||||
'--cmd', 'set shortmess+=I background=light noswapfile',
|
'--cmd', 'set shortmess+=I background=light noswapfile',
|
||||||
'--cmd', 'let &runtimepath=' .. rtp_value,
|
'--cmd', 'let &runtimepath=' .. rtp_value,
|
||||||
'--cmd', additional_cmd,
|
'--cmd', additional_cmd,
|
||||||
'--embed'}
|
'--embed'}
|
||||||
if helpers.prepend_argv then
|
if helpers.prepend_argv then
|
||||||
return merge_args(helpers.prepend_argv, nvim_argv)
|
return merge_args(helpers.prepend_argv, nvim_args)
|
||||||
else
|
else
|
||||||
return nvim_argv
|
return nvim_args
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -11,7 +11,6 @@ local reset = plugin_helpers.reset
|
|||||||
|
|
||||||
local shada_helpers = require('test.functional.shada.helpers')
|
local shada_helpers = require('test.functional.shada.helpers')
|
||||||
local get_shada_rw = shada_helpers.get_shada_rw
|
local get_shada_rw = shada_helpers.get_shada_rw
|
||||||
local read_shada_file = shada_helpers.read_shada_file
|
|
||||||
|
|
||||||
local mpack_eq = function(expected, mpack_result)
|
local mpack_eq = function(expected, mpack_result)
|
||||||
local mpack_keys = {'type', 'timestamp', 'length', 'value'}
|
local mpack_keys = {'type', 'timestamp', 'length', 'value'}
|
||||||
@@ -96,10 +95,10 @@ describe('In autoload/shada.vim', function()
|
|||||||
return a[1] < b[1]
|
return a[1] < b[1]
|
||||||
end)
|
end)
|
||||||
local state = {i=0}
|
local state = {i=0}
|
||||||
return (function(state, var)
|
return (function(state_, _)
|
||||||
state.i = state.i + 1
|
state_.i = state_.i + 1
|
||||||
if ret[state.i] then
|
if ret[state_.i] then
|
||||||
return table.unpack(ret[state.i])
|
return table.unpack(ret[state_.i])
|
||||||
end
|
end
|
||||||
end), state
|
end), state
|
||||||
end
|
end
|
||||||
@@ -2103,8 +2102,8 @@ describe('In plugin/shada.vim', function()
|
|||||||
os.remove(fname_tmp)
|
os.remove(fname_tmp)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local shada_eq = function(expected, fname)
|
local shada_eq = function(expected, fname_)
|
||||||
local fd = io.open(fname)
|
local fd = io.open(fname_)
|
||||||
local mpack_result = fd:read('*a')
|
local mpack_result = fd:read('*a')
|
||||||
fd:close()
|
fd:close()
|
||||||
mpack_eq(expected, mpack_result)
|
mpack_eq(expected, mpack_result)
|
||||||
@@ -2574,6 +2573,7 @@ describe('syntax/shada.vim', function()
|
|||||||
'ShaDaEntryMapHeader'}, s} end
|
'ShaDaEntryMapHeader'}, s} end
|
||||||
local ah = function(s) return {{'ShaDaEntryArray',
|
local ah = function(s) return {{'ShaDaEntryArray',
|
||||||
'ShaDaEntryArrayHeader'}, s} end
|
'ShaDaEntryArrayHeader'}, s} end
|
||||||
|
-- luacheck: ignore
|
||||||
local mses = function(s) return {{'ShaDaEntryMapShort',
|
local mses = function(s) return {{'ShaDaEntryMapShort',
|
||||||
'ShaDaEntryMapShortEntryStart'}, s} end
|
'ShaDaEntryMapShortEntryStart'}, s} end
|
||||||
local mles = function(s) return {{'ShaDaEntryMapLong',
|
local mles = function(s) return {{'ShaDaEntryMapLong',
|
||||||
|
@@ -175,6 +175,8 @@ describe('tui with non-tty file descriptors', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('tui focus event handling', function()
|
describe('tui focus event handling', function()
|
||||||
|
local screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
helpers.clear()
|
helpers.clear()
|
||||||
screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
|
screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
|
||||||
|
@@ -106,7 +106,7 @@
|
|||||||
-- use `screen:snapshot_util({},true)`
|
-- use `screen:snapshot_util({},true)`
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local request, run, stop = helpers.request, helpers.run, helpers.stop
|
local request, run = helpers.request, helpers.run
|
||||||
local dedent = helpers.dedent
|
local dedent = helpers.dedent
|
||||||
|
|
||||||
local Screen = {}
|
local Screen = {}
|
||||||
@@ -241,7 +241,7 @@ function Screen:wait(check, timeout)
|
|||||||
checked = true
|
checked = true
|
||||||
if not err then
|
if not err then
|
||||||
success_seen = true
|
success_seen = true
|
||||||
stop()
|
helpers.stop()
|
||||||
elseif success_seen and #args > 0 then
|
elseif success_seen and #args > 0 then
|
||||||
failure_after_success = true
|
failure_after_success = true
|
||||||
--print(require('inspect')(args))
|
--print(require('inspect')(args))
|
||||||
@@ -448,7 +448,7 @@ function Screen:_row_repr(row, attr_ids, attr_ignore)
|
|||||||
local rv = {}
|
local rv = {}
|
||||||
local current_attr_id
|
local current_attr_id
|
||||||
for i = 1, self._width do
|
for i = 1, self._width do
|
||||||
local attr_id = get_attr_id(attr_ids, attr_ignore, row[i].attrs)
|
local attr_id = self:_get_attr_id(attr_ids, attr_ignore, row[i].attrs)
|
||||||
if current_attr_id and attr_id ~= current_attr_id then
|
if current_attr_id and attr_id ~= current_attr_id then
|
||||||
-- close current attribute bracket, add it before any whitespace
|
-- close current attribute bracket, add it before any whitespace
|
||||||
-- up to the current cell
|
-- up to the current cell
|
||||||
@@ -524,8 +524,8 @@ function Screen:print_snapshot(attrs, ignore)
|
|||||||
local row = self._rows[i]
|
local row = self._rows[i]
|
||||||
for j = 1, self._width do
|
for j = 1, self._width do
|
||||||
local attr = row[j].attrs
|
local attr = row[j].attrs
|
||||||
if attr_index(attrs, attr) == nil and attr_index(ignore, attr) == nil then
|
if self:_attr_index(attrs, attr) == nil and self:_attr_index(ignore, attr) == nil then
|
||||||
if not equal_attrs(attr, {}) then
|
if not self:_equal_attrs(attr, {}) then
|
||||||
table.insert(attrs, attr)
|
table.insert(attrs, attr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -544,7 +544,7 @@ function Screen:print_snapshot(attrs, ignore)
|
|||||||
if self._default_attr_ids == nil or self._default_attr_ids[i] ~= a then
|
if self._default_attr_ids == nil or self._default_attr_ids[i] ~= a then
|
||||||
alldefault = false
|
alldefault = false
|
||||||
end
|
end
|
||||||
local dict = "{"..pprint_attrs(a).."}"
|
local dict = "{"..self:_pprint_attrs(a).."}"
|
||||||
table.insert(attrstrs, "["..tostring(i).."] = "..dict)
|
table.insert(attrstrs, "["..tostring(i).."] = "..dict)
|
||||||
end
|
end
|
||||||
local attrstr = "{"..table.concat(attrstrs, ", ").."}"
|
local attrstr = "{"..table.concat(attrstrs, ", ").."}"
|
||||||
@@ -558,7 +558,7 @@ function Screen:print_snapshot(attrs, ignore)
|
|||||||
io.stdout:flush()
|
io.stdout:flush()
|
||||||
end
|
end
|
||||||
|
|
||||||
function pprint_attrs(attrs)
|
function Screen:_pprint_attrs(attrs)
|
||||||
local items = {}
|
local items = {}
|
||||||
for f, v in pairs(attrs) do
|
for f, v in pairs(attrs) do
|
||||||
local desc = tostring(v)
|
local desc = tostring(v)
|
||||||
@@ -572,7 +572,7 @@ function pprint_attrs(attrs)
|
|||||||
return table.concat(items, ", ")
|
return table.concat(items, ", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
function backward_find_meaningful(tbl, from)
|
function backward_find_meaningful(tbl, from) -- luacheck: ignore
|
||||||
for i = from or #tbl, 1, -1 do
|
for i = from or #tbl, 1, -1 do
|
||||||
if tbl[i] ~= ' ' then
|
if tbl[i] ~= ' ' then
|
||||||
return i + 1
|
return i + 1
|
||||||
@@ -581,24 +581,24 @@ function backward_find_meaningful(tbl, from)
|
|||||||
return from
|
return from
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_attr_id(attr_ids, ignore, attrs)
|
function Screen:_get_attr_id(attr_ids, ignore, attrs)
|
||||||
if not attr_ids then
|
if not attr_ids then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
for id, a in pairs(attr_ids) do
|
for id, a in pairs(attr_ids) do
|
||||||
if equal_attrs(a, attrs) then
|
if self:_equal_attrs(a, attrs) then
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if equal_attrs(attrs, {}) or
|
if self:_equal_attrs(attrs, {}) or
|
||||||
ignore == true or attr_index(ignore, attrs) ~= nil then
|
ignore == true or self:_attr_index(ignore, attrs) ~= nil then
|
||||||
-- ignore this attrs
|
-- ignore this attrs
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
return "UNEXPECTED "..pprint_attrs(attrs)
|
return "UNEXPECTED "..self:_pprint_attrs(attrs)
|
||||||
end
|
end
|
||||||
|
|
||||||
function equal_attrs(a, b)
|
function Screen:_equal_attrs(a, b)
|
||||||
return a.bold == b.bold and a.standout == b.standout and
|
return a.bold == b.bold and a.standout == b.standout and
|
||||||
a.underline == b.underline and a.undercurl == b.undercurl and
|
a.underline == b.underline and a.undercurl == b.undercurl and
|
||||||
a.italic == b.italic and a.reverse == b.reverse and
|
a.italic == b.italic and a.reverse == b.reverse and
|
||||||
@@ -606,12 +606,12 @@ function equal_attrs(a, b)
|
|||||||
a.background == b.background
|
a.background == b.background
|
||||||
end
|
end
|
||||||
|
|
||||||
function attr_index(attrs, attr)
|
function Screen:_attr_index(attrs, attr)
|
||||||
if not attrs then
|
if not attrs then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
for i,a in pairs(attrs) do
|
for i,a in pairs(attrs) do
|
||||||
if equal_attrs(a, attr) then
|
if self:_equal_attrs(a, attr) then
|
||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user