blob: 620aab4b750aa73f073b56dfa7c980f640caac83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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'
}
|