summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2021-12-02 22:16:18 +0800
committersumneko <sumneko@hotmail.com>2021-12-02 22:16:18 +0800
commitc47baf932309a05673b7931fdf6a1be207fb7bc4 (patch)
tree2869d38a1472045ee9075083d14ca31ae6b35dd1 /test
parentb6da7274e8fa773183146982f8864247bb33a214 (diff)
parentcb2042160865589b5534a6bf0b6c366ae4ab1d99 (diff)
downloadlua-language-server-c47baf932309a05673b7931fdf6a1be207fb7bc4.zip
Merge remote-tracking branch 'origin/master' into multi-workspace
Diffstat (limited to 'test')
-rw-r--r--test/completion/common.lua24
-rw-r--r--test/crossfile/hover.lua32
-rw-r--r--test/definition/bug.lua77
-rw-r--r--test/diagnostics/init.lua16
-rw-r--r--test/type_inference/init.lua24
5 files changed, 151 insertions, 22 deletions
diff --git a/test/completion/common.lua b/test/completion/common.lua
index fad0df8e..94b55514 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -3013,3 +3013,27 @@ xx++<??>
}
},
}
+
+TEST [[
+fff(function ()
+ xx@xpcall<??>
+end)
+]]
+{
+ [1] = {
+ label = 'xpcall',
+ kind = define.CompletionItemKind.Event,
+ textEdit = {
+ start = 10007,
+ finish = 10013,
+ newText = 'xpcall(xx, ${1:debug.traceback}$2)$0',
+ },
+ additionalTextEdits = {
+ {
+ start = 10004,
+ finish = 10007,
+ newText = '',
+ }
+ }
+ },
+}
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua
index 5c1ad130..86471936 100644
--- a/test/crossfile/hover.lua
+++ b/test/crossfile/hover.lua
@@ -988,22 +988,22 @@ p: T
-- comment 4
```]]}
-TEST {{ path = 'a.lua', content = '', }, {
- path = 'b.lua',
- content = [[
----@param x number # aaa
-local f
-
-function f(<?x?>) end
-]]
-},
-hover = [[
-```lua
-local x: number
-```
-
----
- aaa]]}
+--TEST {{ path = 'a.lua', content = '', }, {
+-- path = 'b.lua',
+-- content = [[
+-----@param x number # aaa
+--local f
+--
+--function f(<?x?>) end
+--]]
+--},
+--hover = [[
+--```lua
+--local x: number
+--```
+--
+-----
+-- aaa]]}
TEST {{ path = 'a.lua', content = '', }, {
path = 'b.lua',
diff --git a/test/definition/bug.lua b/test/definition/bug.lua
index e8733636..4a755170 100644
--- a/test/definition/bug.lua
+++ b/test/definition/bug.lua
@@ -253,3 +253,80 @@ local <!v!> = t[a]
t[a] = <?v?>
]]
+
+TEST [[
+---@class A
+---@field x number
+
+---@class B: A
+---@field <!x!> boolean
+
+---@type B
+local t
+
+local <!<?v?>!> = t.x
+]]
+
+TEST [[
+---@class A
+---@field <!x!> number
+
+---@class B: A
+
+---@type B
+local t
+
+local <!<?v?>!> = t.x
+]]
+
+TEST [[
+---@class A
+local A
+
+function A:x() end
+
+---@class B: A
+local B
+
+function B:<!x!>() end
+
+---@type B
+local t
+
+local <!<?v?>!> = t.x
+]]
+
+TEST [[
+---@class A
+local A
+
+function A:<!x!>() end
+
+---@class B: A
+local B
+
+---@type B
+local t
+
+local <!<?v?>!> = t.x
+]]
+
+-- TODO
+--TEST [[
+-----@class A
+--local A
+--
+-----@return A
+--function A:x() end
+--
+-----@class B: A
+--local <!B!>
+--
+-----@return B
+--function B:x() end
+--
+-----@type B
+--local t
+--
+--local <!<?v?>!> = t.x()
+--]]
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index 3dfd6518..f95c0bad 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -1506,3 +1506,19 @@ TEST [[
TEST [[
---@type fun(xxx, yyy, ...): boolean
]]
+
+TEST [[
+local <!x!>
+
+return {
+ x = 1,
+}
+]]
+
+TEST [[
+---@class A #1
+]]
+
+TEST [[
+---@class A 1
+]]
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 284ca023..d62bc607 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -912,12 +912,12 @@ for _, a in ipairs(v) do
end
]]
-TEST 'number' [[
----@param x number
-local f
-
-f = function (<?x?>) end
-]]
+--TEST 'number' [[
+-----@param x number
+--local f
+--
+--f = function (<?x?>) end
+--]]
TEST 'integer' [[
--- @class Emit
@@ -1053,3 +1053,15 @@ f {
}
}
]]
+
+TEST 'integer' [[
+for <?i?> = a, b, c do end
+]]
+
+TEST 'number' [[
+---@param x number
+function F(<?x?>) end
+
+---@param x boolean
+function F(x) end
+]]