Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
fesily committed Feb 26, 2024
1 parent 87c83c3 commit e03dc18
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion test/diagnostics/await-in-sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ end

TEST [[
local function f(cb)
<!cb!>()
cb()
end
local function af()
Expand Down
2 changes: 1 addition & 1 deletion test/diagnostics/redundant-parameter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ print(1, 2, 3, 4, 5)

TEST [[
local function f(callback)
callback(<!1!>, <!2!>, <!3!>)
callback(1, 2, 3)
end
f(function () end)
]]
Expand Down
4 changes: 2 additions & 2 deletions test/hover/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,15 @@ function string.lower(s: string|number)
-> string
]]

-- 根据传入值推测参数类型
-- 不根据传入值推测参数类型
TEST [[
local function x(a, ...)
end
<?x?>(1, 2, 3, 4, 5, 6, 7)
]]
[[
function x(a: integer, ...any)
function x(a: any, ...any)
]]

TEST [[
Expand Down
41 changes: 34 additions & 7 deletions test/signature/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ end
x(1, 2, 3, <??>
]]
{'function x(a: integer, <!...any!>)'}
{'function x(a: any, <!...any!>)'}

TEST [[
(''):sub(<??>
Expand All @@ -106,7 +106,7 @@ end
f(1, 'string<??>')
]]
{'function f(a: integer, <!b: string!>, c: any)'}
{'function f(a: any, <!b: any!>, c: any)'}

TEST [[
pcall(function () <??> end)
Expand Down Expand Up @@ -156,7 +156,7 @@ end
f({},<??>)
]]
{'function f(a: table, <!b: any!>, c: any)'}
{'function f(a: any, <!b: any!>, c: any)'}

TEST [[
for _ in pairs(<??>) do
Expand Down Expand Up @@ -188,31 +188,31 @@ end
x( aaaa <??>, 2)
]]
{"function x(<!a: any!>, b: integer)"}
{"function x(<!a: any!>, b: any)"}

TEST [[
local function x(a, b)
end
x(<??> aaaa , 2)
]]
{'function x(<!a: any!>, b: integer)'}
{'function x(<!a: any!>, b: any)'}

TEST [[
local function x(a, b)
end
x(aaaa ,<??> 2)
]]
{'function x(a: any, <!b: integer!>)'}
{'function x(a: any, <!b: any!>)'}

TEST [[
local function x(a, b)
end
x(aaaa , 2 <??>)
]]
{'function x(a: any, <!b: integer!>)'}
{'function x(a: any, <!b: any!>)'}

TEST [[
local fooC
Expand Down Expand Up @@ -372,3 +372,30 @@ t:event("onTimer", <??>)
{
'(method) (ev: "onTimer", <!t: integer!>)',
}

local config = require 'config'
config.set(nil, "Lua.type.inferParamType", true)

TEST [[
local function x(a, b)
end
x("1", <??>)
]]
{
'function x(a: string, <!b: any!>)'
}

TEST [[
local function x(a)
end
x('str')
x(1)
x(<??>)
]]
{
'function x(<!a: string|integer!>)',
}

config.set(nil, "Lua.type.inferParamType", false)

0 comments on commit e03dc18

Please sign in to comment.