aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/extmark_spec.lua5
-rw-r--r--test/functional/api/server_notifications_spec.lua8
-rw-r--r--test/functional/api/server_requests_spec.lua5
-rw-r--r--test/functional/api/vim_spec.lua58
-rw-r--r--test/functional/core/exit_spec.lua3
-rw-r--r--test/functional/core/job_spec.lua3
-rw-r--r--test/functional/core/startup_spec.lua5
-rw-r--r--test/functional/eval/modeline_spec.lua4
-rw-r--r--test/functional/eval/null_spec.lua6
-rw-r--r--test/functional/eval/system_spec.lua7
-rw-r--r--test/functional/ex_cmds/dict_notifications_spec.lua5
-rw-r--r--test/functional/ex_cmds/swapfile_preserve_recover_spec.lua3
-rw-r--r--test/functional/insert/ctrl_o_spec.lua3
-rw-r--r--test/functional/legacy/assert_spec.lua65
-rw-r--r--test/functional/legacy/eval_spec.lua3
-rw-r--r--test/functional/lua/buffer_updates_spec.lua16
-rw-r--r--test/functional/lua/highlight_spec.lua25
-rw-r--r--test/functional/lua/luaeval_spec.lua22
-rw-r--r--test/functional/lua/vim_spec.lua19
-rw-r--r--test/functional/options/defaults_spec.lua28
-rw-r--r--test/functional/options/tabstop_spec.lua5
-rw-r--r--test/functional/plugin/lsp_spec.lua78
-rw-r--r--test/functional/provider/clipboard_spec.lua2
-rw-r--r--test/functional/provider/python3_spec.lua3
-rw-r--r--test/functional/provider/ruby_spec.lua4
-rw-r--r--test/functional/shada/history_spec.lua4
-rw-r--r--test/functional/terminal/buffer_spec.lua23
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua3
-rw-r--r--test/functional/terminal/tui_spec.lua4
-rw-r--r--test/functional/terminal/window_split_tab_spec.lua3
-rw-r--r--test/functional/ui/cursor_spec.lua4
-rw-r--r--test/functional/ui/float_spec.lua2
-rw-r--r--test/functional/ui/highlight_spec.lua69
-rw-r--r--test/functional/ui/output_spec.lua6
-rw-r--r--test/functional/ui/popupmenu_spec.lua4
-rw-r--r--test/functional/viml/completion_spec.lua3
36 files changed, 436 insertions, 74 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index d2b555ee5b..50b4b85d2a 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -12,6 +12,7 @@ local feed = helpers.feed
local clear = helpers.clear
local command = helpers.command
local meths = helpers.meths
+local assert_alive = helpers.assert_alive
local function expect(contents)
return eq(contents, helpers.curbuf_contents())
@@ -1381,13 +1382,13 @@ describe('API/extmarks', function()
end)
it('does not crash with append/delete/undo seqence', function()
- meths.exec([[
+ meths.exec([[
let ns = nvim_create_namespace('myplugin')
call nvim_buf_set_extmark(0, ns, 0, 0, {})
call append(0, '')
%delete
undo]],false)
- eq(2, meths.eval('1+1')) -- did not crash
+ assert_alive()
end)
it('works with left and right gravity', function()
diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua
index e989034925..279ede81f7 100644
--- a/test/functional/api/server_notifications_spec.lua
+++ b/test/functional/api/server_notifications_spec.lua
@@ -6,6 +6,7 @@ local meths = helpers.meths
local exec_lua = helpers.exec_lua
local retry = helpers.retry
local isCI = helpers.isCI
+local assert_alive = helpers.assert_alive
describe('notify', function()
local channel
@@ -73,7 +74,7 @@ describe('notify', function()
nvim('subscribe', 'event1')
nvim('unsubscribe', 'doesnotexist')
nvim('unsubscribe', 'event1')
- eq(2, eval('1+1')) -- Still alive?
+ assert_alive()
end)
it('cancels stale events on channel close', function()
@@ -83,12 +84,13 @@ describe('notify', function()
end
if helpers.pending_win32(pending) then return end
local catchan = eval("jobstart(['cat'], {'rpc': v:true})")
- eq({id=catchan, stream='job', mode='rpc', client = {}}, exec_lua ([[
+ local catpath = eval('exepath("cat")')
+ eq({id=catchan, argv={catpath}, stream='job', mode='rpc', client = {}}, exec_lua ([[
vim.rpcnotify(..., "nvim_call_function", 'chanclose', {..., 'rpc'})
vim.rpcnotify(..., "nvim_subscribe", "daily_rant")
return vim.api.nvim_get_chan_info(...)
]], catchan))
- eq(2, eval('1+1')) -- Still alive?
+ assert_alive()
eq({false, 'Invalid channel: '..catchan},
exec_lua ([[ return {pcall(vim.rpcrequest, ..., 'nvim_eval', '1+1')}]], catchan))
retry(nil, 3000, function() eq({}, meths.get_chan_info(catchan)) end) -- cat be dead :(
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index 237a4b01e4..e408890906 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -11,6 +11,7 @@ local meths = helpers.meths
local spawn, merge_args = helpers.spawn, helpers.merge_args
local set_session = helpers.set_session
local pcall_err = helpers.pcall_err
+local assert_alive = helpers.assert_alive
describe('server -> client', function()
local cid
@@ -33,7 +34,7 @@ describe('server -> client', function()
call jobstop(ch1)
]])
- eq(2, eval("1+1")) -- Still alive?
+ assert_alive()
end)
describe('simple call', function()
@@ -158,7 +159,7 @@ describe('server -> client', function()
-- do some busywork, so the first request will return
-- before this one
for _ = 1, 5 do
- eq(2, eval("1+1"))
+ assert_alive()
end
eq(1, eval('rpcnotify('..cid..', "nested_done")'))
return 'done!'
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 91d2745130..9aad8a1319 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1,6 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
+local fmt = string.format
+local assert_alive = helpers.assert_alive
local NIL = helpers.NIL
local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq
local command = helpers.command
@@ -57,7 +59,7 @@ describe('API', function()
eq({'notification', 'nvim_error_event',
{error_types.Exception.id, 'Invalid method: nvim_bogus'}}, next_msg())
-- error didn't close channel.
- eq(2, eval('1+1'))
+ assert_alive()
end)
it('failed async request emits nvim_error_event', function()
@@ -67,7 +69,7 @@ describe('API', function()
{error_types.Exception.id, 'Vim:E492: Not an editor command: bogus'}},
next_msg())
-- error didn't close channel.
- eq(2, eval('1+1'))
+ assert_alive()
end)
it('does not set CA_COMMAND_BUSY #7254', function()
@@ -1326,10 +1328,10 @@ describe('API', function()
end)
end)
- describe('nvim_list_chans and nvim_get_chan_info', function()
+ describe('nvim_list_chans, nvim_get_chan_info', function()
before_each(function()
- command('autocmd ChanOpen * let g:opened_event = copy(v:event)')
- command('autocmd ChanInfo * let g:info_event = copy(v:event)')
+ command('autocmd ChanOpen * let g:opened_event = deepcopy(v:event)')
+ command('autocmd ChanInfo * let g:info_event = deepcopy(v:event)')
end)
local testinfo = {
stream = 'stdio',
@@ -1350,7 +1352,7 @@ describe('API', function()
eq({}, meths.get_chan_info(10))
end)
- it('works for stdio channel', function()
+ it('stream=stdio channel', function()
eq({[1]=testinfo,[2]=stderr}, meths.list_chans())
eq(testinfo, meths.get_chan_info(1))
eq(stderr, meths.get_chan_info(2))
@@ -1377,11 +1379,13 @@ describe('API', function()
eq(info, meths.get_chan_info(1))
end)
- it('works for job channel', function()
+ it('stream=job channel', function()
eq(3, eval("jobstart(['cat'], {'rpc': v:true})"))
+ local catpath = eval('exepath("cat")')
local info = {
stream='job',
id=3,
+ argv={ catpath },
mode='rpc',
client={},
}
@@ -1394,6 +1398,7 @@ describe('API', function()
info = {
stream='job',
id=3,
+ argv={ catpath },
mode='rpc',
client = {
name='amazing-cat',
@@ -1410,14 +1415,15 @@ describe('API', function()
pcall_err(eval, 'rpcrequest(3, "nvim_set_current_buf", -1)'))
end)
- it('works for :terminal channel', function()
- command(":terminal")
+ it('stream=job :terminal channel', function()
+ command(':terminal')
eq({id=1}, meths.get_current_buf())
- eq(3, meths.buf_get_option(1, "channel"))
+ eq(3, meths.buf_get_option(1, 'channel'))
local info = {
stream='job',
id=3,
+ argv={ eval('exepath(&shell)') },
mode='terminal',
buffer = 1,
pty='?',
@@ -1431,6 +1437,38 @@ describe('API', function()
info.buffer = {id=1}
eq({[1]=testinfo,[2]=stderr,[3]=info}, meths.list_chans())
eq(info, meths.get_chan_info(3))
+
+ -- :terminal with args + running process.
+ command(':exe "terminal" shellescape(v:progpath) "-u NONE -i NONE"')
+ eq(-1, eval('jobwait([&channel], 0)[0]')) -- Running?
+ local expected2 = {
+ stream = 'job',
+ id = 4,
+ argv = (
+ iswin() and {
+ eval('&shell'),
+ '/s',
+ '/c',
+ fmt('"%s -u NONE -i NONE"', eval('shellescape(v:progpath)')),
+ } or {
+ eval('&shell'),
+ eval('&shellcmdflag'),
+ fmt('%s -u NONE -i NONE', eval('shellescape(v:progpath)')),
+ }
+ ),
+ mode = 'terminal',
+ buffer = 2,
+ pty = '?',
+ }
+ local actual2 = eval('nvim_get_chan_info(&channel)')
+ expected2.pty = actual2.pty
+ eq(expected2, actual2)
+
+ -- :terminal with args + stopped process.
+ eq(1, eval('jobstop(&channel)'))
+ eval('jobwait([&channel], 1000)') -- Wait.
+ expected2.pty = (iswin() and '?' or '') -- pty stream was closed.
+ eq(expected2, eval('nvim_get_chan_info(&channel)'))
end)
end)
diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua
index 230b7f8e01..5e569a01d6 100644
--- a/test/functional/core/exit_spec.lua
+++ b/test/functional/core/exit_spec.lua
@@ -1,5 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_alive = helpers.assert_alive
local command = helpers.command
local feed_command = helpers.feed_command
local eval = helpers.eval
@@ -53,7 +54,7 @@ describe(':cquit', function()
if redir_msg then
eq('\n' .. redir_msg, redir_exec(cmdline))
poke_eventloop()
- eq(2, eval("1+1")) -- Still alive?
+ assert_alive()
else
funcs.system({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', '--cmd', cmdline})
eq(exit_code, eval('v:shell_error'))
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index c4745e636f..5e127bce26 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -5,6 +5,7 @@ local clear, eq, eval, exc_exec, feed_command, feed, insert, neq, next_msg, nvim
helpers.insert, helpers.neq, helpers.next_msg, helpers.nvim,
helpers.nvim_dir, helpers.ok, helpers.source,
helpers.write_file, helpers.mkdir, helpers.rmdir
+local assert_alive = helpers.assert_alive
local command = helpers.command
local funcs = helpers.funcs
local os_kill = helpers.os_kill
@@ -870,7 +871,7 @@ describe('jobs', function()
-- loop tick. This is also prevented by try-block, so feed must be used.
feed_command("call DoIt()")
feed('<cr>') -- press RETURN
- eq(2,eval('1+1'))
+ assert_alive()
end)
it('jobstop() kills entire process tree #6530', function()
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index 997e600671..7cddc72561 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
+local assert_alive = helpers.assert_alive
local clear = helpers.clear
local command = helpers.command
local ok = helpers.ok
@@ -231,7 +232,7 @@ describe('startup', function()
it('does not crash if --embed is given twice', function()
clear{args={'--embed'}}
- eq(2, eval('1+1'))
+ assert_alive()
end)
it('does not crash when expanding cdpath during early_init', function()
@@ -247,9 +248,9 @@ describe('startup', function()
[[" -u NONE -i NONE --cmd "set noruler" --cmd "let g:foo = g:bar"')]])
screen:expect([[
^ |
+ |
Error detected while processing pre-vimrc command line: |
E121: Undefined variable: g:bar |
- E15: Invalid expression: g:bar |
Press ENTER or type command to continue |
|
]])
diff --git a/test/functional/eval/modeline_spec.lua b/test/functional/eval/modeline_spec.lua
index c5bb798f4a..b2346079a1 100644
--- a/test/functional/eval/modeline_spec.lua
+++ b/test/functional/eval/modeline_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_alive = helpers.assert_alive
local clear, command, write_file = helpers.clear, helpers.command, helpers.write_file
-local eq, eval = helpers.eq, helpers.eval
describe("modeline", function()
local tempfile = helpers.tmpname()
@@ -14,6 +14,6 @@ describe("modeline", function()
write_file(tempfile, 'vim100000000000000000000000')
command('e! ' .. tempfile)
- eq(2, eval('1+1')) -- Still alive?
+ assert_alive()
end)
end)
diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua
index b1ceff9115..f866aca3ed 100644
--- a/test/functional/eval/null_spec.lua
+++ b/test/functional/eval/null_spec.lua
@@ -53,7 +53,7 @@ describe('NULL', function()
-- Correct behaviour
null_expr_test('can be indexed with error message for empty list', 'L[0]',
- 'E684: list index out of range: 0\nE15: Invalid expression: L[0]', nil)
+ 'E684: list index out of range: 0', nil)
null_expr_test('can be splice-indexed', 'L[:]', 0, {})
null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0)
null_test('is accepted by :for', 'for x in L|throw x|endfor', 0)
@@ -68,7 +68,7 @@ describe('NULL', function()
null_expr_test('can be copied', 'copy(L)', 0, {})
null_expr_test('can be deepcopied', 'deepcopy(L)', 0, {})
null_expr_test('does not crash when indexed', 'L[1]',
- 'E684: list index out of range: 1\nE15: Invalid expression: L[1]', nil)
+ 'E684: list index out of range: 1', nil)
null_expr_test('does not crash call()', 'call("arglistid", L)', 0, 0)
null_expr_test('does not crash col()', 'col(L)', 0, 0)
null_expr_test('does not crash virtcol()', 'virtcol(L)', 0, 0)
@@ -135,7 +135,7 @@ describe('NULL', function()
end)
describe('dict', function()
it('does not crash when indexing NULL dict', function()
- eq('\nE716: Key not present in Dictionary: "test"\nE15: Invalid expression: v:_null_dict.test',
+ eq('\nE716: Key not present in Dictionary: "test"',
redir_exec('echo v:_null_dict.test'))
end)
null_expr_test('makes extend error out', 'extend(D, {})', 'E742: Cannot change value of extend() argument', 0)
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua
index c374baf695..24a1f05390 100644
--- a/test/functional/eval/system_spec.lua
+++ b/test/functional/eval/system_spec.lua
@@ -1,5 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_alive = helpers.assert_alive
local nvim_dir = helpers.nvim_dir
local eq, call, clear, eval, feed_command, feed, nvim =
helpers.eq, helpers.call, helpers.clear, helpers.eval, helpers.feed_command,
@@ -302,7 +303,7 @@ describe('system()', function()
if v_errnum then
eq("E5677:", v_errnum)
end
- eq(2, eval("1+1")) -- Still alive?
+ assert_alive()
end)
end)
@@ -317,11 +318,11 @@ describe('system()', function()
if v_errnum then
eq("E5677:", v_errnum)
end
- eq(2, eval("1+1")) -- Still alive?
+ assert_alive()
end)
it('works with an empty string', function()
eq("test\n", eval('system("echo test", "")'))
- eq(2, eval("1+1")) -- Still alive?
+ assert_alive()
end)
end)
diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua
index e5c9a20db3..21adcf37da 100644
--- a/test/functional/ex_cmds/dict_notifications_spec.lua
+++ b/test/functional/ex_cmds/dict_notifications_spec.lua
@@ -1,4 +1,5 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_alive = helpers.assert_alive
local clear, nvim, source = helpers.clear, helpers.nvim, helpers.source
local insert = helpers.insert
local eq, next_msg = helpers.eq, helpers.next_msg
@@ -325,7 +326,7 @@ describe('VimL dictionary notifications', function()
]])
command('call MakeWatch()')
- eq(2, eval('1+1')) -- Still alive?
+ assert_alive()
end)
end)
@@ -354,7 +355,7 @@ describe('VimL dictionary notifications', function()
command([[call dictwatcherdel(b:, 'changedtick', 'OnTickChanged')]])
insert('t');
- eq(2, eval('1+1')) -- Still alive?
+ assert_alive()
end)
it('does not cause use-after-free when unletting from callback', function()
diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
index f2a381869e..d91feb4bc1 100644
--- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
+++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
@@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
local lfs = require('lfs')
local eq, eval, expect, source =
helpers.eq, helpers.eval, helpers.expect, helpers.source
+local assert_alive = helpers.assert_alive
local clear = helpers.clear
local command = helpers.command
local feed = helpers.feed
@@ -26,7 +27,7 @@ describe(':recover', function()
-- Also check filename ending with ".swp". #9504
eq('Vim(recover):E306: Cannot open '..swapname2,
pcall_err(command, 'recover '..swapname2)) -- Should not segfault. #2117
- eq(2, eval('1+1')) -- Still alive?
+ assert_alive()
end)
end)
diff --git a/test/functional/insert/ctrl_o_spec.lua b/test/functional/insert/ctrl_o_spec.lua
index 543d0a7d68..950ab24219 100644
--- a/test/functional/insert/ctrl_o_spec.lua
+++ b/test/functional/insert/ctrl_o_spec.lua
@@ -1,4 +1,5 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_alive = helpers.assert_alive
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
@@ -45,7 +46,7 @@ describe('insert-mode Ctrl-O', function()
it("doesn't cancel Ctrl-O mode when processing event", function()
feed('iHello World<c-o>')
eq({mode='niI', blocking=false}, meths.get_mode()) -- fast event
- eq(2, eval('1+1')) -- causes K_EVENT key
+ assert_alive() -- causes K_EVENT key
eq({mode='niI', blocking=false}, meths.get_mode()) -- still in ctrl-o mode
feed('dd')
eq({mode='i', blocking=false}, meths.get_mode()) -- left ctrl-o mode
diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua
index 515d6d91b8..c2b22472bf 100644
--- a/test/functional/legacy/assert_spec.lua
+++ b/test/functional/legacy/assert_spec.lua
@@ -26,6 +26,14 @@ describe('assert function:', function()
call('assert_beeps', 'normal 0')
expected_errors({'command did not beep: normal 0'})
end)
+
+ it('can be used as a method', function()
+ local tmpname = source [[
+ call assert_equal(0, 'normal h'->assert_beeps())
+ call assert_equal(1, 'normal 0'->assert_beeps())
+ ]]
+ expected_errors({tmpname .. ' line 2: command did not beep: normal 0'})
+ end)
end)
-- assert_equal({expected}, {actual}, [, {msg}])
@@ -133,6 +141,14 @@ describe('assert function:', function()
call('assert_false', {})
expected_errors({'Expected False but got []'})
end)
+
+ it('can be used as a method', function()
+ local tmpname = source [[
+ call assert_equal(0, v:false->assert_false())
+ call assert_equal(1, 123->assert_false())
+ ]]
+ expected_errors({tmpname .. ' line 2: Expected False but got 123'})
+ end)
end)
-- assert_true({actual}, [, {msg}])
@@ -148,6 +164,14 @@ describe('assert function:', function()
eq(1, call('assert_true', 1.5))
expected_errors({'Expected True but got 1.5'})
end)
+
+ it('can be used as a method', function()
+ local tmpname = source [[
+ call assert_equal(0, v:true->assert_true())
+ call assert_equal(1, 0->assert_true())
+ ]]
+ expected_errors({tmpname .. ' line 2: Expected True but got 0'})
+ end)
end)
describe('v:errors', function()
@@ -223,6 +247,15 @@ describe('assert function:', function()
call('assert_match', 'bar.*foo', 'foobar', 'wrong')
expected_errors({"wrong: Pattern 'bar.*foo' does not match 'foobar'"})
end)
+
+ it('can be used as a method', function()
+ local tmpname = source [[
+ call assert_equal(1, 'foobar'->assert_match('bar.*foo', 'wrong'))
+ ]]
+ expected_errors({
+ tmpname .. " line 1: wrong: Pattern 'bar.*foo' does not match 'foobar'"
+ })
+ end)
end)
-- assert_notmatch({pat}, {text}[, {msg}])
@@ -237,6 +270,13 @@ describe('assert function:', function()
call('assert_notmatch', 'foo', 'foobar')
expected_errors({"Pattern 'foo' does match 'foobar'"})
end)
+
+ it('can be used as a method', function()
+ local tmpname = source [[
+ call assert_equal(1, 'foobar'->assert_notmatch('foo'))
+ ]]
+ expected_errors({tmpname .. " line 1: Pattern 'foo' does match 'foobar'"})
+ end)
end)
-- assert_fails({cmd}, [, {error}])
@@ -267,6 +307,15 @@ describe('assert function:', function()
eq(1, eval([[assert_fails('echo', '', 'echo command')]]))
expected_errors({'command did not fail: echo command'})
end)
+
+ it('can be used as a method', function()
+ local tmpname = source [[
+ call assert_equal(1, 'echo'->assert_fails('', 'echo command'))
+ ]]
+ expected_errors({
+ tmpname .. ' line 1: command did not fail: echo command'
+ })
+ end)
end)
-- assert_inrange({lower}, {upper}, {actual}[, {msg}])
@@ -292,6 +341,15 @@ describe('assert function:', function()
eq('Vim(call):E119: Not enough arguments for function: assert_inrange',
exc_exec("call assert_inrange(1, 1)"))
end)
+
+ it('can be used as a method', function()
+ local tmpname = source [[
+ call assert_equal(0, 5->assert_inrange(5, 7))
+ call assert_equal(0, 7->assert_inrange(5, 7))
+ call assert_equal(1, 8->assert_inrange(5, 7))
+ ]]
+ expected_errors({tmpname .. ' line 3: Expected range 5 - 7, but got 8'})
+ end)
end)
-- assert_report({msg})
@@ -302,6 +360,13 @@ describe('assert function:', function()
command('call remove(v:errors, 0)')
expected_empty()
end)
+
+ it('can be used as a method', function()
+ local tmpname = source [[
+ call assert_equal(1, 'also wrong'->assert_report())
+ ]]
+ expected_errors({tmpname .. ' line 1: also wrong'})
+ end)
end)
-- assert_exception({cmd}, [, {error}])
diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua
index ee9bd29fc4..3b407ce5f5 100644
--- a/test/functional/legacy/eval_spec.lua
+++ b/test/functional/legacy/eval_spec.lua
@@ -1,6 +1,7 @@
-- Test for various eval features.
local helpers = require('test.functional.helpers')(after_each)
+local assert_alive = helpers.assert_alive
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, command, expect = helpers.clear, helpers.command, helpers.expect
local eq, eval, write_file = helpers.eq, helpers.eval, helpers.write_file
@@ -506,7 +507,7 @@ describe('eval', function()
command("call setreg('0',x)")
-- nvim didn't crash and "0 was emptied
- eq(2, eval("1+1"))
+ assert_alive()
eq({}, eval("getreg('0',1,1)"))
-- x is a mutable list
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index a5b613f0b2..073927bf22 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -978,6 +978,22 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
end)
+ it("visual paste", function()
+ local check_events= setup_eventcheck(verify, { "aaa {", "b", "}" })
+ -- Setting up
+ feed[[jdd]]
+ check_events {
+ { "test1", "bytes", 1, 3, 1, 0, 6, 1, 0, 2, 0, 0, 0 };
+ }
+
+ -- Actually testing
+ feed[[v%p]]
+ check_events {
+ { "test1", "bytes", 1, 8, 0, 4, 4, 1, 1, 3, 0, 0, 0 };
+ { "test1", "bytes", 1, 8, 0, 4, 4, 0, 0, 0, 2, 0, 3 };
+ }
+ end)
+
it("nvim_buf_set_lines", function()
local check_events = setup_eventcheck(verify, {"AAA", "BBB"})
diff --git a/test/functional/lua/highlight_spec.lua b/test/functional/lua/highlight_spec.lua
new file mode 100644
index 0000000000..50eecb5d09
--- /dev/null
+++ b/test/functional/lua/highlight_spec.lua
@@ -0,0 +1,25 @@
+local helpers = require('test.functional.helpers')(after_each)
+local exec_lua = helpers.exec_lua
+local eq = helpers.eq
+local eval = helpers.eval
+local command = helpers.command
+local clear = helpers.clear
+
+describe('vim.highlight.on_yank', function()
+
+ before_each(function()
+ clear()
+ end)
+
+ it('does not show errors even if buffer is wiped before timeout', function()
+ command('new')
+ exec_lua[[
+ vim.highlight.on_yank({timeout = 10, on_macro = true, event = {operator = "y", regtype = "v"}})
+ vim.cmd('bwipeout!')
+ ]]
+ helpers.sleep(10)
+ helpers.feed('<cr>') -- avoid hang if error message exists
+ eq('', eval('v:errmsg'))
+ end)
+
+end)
diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua
index 2ec48777fd..8ef77faa0f 100644
--- a/test/functional/lua/luaeval_spec.lua
+++ b/test/functional/lua/luaeval_spec.lua
@@ -481,6 +481,21 @@ describe('v:lua', function()
pcall_err(eval, 'v:lua.mymod.crashy()'))
end)
+ it('works when called as a method', function()
+ eq(123, eval('110->v:lua.foo(13)'))
+ eq(true, exec_lua([[return _G.val == nil]]))
+
+ eq(321, eval('300->v:lua.foo(21, "boop")'))
+ eq("boop", exec_lua([[return _G.val]]))
+
+ eq(NIL, eval('"there"->v:lua.mymod.noisy()'))
+ eq("hey there", meths.get_current_line())
+ eq({5, 10, 15, 20}, eval('[[1], [2, 3], [4]]->v:lua.vim.tbl_flatten()->map({_, v -> v * 5})'))
+
+ eq("Vim:E5108: Error executing lua [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)",
+ pcall_err(eval, '"huh?"->v:lua.mymod.crashy()'))
+ end)
+
it('works in :call', function()
command(":call v:lua.mymod.noisy('command')")
eq("hey command", meths.get_current_line())
@@ -518,8 +533,15 @@ describe('v:lua', function()
eq("Vim:E15: Invalid expression: v:['lua'].foo()", pcall_err(eval, "v:['lua'].foo()"))
eq("Vim(call):E461: Illegal variable name: v:['lua']", pcall_err(command, "call v:['lua'].baar()"))
+ eq("Vim:E117: Unknown function: v:lua", pcall_err(eval, "v:lua()"))
eq("Vim(let):E46: Cannot change read-only variable \"v:['lua']\"", pcall_err(command, "let v:['lua'] = 'xx'"))
eq("Vim(let):E46: Cannot change read-only variable \"v:lua\"", pcall_err(command, "let v:lua = 'xx'"))
+
+ eq("Vim:E107: Missing parentheses: v:lua.func", pcall_err(eval, "'bad'->v:lua.func"))
+ eq("Vim:E274: No white space allowed before parenthesis", pcall_err(eval, "'bad'->v:lua.func ()"))
+ eq("Vim:E107: Missing parentheses: v:lua", pcall_err(eval, "'bad'->v:lua"))
+ eq("Vim:E117: Unknown function: v:lua", pcall_err(eval, "'bad'->v:lua()"))
+ eq("Vim:E15: Invalid expression: v:lua.()", pcall_err(eval, "'bad'->v:lua.()"))
end)
end)
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 4e2bed4deb..0ea914880f 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -17,6 +17,7 @@ local matches = helpers.matches
local source = helpers.source
local NIL = helpers.NIL
local retry = helpers.retry
+local next_msg = helpers.next_msg
before_each(clear)
@@ -2178,6 +2179,24 @@ describe('lua stdlib', function()
end)
end)
+ describe('vim.schedule_wrap', function()
+ it('preserves argument lists', function()
+ exec_lua [[
+ local fun = vim.schedule_wrap(function(kling, klang, klonk)
+ vim.rpcnotify(1, 'mayday_mayday', {a=kling, b=klang, c=klonk})
+ end)
+ fun("BOB", nil, "MIKE")
+ ]]
+ eq({'notification', 'mayday_mayday', {{a='BOB', c='MIKE'}}}, next_msg())
+
+ -- let's gooooo
+ exec_lua [[
+ vim.schedule_wrap(function(...) vim.rpcnotify(1, 'boogalo', select('#', ...)) end)(nil,nil,nil,nil)
+ ]]
+ eq({'notification', 'boogalo', {4}}, next_msg())
+ end)
+ end)
+
describe('vim.api.nvim_buf_call', function()
it('can access buf options', function()
local buf1 = meths.get_current_buf()
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index eb5e284385..6620c9acef 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
+local assert_alive = helpers.assert_alive
local meths = helpers.meths
local command = helpers.command
local clear = helpers.clear
@@ -354,13 +355,13 @@ describe('XDG-based defaults', function()
.. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim/after'
.. ',' .. root_path .. ('/x'):rep(4096) .. '/nvim/after'
):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
- eq('.,' .. root_path .. ('/X'):rep(4096).. '/' .. data_dir .. '/backup',
+ eq('.,' .. root_path .. ('/X'):rep(4096).. '/' .. data_dir .. '/backup//',
(meths.get_option('backupdir'):gsub('\\', '/')))
eq(root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/swap//',
(meths.get_option('directory')):gsub('\\', '/'))
- eq(root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/undo',
+ eq(root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/undo//',
(meths.get_option('undodir')):gsub('\\', '/'))
- eq(root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/view',
+ eq(root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/view//',
(meths.get_option('viewdir')):gsub('\\', '/'))
end)
end)
@@ -404,13 +405,13 @@ describe('XDG-based defaults', function()
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
- eq(('.,$XDG_CONFIG_HOME/' .. data_dir .. '/backup'),
+ eq(('.,$XDG_CONFIG_HOME/' .. data_dir .. '/backup//'),
meths.get_option('backupdir'):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/swap//'),
meths.get_option('directory'):gsub('\\', '/'))
- eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/undo'),
+ eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/undo//'),
meths.get_option('undodir'):gsub('\\', '/'))
- eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/view'),
+ eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/view//'),
meths.get_option('viewdir'):gsub('\\', '/'))
meths.command('set all&')
eq(('$XDG_DATA_HOME/nvim'
@@ -424,13 +425,13 @@ describe('XDG-based defaults', function()
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/'), (meths.get_option('runtimepath')):gsub('\\', '/'))
- eq(('.,$XDG_CONFIG_HOME/' .. data_dir .. '/backup'),
+ eq(('.,$XDG_CONFIG_HOME/' .. data_dir .. '/backup//'),
meths.get_option('backupdir'):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/swap//'),
meths.get_option('directory'):gsub('\\', '/'))
- eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/undo'),
+ eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/undo//'),
meths.get_option('undodir'):gsub('\\', '/'))
- eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/view'),
+ eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/view//'),
meths.get_option('viewdir'):gsub('\\', '/'))
end)
end)
@@ -483,13 +484,13 @@ describe('XDG-based defaults', function()
.. ',\\,-\\,-\\,' .. path_sep ..'nvim' .. path_sep ..'after'
.. ',\\, \\, \\,' .. path_sep ..'nvim' .. path_sep ..'after'
), meths.get_option('runtimepath'))
- eq('.,\\,=\\,=\\,' .. path_sep .. data_dir .. '' .. path_sep ..'backup',
+ eq('.,\\,=\\,=\\,' .. path_sep .. data_dir .. '' .. path_sep ..'backup' .. (path_sep):rep(2),
meths.get_option('backupdir'))
eq('\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'swap' .. (path_sep):rep(2),
meths.get_option('directory'))
- eq('\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'undo',
+ eq('\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'undo' .. (path_sep):rep(2),
meths.get_option('undodir'))
- eq('\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'view',
+ eq('\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'view' .. (path_sep):rep(2),
meths.get_option('viewdir'))
end)
end)
@@ -510,8 +511,7 @@ describe('stdpath()', function()
eq(datadir, funcs.fnamemodify(funcs.stdpath('data'), ':t'))
eq('table', type(funcs.stdpath('config_dirs')))
eq('table', type(funcs.stdpath('data_dirs')))
- -- Check for crash. #8393
- eq(2, eval('1+1'))
+ assert_alive() -- Check for crash. #8393
end)
context('returns a String', function()
diff --git a/test/functional/options/tabstop_spec.lua b/test/functional/options/tabstop_spec.lua
index dc3ba38438..e34f678650 100644
--- a/test/functional/options/tabstop_spec.lua
+++ b/test/functional/options/tabstop_spec.lua
@@ -1,9 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_alive = helpers.assert_alive
local clear = helpers.clear
local feed = helpers.feed
-local eq = helpers.eq
-local eval = helpers.eval
describe("'tabstop' option", function()
before_each(function()
@@ -18,6 +17,6 @@ describe("'tabstop' option", function()
-- Set 'tabstop' to a very high value.
-- Use feed(), not command(), to provoke crash.
feed(':set tabstop=3000000000<CR>')
- eq(2, eval("1+1")) -- Still alive?
+ assert_alive()
end)
end)
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index aa2d8db206..16fe75d359 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -6,6 +6,7 @@ local buf_lines = helpers.buf_lines
local dedent = helpers.dedent
local exec_lua = helpers.exec_lua
local eq = helpers.eq
+local matches = helpers.matches
local pcall_err = helpers.pcall_err
local pesc = helpers.pesc
local insert = helpers.insert
@@ -1939,6 +1940,83 @@ describe('LSP', function()
end)
end)
+ describe('lsp.util.make_floating_popup_options', function()
+ before_each(function()
+ exec_lua [[
+ local bufnr = vim.uri_to_bufnr("file:///fake/uri")
+ local winheight = vim.fn.winheight(0)
+ for i = 1, winheight do
+ vim.api.nvim_buf_set_lines(bufnr, 0, 0, false, {''})
+ end
+ vim.api.nvim_win_set_buf(0, bufnr)
+ vim.api.nvim_win_set_cursor(0, {winheight, 0})
+ ]]
+ end)
+
+ local function popup_row(opts)
+ return exec_lua([[
+ return vim.lsp.util.make_floating_popup_options(...).row
+ ]], 2, 2, opts)
+ end
+
+ local err_pattern = "^Error executing lua: %.%.%./util%.lua:0: invalid floating preview border: .*%. :help vim%.api%.nvim_open_win%(%)$"
+
+ it('calculates default border height correctly', function()
+ eq(0, popup_row())
+ end)
+
+ it('calculates string border height correctly', function()
+ eq(0, popup_row({border = 'none'}))
+ eq(-2, popup_row({border = 'single'}))
+ eq(-2, popup_row({border = 'double'}))
+ eq(-2, popup_row({border = 'rounded'}))
+ eq(-2, popup_row({border = 'solid'}))
+ eq(-1, popup_row({border = 'shadow'}))
+ end)
+
+ it('error on invalid string border', function()
+ matches(err_pattern, pcall_err(popup_row, {border = ''}))
+ matches(err_pattern, pcall_err(popup_row, {border = 'invalid'}))
+ end)
+
+ it('error on invalid array border length', function()
+ matches(err_pattern, pcall_err(popup_row, {border = {}}))
+ matches(err_pattern, pcall_err(popup_row, {border = {'', '', ''}}))
+ matches(err_pattern, pcall_err(popup_row, {border = {'', '', '', '', ''}}))
+ end)
+
+ it('error on invalid array border member type', function()
+ matches(err_pattern, pcall_err(popup_row, {border = {0}}))
+ end)
+
+ it('calculates 8-array border height correctly', function()
+ eq(0, popup_row({border = {'', '', '', '', '', '', '', ''}}))
+ eq(-2, popup_row({border = {'', '~', '', '~', '', '~', '', '~'}}))
+ eq(-1, popup_row({border = {'', '', '', '~', '', '~', '', ''}}))
+ eq(0, popup_row({border = {'', '', '', {'~', 'NormalFloat'}, '', '', '', {'~', 'NormalFloat'}}}))
+ eq(-2, popup_row({border = {'', {'~', 'NormalFloat'}, '', '', '', {'~', 'NormalFloat'}, '', ''}}))
+ end)
+
+ it('calculates 4-array border height correctly', function()
+ eq(0, popup_row({border = {'', '', '', ''}}))
+ eq(-2, popup_row({border = {'', '~', '', '~'}}))
+ eq(0, popup_row({border = {'', '', '', {'~', 'NormalFloat'}}}))
+ eq(-2, popup_row({border = {'', {'~', 'NormalFloat'}, '', ''}}))
+ end)
+
+ it('calculates 2-array border height correctly', function()
+ eq(0, popup_row({border = {'', ''}}))
+ eq(-2, popup_row({border = {'', '~'}}))
+ eq(-2, popup_row({border = {'', {'~', 'NormalFloat'}}}))
+ end)
+
+ it('calculates 1-array border height correctly', function()
+ eq(0, popup_row({border = {''}}))
+ eq(-2, popup_row({border = {'~'}}))
+ eq(-2, popup_row({border = {{'~', 'NormalFloat'}}}))
+ end)
+ end)
+
describe('lsp.util._make_floating_popup_size', function()
before_each(function()
exec_lua [[ contents =
diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua
index e5e21f11a6..986db96a18 100644
--- a/test/functional/provider/clipboard_spec.lua
+++ b/test/functional/provider/clipboard_spec.lua
@@ -653,14 +653,12 @@ describe('clipboard (with fake clipboard.vim)', function()
'',
'',
'E121: Undefined variable: doesnotexist',
- 'E15: Invalid expression: doesnotexist',
}, 'v'}, eval("g:test_clip['*']"))
feed_command(':echo "Howdy!"')
eq({{
'',
'',
'E121: Undefined variable: doesnotexist',
- 'E15: Invalid expression: doesnotexist',
'',
'Howdy!',
}, 'v'}, eval("g:test_clip['*']"))
diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua
index d254edc7d5..d100db8de2 100644
--- a/test/functional/provider/python3_spec.lua
+++ b/test/functional/provider/python3_spec.lua
@@ -1,4 +1,5 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_alive = helpers.assert_alive
local eval, command, feed = helpers.eval, helpers.command, helpers.feed
local eq, clear, insert = helpers.eq, helpers.clear, helpers.insert
local expect, write_file = helpers.expect, helpers.write_file
@@ -116,6 +117,6 @@ describe('python3 provider', function()
feed_command("exe 'split' tempname()")
feed_command("bwipeout!")
feed_command('help help')
- eq(2, eval('1+1')) -- Still alive?
+ assert_alive()
end)
end)
diff --git a/test/functional/provider/ruby_spec.lua b/test/functional/provider/ruby_spec.lua
index 2729d8dfa2..fba96100fc 100644
--- a/test/functional/provider/ruby_spec.lua
+++ b/test/functional/provider/ruby_spec.lua
@@ -1,10 +1,10 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_alive = helpers.assert_alive
local clear = helpers.clear
local command = helpers.command
local curbufmeths = helpers.curbufmeths
local eq = helpers.eq
-local eval = helpers.eval
local exc_exec = helpers.exc_exec
local expect = helpers.expect
local feed = helpers.feed
@@ -107,7 +107,7 @@ describe('ruby provider', function()
helpers.add_builddir_to_rtp()
command([=[autocmd BufDelete * ruby VIM::evaluate('expand("<afile>")')]=])
feed_command('help help')
- eq(2, eval('1+1')) -- Still alive?
+ assert_alive()
end)
end)
diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua
index 9291f5e100..84cc34c7cc 100644
--- a/test/functional/shada/history_spec.lua
+++ b/test/functional/shada/history_spec.lua
@@ -2,7 +2,7 @@
local helpers = require('test.functional.helpers')(after_each)
local nvim_command, funcs, meths, nvim_feed, eq =
helpers.command, helpers.funcs, helpers.meths, helpers.feed, helpers.eq
-local eval = helpers.eval
+local assert_alive = helpers.assert_alive
local shada_helpers = require('test.functional.shada.helpers')
local reset, clear = shada_helpers.reset, shada_helpers.clear
@@ -244,7 +244,7 @@ describe('ShaDa support code', function()
nvim_command('wshada')
nvim_command('set shada=\'10,:0')
nvim_command('wshada')
- eq(2, eval('1+1')) -- check nvim still running
+ assert_alive()
end)
end)
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index c61bf108cb..103ae59b8e 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -1,5 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
+local assert_alive = helpers.assert_alive
local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
local poke_eventloop = helpers.poke_eventloop
local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.source
@@ -7,6 +8,7 @@ local eq, neq = helpers.eq, helpers.neq
local write_file = helpers.write_file
local command= helpers.command
local exc_exec = helpers.exc_exec
+local matches = helpers.matches
describe(':terminal buffer', function()
local screen
@@ -255,8 +257,23 @@ describe(':terminal buffer', function()
command('bdelete!')
end)
- it('handles wqall', function()
+ it('requires bang (!) to close a running job #15402', function()
eq('Vim(wqall):E948: Job still running', exc_exec('wqall'))
+ for _, cmd in ipairs({ 'bdelete', '%bdelete', 'bwipeout', 'bunload' }) do
+ matches('^Vim%('..cmd:gsub('%%', '')..'%):E89: term://.*tty%-test.* will be killed %(add %! to override%)$',
+ exc_exec(cmd))
+ end
+ command('call jobstop(&channel)')
+ assert(0 >= eval('jobwait([&channel], 1000)[0]'))
+ command('bdelete')
+ end)
+
+ it('stops running jobs with :quit', function()
+ -- Open in a new window to avoid terminating the nvim instance
+ command('split')
+ command('terminal')
+ command('set nohidden')
+ command('quit')
end)
it('does not segfault when pasting empty buffer #13955', function()
@@ -284,7 +301,7 @@ describe('No heap-buffer-overflow when using', function()
feed('$')
-- Let termopen() modify the buffer
feed_command('call termopen("echo")')
- eq(2, eval('1+1')) -- check nvim still running
+ assert_alive()
feed_command('bdelete!')
end)
end)
@@ -294,6 +311,6 @@ describe('No heap-buffer-overflow when', function()
feed_command('set nowrap')
feed_command('autocmd TermOpen * startinsert')
feed_command('call feedkeys("4000ai\\<esc>:terminal!\\<cr>")')
- eq(2, eval('1+1'))
+ assert_alive()
end)
end)
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 4b512605e1..707c355069 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -1,5 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
+local assert_alive = helpers.assert_alive
local clear, poke_eventloop, nvim = helpers.clear, helpers.poke_eventloop, helpers.nvim
local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq
local feed = helpers.feed
@@ -215,7 +216,7 @@ describe(':terminal (with fake shell)', function()
-- handler), :terminal cleanup is pending on the main-loop.
-- This write should be ignored (not crash, #5445).
feed('iiYYYYYYY')
- eq(2, eval("1+1")) -- Still alive?
+ assert_alive()
end)
it('works with findfile()', function()
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 8a5dd7ef18..f7520b14d4 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -8,12 +8,12 @@ local helpers = require('test.functional.helpers')(after_each)
local uname = helpers.uname
local thelpers = require('test.functional.terminal.helpers')
local Screen = require('test.functional.ui.screen')
+local assert_alive = helpers.assert_alive
local eq = helpers.eq
local feed_command = helpers.feed_command
local feed_data = thelpers.feed_data
local clear = helpers.clear
local command = helpers.command
-local eval = helpers.eval
local nvim_dir = helpers.nvim_dir
local retry = helpers.retry
local nvim_prog = helpers.nvim_prog
@@ -82,7 +82,7 @@ describe('TUI', function()
command('call jobresize(b:terminal_job_id, 1, 4)')
screen:try_resize(57, 17)
command('call jobresize(b:terminal_job_id, 57, 17)')
- eq(2, eval("1+1")) -- Still alive?
+ assert_alive()
end)
it('accepts resize while pager is active', function()
diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua
index 03bd336aec..188afa1e84 100644
--- a/test/functional/terminal/window_split_tab_spec.lua
+++ b/test/functional/terminal/window_split_tab_spec.lua
@@ -1,5 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
+local assert_alive = helpers.assert_alive
local clear = helpers.clear
local feed, nvim = helpers.feed, helpers.nvim
local feed_command = helpers.feed_command
@@ -33,7 +34,7 @@ describe(':terminal', function()
command('vsplit foo')
eq(3, eval("winnr('$')"))
feed('ZQ') -- Close split, should not crash. #7538
- eq(2, eval("1+1")) -- Still alive?
+ assert_alive()
end)
it('does not change size on WinEnter', function()
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index f75f700fb5..9c035c728b 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -212,10 +212,10 @@ describe('ui/cursor', function()
if m.blinkwait then m.blinkwait = 700 end
end
if m.hl_id then
- m.hl_id = 56
+ m.hl_id = 58
m.attr = {background = Screen.colors.DarkGray}
end
- if m.id_lm then m.id_lm = 57 end
+ if m.id_lm then m.id_lm = 59 end
end
-- Assert the new expectation.
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index be22d9a403..59ce7c82e2 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -5036,7 +5036,7 @@ describe('float window', function()
]])
end
- eq(2, eval('1+1'))
+ assert_alive()
end)
it("o (:only) non-float", function()
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 499aeba6ec..c00d30fe32 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -1292,6 +1292,75 @@ describe("MsgSeparator highlight and msgsep fillchar", function()
end)
end)
+describe("'number' and 'relativenumber' highlight", function()
+ before_each(clear)
+
+ it('LineNr, LineNrAbove and LineNrBelow', function()
+ local screen = Screen.new(20,10)
+ screen:set_default_attr_ids({
+ [1] = {foreground = Screen.colors.Red},
+ [2] = {foreground = Screen.colors.Blue},
+ [3] = {foreground = Screen.colors.Green},
+ })
+ screen:attach()
+ command('set number relativenumber')
+ command('call setline(1, range(50))')
+ command('highlight LineNr guifg=Red')
+ feed('4j')
+ screen:expect([[
+ {1: 4 }0 |
+ {1: 3 }1 |
+ {1: 2 }2 |
+ {1: 1 }3 |
+ {1:5 }^4 |
+ {1: 1 }5 |
+ {1: 2 }6 |
+ {1: 3 }7 |
+ {1: 4 }8 |
+ |
+ ]])
+ command('highlight LineNrAbove guifg=Blue')
+ screen:expect([[
+ {2: 4 }0 |
+ {2: 3 }1 |
+ {2: 2 }2 |
+ {2: 1 }3 |
+ {1:5 }^4 |
+ {1: 1 }5 |
+ {1: 2 }6 |
+ {1: 3 }7 |
+ {1: 4 }8 |
+ |
+ ]])
+ command('highlight LineNrBelow guifg=Green')
+ screen:expect([[
+ {2: 4 }0 |
+ {2: 3 }1 |
+ {2: 2 }2 |
+ {2: 1 }3 |
+ {1:5 }^4 |
+ {3: 1 }5 |
+ {3: 2 }6 |
+ {3: 3 }7 |
+ {3: 4 }8 |
+ |
+ ]])
+ feed('3j')
+ screen:expect([[
+ {2: 7 }0 |
+ {2: 6 }1 |
+ {2: 5 }2 |
+ {2: 4 }3 |
+ {2: 3 }4 |
+ {2: 2 }5 |
+ {2: 1 }6 |
+ {1:8 }^7 |
+ {3: 1 }8 |
+ |
+ ]])
+ end)
+end)
+
describe("'winhighlight' highlight", function()
local screen
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua
index 3826707743..50e5dfac84 100644
--- a/test/functional/ui/output_spec.lua
+++ b/test/functional/ui/output_spec.lua
@@ -1,9 +1,9 @@
local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')(after_each)
local child_session = require('test.functional.terminal.helpers')
+local assert_alive = helpers.assert_alive
local mkdir, write_file, rmdir = helpers.mkdir, helpers.write_file, helpers.rmdir
local eq = helpers.eq
-local eval = helpers.eval
local feed = helpers.feed
local feed_command = helpers.feed_command
local iswin = helpers.iswin
@@ -86,12 +86,12 @@ describe("shell command :!", function()
it("cat a binary file #4142", function()
feed(":exe 'silent !cat '.shellescape(v:progpath)<CR>")
- eq(2, eval('1+1')) -- Still alive?
+ assert_alive()
end)
it([[display \x08 char #4142]], function()
feed(":silent !echo \08<CR>")
- eq(2, eval('1+1')) -- Still alive?
+ assert_alive()
end)
it('handles control codes', function()
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index 0944bfc21a..aeba049557 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -1,5 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
+local assert_alive = helpers.assert_alive
local clear, feed = helpers.clear, helpers.feed
local source = helpers.source
local insert = helpers.insert
@@ -9,7 +10,6 @@ local funcs = helpers.funcs
local get_pathsep = helpers.get_pathsep
local eq = helpers.eq
local pcall_err = helpers.pcall_err
-local eval = helpers.eval
describe('ui/ext_popupmenu', function()
local screen
@@ -2211,6 +2211,6 @@ describe('builtin popupmenu', function()
feed('$i')
funcs.complete(col - max_len, items)
feed('<c-y>')
- eq(2, eval('1+1'))
+ assert_alive()
end)
end)
diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua
index a4241fe5aa..befad29922 100644
--- a/test/functional/viml/completion_spec.lua
+++ b/test/functional/viml/completion_spec.lua
@@ -1,5 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
+local assert_alive = helpers.assert_alive
local clear, feed = helpers.clear, helpers.feed
local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq
local feed_command, source, expect = helpers.feed_command, helpers.source, helpers.expect
@@ -870,7 +871,7 @@ describe('completion', function()
{3:-- Keyword completion (^N^P) }{4:match 1 of 2} |
]])
- eval('1 + 1')
+ assert_alive()
-- popupmenu still visible
screen:expect{grid=[[
foobar fooegg |