test: support upvalues in exec_lua

This commit is contained in:
Lewis Russell
2024-08-11 09:27:48 +01:00
committed by Lewis Russell
parent a19e89022d
commit e5c174421d
34 changed files with 1740 additions and 1362 deletions

View File

@@ -15,27 +15,27 @@ describe('ffi.cdef', function()
eq(
12,
exec_lua [=[
local ffi = require('ffi')
exec_lua(function()
local ffi = require('ffi')
ffi.cdef [[
ffi.cdef [[
typedef struct window_S win_T;
int win_col_off(win_T *wp);
extern win_T *curwin;
]]
vim.cmd('set number numberwidth=4 signcolumn=yes:4')
vim.cmd('set number numberwidth=4 signcolumn=yes:4')
return ffi.C.win_col_off(ffi.C.curwin)
]=]
return ffi.C.win_col_off(ffi.C.curwin)
end)
)
eq(
20,
exec_lua [=[
local ffi = require('ffi')
exec_lua(function()
local ffi = require('ffi')
ffi.cdef[[
ffi.cdef [[
typedef struct {} stl_hlrec_t;
typedef struct {} StlClickRecord;
typedef struct {} statuscol_T;
@@ -58,32 +58,32 @@ describe('ffi.cdef', function()
);
]]
return ffi.C.build_stl_str_hl(
ffi.C.find_window_by_handle(0, ffi.new('Error')),
ffi.new('char[1024]'),
1024,
ffi.cast('char*', 'StatusLineOfLength20'),
-1,
0,
0,
0,
nil,
nil,
nil
)
]=]
return ffi.C.build_stl_str_hl(
ffi.C.find_window_by_handle(0, ffi.new('Error')),
ffi.new('char[1024]'),
1024,
ffi.cast('char*', 'StatusLineOfLength20'),
-1,
0,
0,
0,
nil,
nil,
nil
)
end)
)
-- Check that extern symbols are exported and accessible
eq(
true,
exec_lua [[
local ffi = require('ffi')
exec_lua(function()
local ffi = require('ffi')
ffi.cdef('uint64_t display_tick;')
ffi.cdef('uint64_t display_tick;')
return ffi.C.display_tick >= 0
]]
return ffi.C.display_tick >= 0
end)
)
end)
end)