mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
unittests: Fix linter errors
This commit is contained in:
@@ -19,8 +19,13 @@ local api = cimport('./src/nvim/api/private/defs.h',
|
|||||||
|
|
||||||
local obj2lua
|
local obj2lua
|
||||||
|
|
||||||
obj2lua = function(obj)
|
local obj2lua_tab = nil
|
||||||
local obj2lua_tab = {
|
|
||||||
|
local function init_obj2lua_tab()
|
||||||
|
if obj2lua_tab then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
obj2lua_tab = {
|
||||||
[tonumber(api.kObjectTypeArray)] = function(obj)
|
[tonumber(api.kObjectTypeArray)] = function(obj)
|
||||||
local ret = {[type_key]=list_type}
|
local ret = {[type_key]=list_type}
|
||||||
for i = 1,tonumber(obj.data.array.size) do
|
for i = 1,tonumber(obj.data.array.size) do
|
||||||
@@ -59,6 +64,10 @@ obj2lua = function(obj)
|
|||||||
return ffi.string(obj.data.string.data, obj.data.string.size)
|
return ffi.string(obj.data.string.data, obj.data.string.size)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
obj2lua = function(obj)
|
||||||
|
init_obj2lua_tab()
|
||||||
return ((obj2lua_tab[tonumber(obj['type'])] or function(obj_inner)
|
return ((obj2lua_tab[tonumber(obj['type'])] or function(obj_inner)
|
||||||
assert(false, 'Converting ' .. tostring(tonumber(obj_inner['type'])) .. ' is not implementing yet')
|
assert(false, 'Converting ' .. tostring(tonumber(obj_inner['type'])) .. ' is not implementing yet')
|
||||||
end)(obj))
|
end)(obj))
|
||||||
|
@@ -72,6 +72,7 @@ describe('json_decode_string()', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
itp('does not overflow in error messages', function()
|
itp('does not overflow in error messages', function()
|
||||||
|
local saved_p_enc = decode.p_enc
|
||||||
check_failure(']test', 1, 'E474: No container to close: ]')
|
check_failure(']test', 1, 'E474: No container to close: ]')
|
||||||
check_failure('[}test', 2, 'E474: Closing list with curly bracket: }')
|
check_failure('[}test', 2, 'E474: Closing list with curly bracket: }')
|
||||||
check_failure('{]test', 2,
|
check_failure('{]test', 2,
|
||||||
|
@@ -11,7 +11,6 @@ local posix = nil
|
|||||||
local syscall = nil
|
local syscall = nil
|
||||||
|
|
||||||
local check_cores = global_helpers.check_cores
|
local check_cores = global_helpers.check_cores
|
||||||
local which = global_helpers.which
|
|
||||||
local neq = global_helpers.neq
|
local neq = global_helpers.neq
|
||||||
local map = global_helpers.map
|
local map = global_helpers.map
|
||||||
local eq = global_helpers.eq
|
local eq = global_helpers.eq
|
||||||
@@ -30,11 +29,11 @@ for _, p in ipairs(Paths.include_paths) do
|
|||||||
Preprocess.add_to_include_path(p)
|
Preprocess.add_to_include_path(p)
|
||||||
end
|
end
|
||||||
|
|
||||||
local pid = nil
|
local child_pid = nil
|
||||||
local function only_separate(func)
|
local function only_separate(func)
|
||||||
return function(...)
|
return function(...)
|
||||||
if pid ~= 0 then
|
if child_pid ~= 0 then
|
||||||
eq(0, 'This function must be run in a separate process only')
|
error('This function must be run in a separate process only')
|
||||||
end
|
end
|
||||||
return func(...)
|
return func(...)
|
||||||
end
|
end
|
||||||
@@ -44,7 +43,7 @@ local deferred_calls_mod = nil
|
|||||||
local function deferred_call(func, ret)
|
local function deferred_call(func, ret)
|
||||||
return function(...)
|
return function(...)
|
||||||
local deferred_calls = deferred_calls_mod or deferred_calls_init
|
local deferred_calls = deferred_calls_mod or deferred_calls_init
|
||||||
if pid ~= 0 then
|
if child_pid ~= 0 then
|
||||||
deferred_calls[#deferred_calls + 1] = {func=func, args={...}}
|
deferred_calls[#deferred_calls + 1] = {func=func, args={...}}
|
||||||
return ret
|
return ret
|
||||||
else
|
else
|
||||||
@@ -57,7 +56,7 @@ local separate_cleanups_mod = nil
|
|||||||
local function separate_cleanup(func)
|
local function separate_cleanup(func)
|
||||||
return function(...)
|
return function(...)
|
||||||
local separate_cleanups = separate_cleanups_mod
|
local separate_cleanups = separate_cleanups_mod
|
||||||
if pid ~= 0 then
|
if child_pid ~= 0 then
|
||||||
separate_cleanups[#separate_cleanups + 1] = {args={...}}
|
separate_cleanups[#separate_cleanups + 1] = {args={...}}
|
||||||
else
|
else
|
||||||
func(...)
|
func(...)
|
||||||
@@ -68,10 +67,10 @@ end
|
|||||||
local libnvim = nil
|
local libnvim = nil
|
||||||
|
|
||||||
local lib = setmetatable({}, {
|
local lib = setmetatable({}, {
|
||||||
__index = only_separate(function(tbl, idx)
|
__index = only_separate(function(_, idx)
|
||||||
return libnvim[idx]
|
return libnvim[idx]
|
||||||
end),
|
end),
|
||||||
__newindex = deferred_call(function(tbl, idx, val)
|
__newindex = deferred_call(function(_, idx, val)
|
||||||
libnvim[idx] = val
|
libnvim[idx] = val
|
||||||
end),
|
end),
|
||||||
})
|
})
|
||||||
@@ -154,10 +153,8 @@ cimport = function(...)
|
|||||||
or path:sub(2, 2) == ':') then
|
or path:sub(2, 2) == ':') then
|
||||||
path = './' .. path
|
path = './' .. path
|
||||||
end
|
end
|
||||||
|
if not preprocess_cache[path] then
|
||||||
local body
|
local body
|
||||||
if preprocess_cache[path] then
|
|
||||||
body = preprocess_cache[path]
|
|
||||||
else
|
|
||||||
body, previous_defines = Preprocess.preprocess(previous_defines, path)
|
body, previous_defines = Preprocess.preprocess(previous_defines, path)
|
||||||
-- format it (so that the lines are "unique" statements), also filter out
|
-- format it (so that the lines are "unique" statements), also filter out
|
||||||
-- Objective-C blocks
|
-- Objective-C blocks
|
||||||
@@ -178,10 +175,10 @@ cimport = function(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local cimport_immediate = function(...)
|
local cimport_immediate = function(...)
|
||||||
local saved_pid = pid
|
local saved_pid = child_pid
|
||||||
pid = 0
|
child_pid = 0
|
||||||
local err, emsg = pcall(cimport, ...)
|
local err, emsg = pcall(cimport, ...)
|
||||||
pid = saved_pid
|
child_pid = saved_pid
|
||||||
if not err then
|
if not err then
|
||||||
emsg = tostring(emsg)
|
emsg = tostring(emsg)
|
||||||
io.stderr:write(emsg .. '\n')
|
io.stderr:write(emsg .. '\n')
|
||||||
@@ -461,7 +458,7 @@ end
|
|||||||
|
|
||||||
local function gen_itp(it)
|
local function gen_itp(it)
|
||||||
deferred_calls_mod = {}
|
deferred_calls_mod = {}
|
||||||
deferred_cleanups_mod = {}
|
separate_cleanups_mod = {}
|
||||||
preprocess_cache_mod = map(function(v) return v end, preprocess_cache_init)
|
preprocess_cache_mod = map(function(v) return v end, preprocess_cache_init)
|
||||||
previous_defines_mod = previous_defines_init
|
previous_defines_mod = previous_defines_init
|
||||||
local function just_fail(_)
|
local function just_fail(_)
|
||||||
@@ -479,8 +476,8 @@ local function gen_itp(it)
|
|||||||
end
|
end
|
||||||
it(name, function()
|
it(name, function()
|
||||||
local rd, wr = sc.pipe()
|
local rd, wr = sc.pipe()
|
||||||
pid = sc.fork()
|
child_pid = sc.fork()
|
||||||
if pid == 0 then
|
if child_pid == 0 then
|
||||||
init()
|
init()
|
||||||
sc.close(rd)
|
sc.close(rd)
|
||||||
collectgarbage('stop')
|
collectgarbage('stop')
|
||||||
@@ -500,8 +497,8 @@ local function gen_itp(it)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
sc.close(wr)
|
sc.close(wr)
|
||||||
sc.wait(pid)
|
sc.wait(child_pid)
|
||||||
pid = nil
|
child_pid = nil
|
||||||
local function check()
|
local function check()
|
||||||
local res = sc.read(rd, 2)
|
local res = sc.read(rd, 2)
|
||||||
eq(2, #res)
|
eq(2, #res)
|
||||||
|
@@ -11,7 +11,6 @@ local ffi, eq = helpers.ffi, helpers.eq
|
|||||||
local intern = helpers.internalize
|
local intern = helpers.internalize
|
||||||
local to_cstr = helpers.to_cstr
|
local to_cstr = helpers.to_cstr
|
||||||
local NULL = ffi.cast('void *', 0)
|
local NULL = ffi.cast('void *', 0)
|
||||||
local deferred_call = deferred_call
|
|
||||||
|
|
||||||
describe('shell functions', function()
|
describe('shell functions', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
Reference in New Issue
Block a user