summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/crossfile/hover.lua23
-rw-r--r--test/hover/init.lua40
-rw-r--r--test/signature/init.lua2
-rw-r--r--test/type_inference/init.lua38
4 files changed, 97 insertions, 6 deletions
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua
index b9ffd59b..c6991d8f 100644
--- a/test/crossfile/hover.lua
+++ b/test/crossfile/hover.lua
@@ -1158,3 +1158,26 @@ TEST {
---
The color of your awesome apple!]]
}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ ---@type fun(x: number, y: number, ...: number):(x: number, y: number, ...: number)
+ local <?f?>
+ ]]
+ },
+ hover = [[
+```lua
+local f: fun(x: number, y: number, ...number):(x: number, y: number, ...number)
+```
+
+---
+
+```lua
+function f(x: number, y: number, ...: number)
+ -> x: number
+ 2. y: number
+ 3. ...number
+```]]
+}
diff --git a/test/hover/init.lua b/test/hover/init.lua
index a97cf3ae..9cdf2ed4 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -247,7 +247,7 @@ TEST [[
<?print?>()
]]
[[
-function print(...: any)
+function print(...any)
]]
TEST [[
@@ -300,7 +300,7 @@ end
<?x?>(1, 2, 3, 4, 5, 6, 7)
]]
[[
-function x(a: any, ...: any)
+function x(a: any, ...any)
]]
TEST [[
@@ -1518,7 +1518,7 @@ TEST [[
local function f(<?callback?>) end
]]
[[
-(parameter) callback: fun(x: integer, ...: any)
+(parameter) callback: fun(x: integer, ...any)
]]
TEST [[
@@ -2030,3 +2030,37 @@ local t: A {
y: boolean = true,
}
]]
+
+TEST [[
+---@param ... boolean
+---@return number ...
+local function <?f?>(...) end
+]]
+[[
+function f(...boolean)
+ -> ...number
+]]
+
+TEST [[
+---@type fun():x: number
+local <?f?>
+]]
+[[
+local f: fun():(x: number)
+]]
+
+TEST [[
+---@type fun(...: boolean):...: number
+local <?f?>
+]]
+[[
+local f: fun(...boolean):...number
+]]
+
+TEST [[
+---@type fun():x: number, y: boolean
+local <?f?>
+]]
+[[
+local f: fun():(x: number, y: boolean)
+]]
diff --git a/test/signature/init.lua b/test/signature/init.lua
index 0b750cd6..207fc0b7 100644
--- a/test/signature/init.lua
+++ b/test/signature/init.lua
@@ -83,7 +83,7 @@ end
x(1, 2, 3, <??>
]]
-'function x(a: any, <!...: any!>)'
+'function x(a: any, <!...any!>)'
TEST [[
(''):sub(<??>
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index e86983b6..db5a38fd 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -510,12 +510,12 @@ TEST 'fun()' [[
local <?x?>
]]
-TEST 'fun(a: string, b: any, ...: any)' [[
+TEST 'fun(a: string, b: any, ...any)' [[
---@type fun(a: string, b, ...)
local <?x?>
]]
-TEST 'fun(a: string, b: any, c?: boolean, ...: any):c, d?, ...' [[
+TEST 'fun(a: string, b: any, c?: boolean, ...any):c, d?, ...' [[
---@type fun(a: string, b, c?: boolean, ...):c, d?, ...
local <?x?>
]]
@@ -3092,3 +3092,37 @@ local function f() end
local _, <?n?> = f()
]]
+
+TEST 'boolean' [[
+---@type fun():name1: boolean, name2:number
+local f
+
+local <?n?> = f()
+]]
+
+TEST 'number' [[
+---@type fun():name1: boolean, name2:number
+local f
+
+local _, <?n?> = f()
+]]
+TEST 'boolean' [[
+---@type fun():(name1: boolean, name2:number)
+local f
+
+local <?n?> = f()
+]]
+
+TEST 'number' [[
+---@type fun():(name1: boolean, name2:number)
+local f
+
+local _, <?n?> = f()
+]]
+
+TEST 'boolean' [[
+---@type fun():...: boolean
+local f
+
+local _, <?n?> = f()
+]]