diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 16:50:01 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 16:50:01 +0800 |
commit | 3c5ff2671305041d03cde8dafb05d4aed0cc0a65 (patch) | |
tree | 0f058a92500c7abef99fab007dc30d80107795b6 /server/test/signature | |
parent | bc0ab7b1fa924076a549cdcaaf3e90a6ef67600f (diff) | |
download | lua-language-server-3c5ff2671305041d03cde8dafb05d4aed0cc0a65.zip |
找当前参数
Diffstat (limited to 'server/test/signature')
-rw-r--r-- | server/test/signature/init.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/server/test/signature/init.lua b/server/test/signature/init.lua new file mode 100644 index 00000000..620aab4b --- /dev/null +++ b/server/test/signature/init.lua @@ -0,0 +1,35 @@ +local parser = require 'parser' +local matcher = require 'matcher' + +rawset(_G, 'TEST', true) + +function TEST(script) + return function (expect) + local pos = script:find('@', 1, true) + local new_script = script:gsub('@', '') + local ast = parser:ast(new_script) + local vm = matcher.vm(ast) + assert(vm) + local results = matcher.signature(vm, pos) + assert(results) + local result = results[#results] + + local label = result.label:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n') + expect.label = expect.label:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n') + local arg = result.arg.label + + assert(expect.label == label) + assert(expect.arg == arg) + end +end + +TEST [[ +local function x(a, b) +end + +x(@ +]] +{ + label = "function x(a: any, b: any)", + arg = 'a: any' +} |