summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-18 01:07:30 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-18 01:07:30 +0800
commitdca751cf110a96a351c8cadc049ac364dc41a4dd (patch)
tree785d41633d4ee6bfa3e97ec25043c5cedbc6da28 /test
parent04c671114d1d4c4bcfbad74c8341b24844552865 (diff)
downloadlua-language-server-dca751cf110a96a351c8cadc049ac364dc41a4dd.zip
#1255
diagnostic for enum
Diffstat (limited to 'test')
-rw-r--r--test/diagnostics/type-check.lua35
-rw-r--r--test/hover/init.lua10
-rw-r--r--test/type_inference/init.lua2
3 files changed, 46 insertions, 1 deletions
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index 46cb2471..b99e226c 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -729,5 +729,40 @@ local x = G
]]
config.set(nil, 'Lua.type.weakUnionCheck', false)
+TEST [[
+---@type 1|2
+local x
+
+x = 1
+x = 2
+<!x!> = 3
+]]
+
+TEST [[
+---@type 'x'|'y'
+local x
+
+x = 'x'
+x = 'y'
+<!x!> = 'z'
+]]
+
+TEST [[
+---@enum A
+local t = {
+ x = 1,
+ y = 2,
+}
+
+---@param x A
+local function f(x)
+end
+
+f(<!t!>)
+f(t.x)
+f(1)
+f(<!3!>)
+]]
+
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')
diff --git a/test/hover/init.lua b/test/hover/init.lua
index 0954ac80..95764923 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -2120,3 +2120,13 @@ local <?s?>
[[
local s: 'a'
]]
+
+TEST [[
+---@enum <?A?>
+local m = {
+ x = 1,
+}
+]]
+[[
+(enum) A
+]]
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 39d14e86..e4baf4a4 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -3720,7 +3720,7 @@ TEST '-2|-3|1' [[
local <?n?>
]]
-TEST 'A' [[
+TEST 'table' [[
---@enum A
local m = {}