aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/ffi_spec.lua
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-10-17 23:58:14 +0200
committerGitHub <noreply@github.com>2021-10-17 23:58:14 +0200
commitffc28dcbdb0d3ea7f1f70d1f9627d423f950d224 (patch)
tree6b58b54af6095b8d09c5c5dc6654af0892d83dc5 /test/functional/lua/ffi_spec.lua
parent8f9f127274fb5e715645f88fe8e76f4a7ca8ca10 (diff)
parentaa644b7fd3ba195ed101b8afc4c599050160cc79 (diff)
downloadrneovim-ffc28dcbdb0d3ea7f1f70d1f9627d423f950d224.tar.gz
rneovim-ffc28dcbdb0d3ea7f1f70d1f9627d423f950d224.tar.bz2
rneovim-ffc28dcbdb0d3ea7f1f70d1f9627d423f950d224.zip
Merge pull request #15999 from famiu/fix/build/export-windows-symbols
fix(build): export symbols on Windows
Diffstat (limited to 'test/functional/lua/ffi_spec.lua')
-rw-r--r--test/functional/lua/ffi_spec.lua62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/functional/lua/ffi_spec.lua b/test/functional/lua/ffi_spec.lua
new file mode 100644
index 0000000000..80c01a2b8c
--- /dev/null
+++ b/test/functional/lua/ffi_spec.lua
@@ -0,0 +1,62 @@
+local helpers = require('test.functional.helpers')(after_each)
+local eq = helpers.eq
+local exec_lua = helpers.exec_lua
+local clear = helpers.clear
+
+before_each(clear)
+
+describe('ffi.cdef', function()
+ it('can use Neovim core functions', function()
+ if not exec_lua("return pcall(require, 'ffi')") then
+ pending('missing LuaJIT FFI')
+ end
+
+ eq(12, exec_lua[[
+ local ffi = require('ffi')
+
+ ffi.cdef('int curwin_col_off(void);')
+
+ vim.cmd('set number numberwidth=4 signcolumn=yes:4')
+
+ return ffi.C.curwin_col_off()
+ ]])
+
+ eq(20, exec_lua[=[
+ local ffi = require('ffi')
+
+ ffi.cdef[[
+ typedef unsigned char char_u;
+ typedef struct window_S win_T;
+ typedef struct {} stl_hlrec_t;
+ typedef struct {} StlClickRecord;
+ typedef struct {} Error;
+
+ win_T *find_window_by_handle(int Window, Error *err);
+
+ int build_stl_str_hl(
+ win_T *wp,
+ char_u *out,
+ size_t outlen,
+ char_u *fmt,
+ int use_sandbox,
+ char_u fillchar,
+ int maxwidth,
+ stl_hlrec_t **hltab,
+ StlClickRecord **tabtab
+ );
+ ]]
+
+ return ffi.C.build_stl_str_hl(
+ ffi.C.find_window_by_handle(0, ffi.new('Error')),
+ ffi.new('char_u[1024]'),
+ 1024,
+ ffi.cast('char_u*', 'StatusLineOfLength20'),
+ 0,
+ 0,
+ 0,
+ nil,
+ nil
+ )
+ ]=])
+ end)
+end)