diff options
Diffstat (limited to 'test/plugins/ffi/cdef.lua')
-rw-r--r-- | test/plugins/ffi/cdef.lua | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/plugins/ffi/cdef.lua b/test/plugins/ffi/cdef.lua new file mode 100644 index 00000000..cf3992d3 --- /dev/null +++ b/test/plugins/ffi/cdef.lua @@ -0,0 +1,61 @@ + +local files = require 'files' +local code = require 'plugins.ffi.searchCode' +local cdefRerence = require 'plugins.ffi.cdefRerence' + +rawset(_G, 'TEST', true) + +function TEST(wanted) + ---@async + return function (script) + files.setText(TESTURI, script) + local codeResults = code(cdefRerence(), TESTURI) + assert(codeResults) + table.sort(codeResults) + assert(table.concat(codeResults, '|') == wanted, table.concat(codeResults, '|') .. ' ~= ' .. wanted) + files.remove(TESTURI) + end +end + +TEST 'aaa|bbb' [[ +local ffi = require 'ffi' +local cdef = ffi.cdef +cdef('aaa') +cdef = function () +end +cdef('bbb') +]] + +TEST 'aaa' [[ +local ffi = require 'ffi' + +ffi.cdef('aaa') +]] + +TEST 'aa.aa' [[ +local ffi = require 'ffi' +local t1 = ffi + +t1.cdef"aa.aa" +]] + +TEST 'aaa' [[ +local ffi = require 'ffi' +local code = 'aaa' +ffi.cdef(code) +]] + +TEST 'aaa|bbb' [[ +local ffi = require 'ffi' +local code = 'aaa' +code = 'bbb' +local t1 = ffi +t1.cdef(code) +]] + +TEST 'aa.aa' [[ +local ffi = require 'ffi' +local cdef = ffi.cdef + +cdef"aa.aa" +]] |