diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-01-09 17:15:22 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-01-09 17:15:22 +0800 |
commit | c796d406329170e010590d7c9584b8483021cee3 (patch) | |
tree | a4f43228c38847acaf968aea1e46c8df3d88ec17 /test | |
parent | 78875f59fe2fa846d62bf955805b647d17cf87d2 (diff) | |
download | lua-language-server-c796d406329170e010590d7c9584b8483021cee3.zip |
support trace for global
Diffstat (limited to 'test')
-rw-r--r-- | test/definition/bug.lua | 7 | ||||
-rw-r--r-- | test/signature/init.lua | 30 | ||||
-rw-r--r-- | test/type_inference/init.lua | 59 |
3 files changed, 50 insertions, 46 deletions
diff --git a/test/definition/bug.lua b/test/definition/bug.lua index b564f764..2e2a5972 100644 --- a/test/definition/bug.lua +++ b/test/definition/bug.lua @@ -48,6 +48,13 @@ obj[#<?obj?>+1] = {} TEST [[ self = { + <!results!> = {} +} +self[self.<?results?>] = lbl +]] + +TEST [[ +self = { results = { <!labels!> = {}, } diff --git a/test/signature/init.lua b/test/signature/init.lua index 17c5cecb..147f93e1 100644 --- a/test/signature/init.lua +++ b/test/signature/init.lua @@ -235,11 +235,8 @@ end)(<??>) {'function (<!a: any!>, b: any)'} TEST [[ -function X() end - ----@param a number -function X(a) end - +---@overload fun() +---@overload fun(a:number) ---@param a number ---@param b number function X(a, b) end @@ -252,12 +249,9 @@ X(<??>) 'function X(<!a: number!>, b: number)', } -TEST [[ -function X() end - ----@param a number -function X(a) end - +TEST [[\ +---@overload fun() +---@overload fun(a:number) ---@param a number ---@param b number function X(a, b) end @@ -270,11 +264,8 @@ X(<?1?>) } TEST [[ -function X() end - ----@param a number -function X(a) end - +---@overload fun() +---@overload fun(a:number) ---@param a number ---@param b number function X(a, b) end @@ -286,11 +277,8 @@ X(1, <??>) } TEST [[ -function X() end - ----@param a number -function X(a) end - +---@overload fun() +---@overload fun(a:number) ---@param a number ---@param b number function X(a, b) end diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index 0b69a34c..db1d306e 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -2893,10 +2893,7 @@ local <?x?> = echo(b) ]] TEST 'boolean' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -2906,10 +2903,7 @@ local <?x?> = f() ]] TEST 'number' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -2919,10 +2913,7 @@ local <?x?> = f(1) ]] TEST 'boolean' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -2936,10 +2927,7 @@ local <?x?> = f(r0()) ]] TEST 'number' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -2953,10 +2941,7 @@ local <?x?> = f(r1()) ]] TEST 'boolean' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -2969,10 +2954,7 @@ local <?x?> = f(r0()) ]] TEST 'number' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -3430,7 +3412,7 @@ local mt = {} mt.<?x?> = nil ]] -TEST 'unknown' [[ +TEST 'nil' [[ mt = {} mt.<?x?> = nil ]] @@ -4148,3 +4130,30 @@ for _, <?x?> in ipairs(xs) do x = f(x) end ]] + +TEST 'number' [[ +---@type number? +X = Y + +if X then + print(<?X?>) +end +]] + +TEST 'number' [[ +---@type number|boolean +X = Y + +if type(X) == 'number' then + print(<?X?>) +end +]] + +TEST 'boolean' [[ +---@type number|boolean +X = Y + +if type(X) ~= 'number' then + print(<?X?>) +end +]] |