diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/completion/common.lua | 26 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 24 | ||||
-rw-r--r-- | test/diagnostics/param-type-mismatch.lua | 16 |
3 files changed, 66 insertions, 0 deletions
diff --git a/test/completion/common.lua b/test/completion/common.lua index e33b2a1b..bd317259 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -3816,6 +3816,32 @@ f(<??>) } TEST [[ +local x = 1 +local y = 2 + +---@enum(key) Enum +local t = { + x = x, + y = y, +} + +---@param p Enum +local function f(p) end + +f(<??>) +]] +{ + { + label = '"x"', + kind = define.CompletionItemKind.EnumMember, + }, + { + label = '"y"', + kind = define.CompletionItemKind.EnumMember, + }, +} + +TEST [[ -- <??> ]] diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 617b6f7e..a18c714b 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -1637,6 +1637,30 @@ TEST { { path = 'a.lua', content = [[ + ---@enum(key) <?A?> + local t = { + x = 1 << 0, + y = 1 << 1, + z = 1 << 2, + } + ]] + }, + hover = [[ +```lua +(enum) A +``` + +--- + +```lua +"x" | "y" | "z" +```]] +} + +TEST { + { + path = 'a.lua', + content = [[ ---@alias someType ---| "#" # description diff --git a/test/diagnostics/param-type-mismatch.lua b/test/diagnostics/param-type-mismatch.lua index 2a4bfcb1..e31e9933 100644 --- a/test/diagnostics/param-type-mismatch.lua +++ b/test/diagnostics/param-type-mismatch.lua @@ -91,6 +91,22 @@ f(<!{ h = 1 }!>) ]] TEST [[ +---@enum(key) A +local t = { + x = 1, + ['y'] = 2, +} + +---@param x A +local function f(x) +end + +f('x') +f('y') +f(<!'z'!>) +]] + +TEST [[ ---@generic T: string | boolean | table ---@param x T ---@return T |