summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-05-07 15:24:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-05-07 15:24:22 +0800
commitd948291c63ea17804b37bd4e3e5f123ac63730d9 (patch)
tree4ddd9ede425b0402cb42bc83442b7bd1e248bc42 /test
parentdc4c7983dc42e9aca00e69a3e709e2f5b6415427 (diff)
downloadlua-language-server-d948291c63ea17804b37bd4e3e5f123ac63730d9.zip
stash
Diffstat (limited to 'test')
-rw-r--r--test/completion/init.lua138
1 files changed, 32 insertions, 106 deletions
diff --git a/test/completion/init.lua b/test/completion/init.lua
index 1344d3af..ebdac49a 100644
--- a/test/completion/init.lua
+++ b/test/completion/init.lua
@@ -60,6 +60,8 @@ local Cared = {
['deprecated'] = true,
}
+local IgnoreFunction = false
+
function TEST(script)
return function (expect)
files.removeAll()
@@ -86,6 +88,16 @@ function TEST(script)
end
end
end
+ if IgnoreFunction then
+ for i = #result, 1, -1 do
+ local item = result[i]
+ if item.label:find '%('
+ and not item.label:find 'function' then
+ result[i] = result[#result]
+ result[#result] = nil
+ end
+ end
+ end
assert(result)
if expect.include then
expect.include = nil
@@ -217,11 +229,11 @@ ff$
]]
{
{
- label = 'assert(a, b)',
+ label = 'ffff(a, b)',
kind = define.CompletionItemKind.Function,
},
{
- label = 'assert(a, b)',
+ label = 'ffff(a, b)',
kind = define.CompletionItemKind.Snippet,
}
}
@@ -285,11 +297,11 @@ mt:g$
]]
{
{
- label = 'get',
+ label = 'get(a, b)',
kind = define.CompletionItemKind.Method,
},
{
- label = 'get()',
+ label = 'get(a, b)',
kind = define.CompletionItemKind.Snippet,
},
{
@@ -311,15 +323,16 @@ loc$
kind = define.CompletionItemKind.Snippet,
},
{
- label = 'collectgarbage',
+ label = 'collectgarbage(opt, ...)',
kind = define.CompletionItemKind.Function,
},
{
- label = 'collectgarbage()',
+ label = 'collectgarbage(opt, ...)',
kind = define.CompletionItemKind.Snippet,
},
}
+IgnoreFunction = true
TEST [[
do$
]]
@@ -332,50 +345,6 @@ do$
label = 'do .. end',
kind = define.CompletionItemKind.Snippet,
},
- {
- label = 'dofile',
- kind = define.CompletionItemKind.Function,
- },
- {
- label = 'dofile()',
- kind = define.CompletionItemKind.Snippet,
- },
- {
- label = 'load',
- kind = define.CompletionItemKind.Function,
- },
- {
- label = 'load()',
- kind = define.CompletionItemKind.Snippet,
- },
- {
- label = 'loadfile',
- kind = define.CompletionItemKind.Function,
- },
- {
- label = 'loadfile()',
- kind = define.CompletionItemKind.Snippet,
- },
- {
- label = 'loadstring',
- kind = define.CompletionItemKind.Function,
- deprecated = true,
- },
- {
- label = 'loadstring()',
- kind = define.CompletionItemKind.Snippet,
- deprecated = true,
- },
- {
- label = 'module',
- kind = define.CompletionItemKind.Function,
- deprecated = true,
- },
- {
- label = 'module()',
- kind = define.CompletionItemKind.Snippet,
- deprecated = true,
- },
}
TEST [[
@@ -454,6 +423,7 @@ t. $
},
}
+IgnoreFunction = false
TEST [[
t.a = {}
function t:b()
@@ -462,7 +432,7 @@ t:$
]]
{
{
- label = 'b',
+ label = 'b()',
kind = define.CompletionItemKind.Method,
},
{
@@ -507,6 +477,7 @@ TEST 'local s = "a:$"' (nil)
TEST 'debug.$'
(EXISTS)
+IgnoreFunction = true
TEST [[
local xxxx = {
xxyy = 1,
@@ -530,22 +501,6 @@ local t = {
label = 'xxzz',
kind = define.CompletionItemKind.Property,
},
- {
- label = 'next',
- kind = define.CompletionItemKind.Function,
- },
- {
- label = 'next()',
- kind = define.CompletionItemKind.Snippet,
- },
- {
- label = 'xpcall',
- kind = define.CompletionItemKind.Function,
- },
- {
- label = 'xpcall()',
- kind = define.CompletionItemKind.Snippet,
- },
}
TEST [[
@@ -1030,25 +985,10 @@ else$
label = 'ELSE',
kind = define.CompletionItemKind.Enum,
},
- {
- label = 'select',
- kind = define.CompletionItemKind.Function,
- },
- {
- label = 'select()',
- kind = define.CompletionItemKind.Snippet,
- },
- {
- label = 'setmetatable',
- kind = define.CompletionItemKind.Function,
- },
- {
- label = 'setmetatable()',
- kind = define.CompletionItemKind.Snippet,
- },
}
Cared['insertText'] = true
+IgnoreFunction = false
TEST [[
local xpcal
xpcal$
@@ -1059,11 +999,11 @@ xpcal$
kind = define.CompletionItemKind.Variable,
},
{
- label = 'xpcall',
+ label = 'xpcall(f, msgh, arg1, ...)',
kind = define.CompletionItemKind.Function,
},
{
- label = 'xpcall()',
+ label = 'xpcall(f, msgh, arg1, ...)',
kind = define.CompletionItemKind.Snippet,
insertText = EXISTS,
},
@@ -1077,11 +1017,11 @@ mt:f$
]]
{
{
- label = 'f',
+ label = 'f(a, b, c)',
kind = define.CompletionItemKind.Method,
},
{
- label = 'f()',
+ label = 'f(a, b, c)',
kind = define.CompletionItemKind.Snippet,
insertText = 'f(${1:a: any}, ${2:b: any}, ${3:c: any})',
},
@@ -1123,6 +1063,7 @@ end",
},
}
Cared['insertText'] = false
+IgnoreFunction = true
TEST [[
local function f()
@@ -1143,22 +1084,6 @@ end
label = 'elseif .. then',
kind = define.CompletionItemKind.Snippet,
},
- {
- label = 'select',
- kind = define.CompletionItemKind.Function,
- },
- {
- label = 'select()',
- kind = define.CompletionItemKind.Snippet,
- },
- {
- label = 'setmetatable',
- kind = define.CompletionItemKind.Function,
- },
- {
- label = 'setmetatable()',
- kind = define.CompletionItemKind.Snippet,
- },
}
TEST [[
@@ -1259,17 +1184,18 @@ io$
]]
(EXISTS)
+IgnoreFunction = false
TEST [[
loadstring$
]]
{
{
- label = 'loadstring',
+ label = 'loadstring(text, chunkname)',
kind = define.CompletionItemKind.Function,
deprecated = true,
},
{
- label = 'loadstring()',
+ label = 'loadstring(text, chunkname)',
kind = define.CompletionItemKind.Snippet,
deprecated = true,
},
@@ -1293,7 +1219,7 @@ loadstring$
]]
{
{
- label = 'loadstring',
+ label = 'loadstring()',
kind = define.CompletionItemKind.Function,
},
{