summaryrefslogtreecommitdiff
path: root/test/completion
diff options
context:
space:
mode:
authorKevin Hahn <hahn.kev@gmail.com>2022-06-27 13:34:32 +0700
committerKevin Hahn <hahn.kev@gmail.com>2022-06-27 14:14:36 +0700
commitd0c242b4bc8bf39329655272e2f3922a9d559bda (patch)
tree1fe1c7a2bf862ece171302becdf299b96b018cca /test/completion
parentbd517b96174441ace37885353d5570f2d11e6404 (diff)
downloadlua-language-server-d0c242b4bc8bf39329655272e2f3922a9d559bda.zip
add unit tests for arrays
Diffstat (limited to 'test/completion')
-rw-r--r--test/completion/common.lua258
1 files changed, 258 insertions, 0 deletions
diff --git a/test/completion/common.lua b/test/completion/common.lua
index 27431000..fe09dea2 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -1640,6 +1640,264 @@ f('<??>')
}
TEST [[
+---@alias Option string | "AAA" | "BBB" | "CCC"
+---@param x Option[]
+function f(x)
+end
+
+f({<??>})
+]]
+{
+ {
+ label = '"AAA"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"BBB"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"CCC"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ }
+}
+
+TEST [[
+---@alias Option string | "AAA" | "BBB" | "CCC"
+---@param x Option[]
+function f(x)
+end
+
+f({"<??>"})
+]]
+{
+ {
+ label = '"AAA"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"BBB"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"CCC"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ }
+}
+
+TEST [[
+---@alias Option string | "AAA" | "BBB" | "CCC"
+---@param x Option[]
+function f(x)
+end
+
+f(<??>)
+]]
+ (nil)
+
+TEST [[
+---@alias Option "AAA" | "BBB" | "CCC"
+
+---@type Option[]
+local l = {<??>}
+]]
+{
+ {
+ label = '"AAA"',
+ kind = define.CompletionItemKind.EnumMember,
+ },
+ {
+ label = '"BBB"',
+ kind = define.CompletionItemKind.EnumMember,
+ },
+ {
+ label = '"CCC"',
+ kind = define.CompletionItemKind.EnumMember,
+ }
+}
+
+TEST [[
+---@alias Option "AAA" | "BBB" | "CCC"
+
+---@type Option[]
+local l = {"<??>"}
+]]
+{
+ {
+ label = '"AAA"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"BBB"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ },
+ {
+ label = '"CCC"',
+ kind = define.CompletionItemKind.EnumMember,
+ textEdit = EXISTS
+ }
+}
+
+TEST [[
+---@alias Option "AAA" | "BBB" | "CCC"
+
+---@type Option[]
+local l = <??>
+]]
+ (nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+
+---@type OptionObj[]
+local l = { {<??>} }
+]]
+{
+ {
+ label = 'a',
+ kind = define.CompletionItemKind.Property,
+ },
+ {
+ label = 'b',
+ kind = define.CompletionItemKind.Property,
+ }
+}
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+
+---@type OptionObj[]
+local l = { <??> }
+]]
+ (nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+
+---@type OptionObj[]
+local l = <??>
+]]
+ (nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@field children OptionObj[]
+
+---@type OptionObj[]
+local l = {
+ {
+ a = true,
+ children = { {<??>} }
+ }
+}
+]]
+{
+ {
+ label = 'a',
+ kind = define.CompletionItemKind.Property,
+ },
+ {
+ label = 'b',
+ kind = define.CompletionItemKind.Property,
+ },
+ {
+ label = 'children',
+ kind = define.CompletionItemKind.Property,
+ }
+}
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@field children OptionObj[]
+
+---@type OptionObj[]
+local l = {
+ {
+ children = {<??>}
+ }
+}
+]]
+(nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@field children OptionObj[]
+
+---@type OptionObj[]
+local l = {
+ {
+ children = <??>
+ }
+}
+]]
+(nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@param x OptionObj[]
+function f(x)
+end
+
+f({ {<??>} })
+]]
+{
+ {
+ label = 'a',
+ kind = define.CompletionItemKind.Property,
+ },
+ {
+ label = 'b',
+ kind = define.CompletionItemKind.Property,
+ }
+}
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@param x OptionObj[]
+function f(x)
+end
+
+f({<??>})
+]]
+ (nil)
+
+TEST [[
+---@class OptionObj
+---@field a boolean
+---@field b boolean
+---@param x OptionObj[]
+function f(x)
+end
+
+f(<??>)
+]]
+ (nil)
+
+TEST [[
---this is
---a multi line
---comment