mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
test: rename next_message() to next_msg()
This commit is contained in:
parent
d554a6c7f0
commit
fd4021387e
@ -1,7 +1,7 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local eq, clear, eval, command, nvim, next_message =
|
local eq, clear, eval, command, nvim, next_msg =
|
||||||
helpers.eq, helpers.clear, helpers.eval, helpers.command, helpers.nvim,
|
helpers.eq, helpers.clear, helpers.eval, helpers.command, helpers.nvim,
|
||||||
helpers.next_message
|
helpers.next_msg
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
|
|
||||||
describe('notify', function()
|
describe('notify', function()
|
||||||
@ -15,10 +15,10 @@ describe('notify', function()
|
|||||||
describe('passing a valid channel id', function()
|
describe('passing a valid channel id', function()
|
||||||
it('sends the notification/args to the corresponding channel', function()
|
it('sends the notification/args to the corresponding channel', function()
|
||||||
eval('rpcnotify('..channel..', "test-event", 1, 2, 3)')
|
eval('rpcnotify('..channel..', "test-event", 1, 2, 3)')
|
||||||
eq({'notification', 'test-event', {1, 2, 3}}, next_message())
|
eq({'notification', 'test-event', {1, 2, 3}}, next_msg())
|
||||||
command('au FileType lua call rpcnotify('..channel..', "lua!")')
|
command('au FileType lua call rpcnotify('..channel..', "lua!")')
|
||||||
command('set filetype=lua')
|
command('set filetype=lua')
|
||||||
eq({'notification', 'lua!', {}}, next_message())
|
eq({'notification', 'lua!', {}}, next_msg())
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -28,13 +28,13 @@ describe('notify', function()
|
|||||||
eval('rpcnotify(0, "event1", 1, 2, 3)')
|
eval('rpcnotify(0, "event1", 1, 2, 3)')
|
||||||
eval('rpcnotify(0, "event2", 4, 5, 6)')
|
eval('rpcnotify(0, "event2", 4, 5, 6)')
|
||||||
eval('rpcnotify(0, "event2", 7, 8, 9)')
|
eval('rpcnotify(0, "event2", 7, 8, 9)')
|
||||||
eq({'notification', 'event2', {4, 5, 6}}, next_message())
|
eq({'notification', 'event2', {4, 5, 6}}, next_msg())
|
||||||
eq({'notification', 'event2', {7, 8, 9}}, next_message())
|
eq({'notification', 'event2', {7, 8, 9}}, next_msg())
|
||||||
nvim('unsubscribe', 'event2')
|
nvim('unsubscribe', 'event2')
|
||||||
nvim('subscribe', 'event1')
|
nvim('subscribe', 'event1')
|
||||||
eval('rpcnotify(0, "event2", 10, 11, 12)')
|
eval('rpcnotify(0, "event2", 10, 11, 12)')
|
||||||
eval('rpcnotify(0, "event1", 13, 14, 15)')
|
eval('rpcnotify(0, "event1", 13, 14, 15)')
|
||||||
eq({'notification', 'event1', {13, 14, 15}}, next_message())
|
eq({'notification', 'event1', {13, 14, 15}}, next_msg())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not crash for deeply nested variable', function()
|
it('does not crash for deeply nested variable', function()
|
||||||
@ -42,7 +42,7 @@ describe('notify', function()
|
|||||||
local nest_level = 1000
|
local nest_level = 1000
|
||||||
meths.command(('call map(range(%u), "extend(g:, {\'l\': [g:l]})")'):format(nest_level - 1))
|
meths.command(('call map(range(%u), "extend(g:, {\'l\': [g:l]})")'):format(nest_level - 1))
|
||||||
eval('rpcnotify('..channel..', "event", g:l)')
|
eval('rpcnotify('..channel..', "event", g:l)')
|
||||||
local msg = next_message()
|
local msg = next_msg()
|
||||||
eq('notification', msg[1])
|
eq('notification', msg[1])
|
||||||
eq('event', msg[2])
|
eq('event', msg[2])
|
||||||
local act_ret = msg[3]
|
local act_ret = msg[3]
|
||||||
|
@ -6,7 +6,7 @@ local Paths = require('test.config.paths')
|
|||||||
local clear, nvim, eval = helpers.clear, helpers.nvim, helpers.eval
|
local clear, nvim, eval = helpers.clear, helpers.nvim, helpers.eval
|
||||||
local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop
|
local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop
|
||||||
local nvim_prog, command, funcs = helpers.nvim_prog, helpers.command, helpers.funcs
|
local nvim_prog, command, funcs = helpers.nvim_prog, helpers.command, helpers.funcs
|
||||||
local source, next_message = helpers.source, helpers.next_message
|
local source, next_msg = helpers.source, helpers.next_msg
|
||||||
local ok = helpers.ok
|
local ok = helpers.ok
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
|
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
|
||||||
@ -258,12 +258,12 @@ describe('server -> client', function()
|
|||||||
it('rpc and text stderr can be combined', function()
|
it('rpc and text stderr can be combined', function()
|
||||||
eq("ok",funcs.rpcrequest(jobid, "poll"))
|
eq("ok",funcs.rpcrequest(jobid, "poll"))
|
||||||
funcs.rpcnotify(jobid, "ping")
|
funcs.rpcnotify(jobid, "ping")
|
||||||
eq({'notification', 'pong', {}}, next_message())
|
eq({'notification', 'pong', {}}, next_msg())
|
||||||
eq("done!",funcs.rpcrequest(jobid, "write_stderr", "fluff\n"))
|
eq("done!",funcs.rpcrequest(jobid, "write_stderr", "fluff\n"))
|
||||||
eq({'notification', 'stderr', {0, {'fluff', ''}}}, next_message())
|
eq({'notification', 'stderr', {0, {'fluff', ''}}}, next_msg())
|
||||||
funcs.rpcrequest(jobid, "exit")
|
funcs.rpcrequest(jobid, "exit")
|
||||||
eq({'notification', 'stderr', {0, {''}}}, next_message())
|
eq({'notification', 'stderr', {0, {''}}}, next_msg())
|
||||||
eq({'notification', 'exit', {0, 0}}, next_message())
|
eq({'notification', 'exit', {0, 0}}, next_msg())
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ local clear = helpers.clear
|
|||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local expect = helpers.expect
|
local expect = helpers.expect
|
||||||
local next_msg = helpers.next_message
|
local next_msg = helpers.next_msg
|
||||||
local feed = helpers.feed
|
local feed = helpers.feed
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local clear, eq, eval, next_msg, ok, source = helpers.clear, helpers.eq,
|
local clear, eq, eval, next_msg, ok, source = helpers.clear, helpers.eq,
|
||||||
helpers.eval, helpers.next_message, helpers.ok, helpers.source
|
helpers.eval, helpers.next_msg, helpers.ok, helpers.source
|
||||||
local command, funcs, meths = helpers.command, helpers.funcs, helpers.meths
|
local command, funcs, meths = helpers.command, helpers.funcs, helpers.meths
|
||||||
local sleep = helpers.sleep
|
local sleep = helpers.sleep
|
||||||
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
|
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
|
||||||
|
@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
local clear, eq, eval, exc_exec, feed_command, feed, insert, neq, next_msg, nvim,
|
local clear, eq, eval, exc_exec, feed_command, feed, insert, neq, next_msg, nvim,
|
||||||
nvim_dir, ok, source, write_file, mkdir, rmdir = helpers.clear,
|
nvim_dir, ok, source, write_file, mkdir, rmdir = helpers.clear,
|
||||||
helpers.eq, helpers.eval, helpers.exc_exec, helpers.feed_command, helpers.feed,
|
helpers.eq, helpers.eval, helpers.exc_exec, helpers.feed_command, helpers.feed,
|
||||||
helpers.insert, helpers.neq, helpers.next_message, helpers.nvim,
|
helpers.insert, helpers.neq, helpers.next_msg, helpers.nvim,
|
||||||
helpers.nvim_dir, helpers.ok, helpers.source,
|
helpers.nvim_dir, helpers.ok, helpers.source,
|
||||||
helpers.write_file, helpers.mkdir, helpers.rmdir
|
helpers.write_file, helpers.mkdir, helpers.rmdir
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local clear, nvim, source = helpers.clear, helpers.nvim, helpers.source
|
local clear, nvim, source = helpers.clear, helpers.nvim, helpers.source
|
||||||
local eq, next_msg = helpers.eq, helpers.next_message
|
local eq, next_msg = helpers.eq, helpers.next_msg
|
||||||
local exc_exec = helpers.exc_exec
|
local exc_exec = helpers.exc_exec
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
|
@ -97,14 +97,14 @@ local function request(method, ...)
|
|||||||
return rv
|
return rv
|
||||||
end
|
end
|
||||||
|
|
||||||
local function next_message(timeout)
|
local function next_msg(timeout)
|
||||||
return session:next_message(timeout)
|
return session:next_message(timeout)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function expect_twostreams(msgs1, msgs2)
|
local function expect_twostreams(msgs1, msgs2)
|
||||||
local pos1, pos2 = 1, 1
|
local pos1, pos2 = 1, 1
|
||||||
while pos1 <= #msgs1 or pos2 <= #msgs2 do
|
while pos1 <= #msgs1 or pos2 <= #msgs2 do
|
||||||
local msg = next_message()
|
local msg = next_msg()
|
||||||
if pos1 <= #msgs1 and pcall(eq, msgs1[pos1], msg) then
|
if pos1 <= #msgs1 and pcall(eq, msgs1[pos1], msg) then
|
||||||
pos1 = pos1 + 1
|
pos1 = pos1 + 1
|
||||||
elseif pos2 <= #msgs2 then
|
elseif pos2 <= #msgs2 then
|
||||||
@ -117,7 +117,7 @@ local function expect_twostreams(msgs1, msgs2)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Expects a sequence of next_message() results. If multiple sequences are
|
-- Expects a sequence of next_msg() results. If multiple sequences are
|
||||||
-- passed they are tried until one succeeds, in order of shortest to longest.
|
-- passed they are tried until one succeeds, in order of shortest to longest.
|
||||||
local function expect_msg_seq(...)
|
local function expect_msg_seq(...)
|
||||||
if select('#', ...) < 1 then
|
if select('#', ...) < 1 then
|
||||||
@ -140,7 +140,7 @@ local function expect_msg_seq(...)
|
|||||||
local expected_seq = seqs[anum]
|
local expected_seq = seqs[anum]
|
||||||
-- Collect enough messages to compare the next expected sequence.
|
-- Collect enough messages to compare the next expected sequence.
|
||||||
while #actual_seq < #expected_seq do
|
while #actual_seq < #expected_seq do
|
||||||
local msg = next_message(10000) -- Big timeout for ASAN/valgrind.
|
local msg = next_msg(10000) -- Big timeout for ASAN/valgrind.
|
||||||
if msg == nil then
|
if msg == nil then
|
||||||
error(cat_err(final_error,
|
error(cat_err(final_error,
|
||||||
string.format('got %d messages, expected %d',
|
string.format('got %d messages, expected %d',
|
||||||
@ -754,7 +754,7 @@ local module = {
|
|||||||
mkdir = lfs.mkdir,
|
mkdir = lfs.mkdir,
|
||||||
neq = neq,
|
neq = neq,
|
||||||
new_pipename = new_pipename,
|
new_pipename = new_pipename,
|
||||||
next_message = next_message,
|
next_msg = next_msg,
|
||||||
nvim = nvim,
|
nvim = nvim,
|
||||||
nvim_argv = nvim_argv,
|
nvim_argv = nvim_argv,
|
||||||
nvim_async = nvim_async,
|
nvim_async = nvim_async,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local clear, feed_command, nvim = helpers.clear, helpers.feed_command, helpers.nvim
|
local clear, feed_command, nvim = helpers.clear, helpers.feed_command, helpers.nvim
|
||||||
local feed, next_message, eq = helpers.feed, helpers.next_message, helpers.eq
|
local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq
|
||||||
local expect = helpers.expect
|
local expect = helpers.expect
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
@ -16,7 +16,7 @@ describe('mappings', function()
|
|||||||
|
|
||||||
local check_mapping = function(mapping, expected)
|
local check_mapping = function(mapping, expected)
|
||||||
feed(mapping)
|
feed(mapping)
|
||||||
eq({'notification', 'mapped', {expected}}, next_message())
|
eq({'notification', 'mapped', {expected}}, next_msg())
|
||||||
end
|
end
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
Loading…
Reference in New Issue
Block a user