diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/definition/luadoc.lua | 10 | ||||
-rw-r--r-- | test/diagnostics/type-check.lua | 66 | ||||
-rw-r--r-- | test/hover/init.lua | 6 |
3 files changed, 74 insertions, 8 deletions
diff --git a/test/definition/luadoc.lua b/test/definition/luadoc.lua index d8da938e..d8b3ef60 100644 --- a/test/definition/luadoc.lua +++ b/test/definition/luadoc.lua @@ -642,7 +642,7 @@ end ]] TEST [[ ----@class TT<V>: { <!x: V!> } +---@class TT<V>: { <!x!>: V } ---@type TT<A> local t @@ -653,7 +653,7 @@ print(t.<?x?>) ]] TEST [[ ----@alias TT<V> { <!x: V!> } +---@alias TT<V> { <!x!>: V } ---@type TT<A> local t @@ -823,7 +823,7 @@ z.<?a?> ]] TEST [[ ----@type { <!x: number!>, y: number } +---@type { <!x!>: number, y: number } local t print(t.<?x?>) @@ -846,14 +846,14 @@ local <!<?v?>!> = t[1] TEST [[ ---@class A ----@field <!['xx']!>? <!{}!> +---@field [<!'xx'!>]? <!{}!> local t print(t.<?xx?>) ]] TEST [[ ----@type { <!['xx']?: boolean!> } +---@type { [<!'xx'!>]?: boolean } local t print(t.<?xx?>) diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua index 7a39d7dc..f6b8f008 100644 --- a/test/diagnostics/type-check.lua +++ b/test/diagnostics/type-check.lua @@ -876,6 +876,72 @@ end f(<!1!>) ]] +TEST [[ +---@type table<string, string> +local x + +---@type table<number, string> +local y + +<!x!> = y +]] + +TEST [[ +---@type table<string, string> +local x + +---@type table<string, number> +local y + +<!x!> = y +]] + +TEST [[ +---@type table<string, string> +local x + +---@type table<string, string> +local y + +x = y +]] + +TEST [[ +---@param opts {a:number, b:number} +local function foo(opts) + +end + +---@param opts {a:number, b:number} +local function bar(opts) + foo(opts) +end +]] + +TEST [[ +---@param opts {a:number, b:number} +local function foo(opts) + +end + +---@param opts {c:number, d:number} +local function bar(opts) + foo(<!opts!>) -- this should raise linting error +end +]] + +TEST [[ +---@param opts {[number]: boolean} +local function foo(opts) + +end + +---@param opts {[1]: boolean} +local function bar(opts) + foo(opts) +end +]] + config.remove(nil, 'Lua.diagnostics.disable', 'unused-local') config.remove(nil, 'Lua.diagnostics.disable', 'unused-function') config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global') diff --git a/test/hover/init.lua b/test/hover/init.lua index 780c1da8..974f87db 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -420,7 +420,7 @@ local t: { [1]: integer = 2, [true]: integer = 3, [5.5]: integer = 4, - b: integer = 7, + ["b"]: integer = 7, ["012"]: integer = 8, } ]] @@ -1714,11 +1714,11 @@ local <?t?> = { local t: { x: string = "e", y: string = "f", - z: string = "g", + ["z"]: string = "g", + [10]: string = "d", [1]: string = "a", [2]: string = "b", [3]: string = "c"|"h", - [10]: string = "d", } ]] |