summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoruhziel <uhziel@gmail.com>2020-12-24 20:04:23 +0800
committerGitHub <noreply@github.com>2020-12-24 20:04:23 +0800
commit01688aa0248388feb0fbd0c618f2f02bc3a5de96 (patch)
tree88defe2e8d8ea8dc80bf29c9955507fe5d16bc43 /test
parent0161e51df7f8aed8406e964316eb98926a52c023 (diff)
parent49226612d1b557401a486df3e65fc138bec62d63 (diff)
downloadlua-language-server-01688aa0248388feb0fbd0c618f2f02bc3a5de96.zip
Merge branch 'master' into generic-name-string-literal
Diffstat (limited to 'test')
-rw-r--r--test/completion/init.lua24
-rw-r--r--test/crossfile/definition.lua25
-rw-r--r--test/definition/bug.lua23
-rw-r--r--test/definition/luadoc.lua28
-rw-r--r--test/diagnostics/init.lua25
-rw-r--r--test/full/example.lua2
-rw-r--r--test/signature/init.lua16
7 files changed, 126 insertions, 17 deletions
diff --git a/test/completion/init.lua b/test/completion/init.lua
index 662df84e..69ca83c3 100644
--- a/test/completion/init.lua
+++ b/test/completion/init.lua
@@ -1071,10 +1071,10 @@ function$
{
label = 'function ()',
kind = define.CompletionItemKind.Snippet,
- insertText = [[
-function $1($2)
- $0
-end]],
+ insertText = "\z
+function $1($2)\
+\t$0\
+end",
},
}
@@ -1089,10 +1089,10 @@ local t = function$
{
label = 'function ()',
kind = define.CompletionItemKind.Snippet,
- insertText = [[
-function ($1)
- $0
-end]],
+ insertText = "\z
+function ($1)\
+\t$0\
+end",
},
}
Cared['insertText'] = false
@@ -1964,10 +1964,10 @@ f($)
{
label = 'fun(x: number, y: number):string',
kind = define.CompletionItemKind.Function,
- insertText = [[
-function (${1:x}, ${2:y})
- $0
-end]],
+ insertText = "\z
+function (${1:x}, ${2:y})\
+\t$0\
+end",
},
}
Cared['insertText'] = nil
diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua
index 839a3e89..30d796c8 100644
--- a/test/crossfile/definition.lua
+++ b/test/crossfile/definition.lua
@@ -615,3 +615,28 @@ TEST {
]]
},
}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ local lib = {}
+
+ function lib:fn1()
+ return self
+ end
+
+ function lib:<!fn2!>()
+ end
+
+ return lib:fn1()
+ ]]
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local app = require 'a'
+ print(app.<?fn2?>)
+ ]]
+ },
+}
diff --git a/test/definition/bug.lua b/test/definition/bug.lua
index e7158848..8c446123 100644
--- a/test/definition/bug.lua
+++ b/test/definition/bug.lua
@@ -146,3 +146,26 @@ t.<!f1!> = t.f2
print(t.<?f2?>)
]]
+
+TEST [[
+---@type string
+string.xx = ''
+string.xx:<?format?>()
+]]
+
+TEST [[
+---@class Foo
+Foo = {}
+function Foo:Constructor()
+ self.<!bar1!> = 1
+end
+
+---@class Foo2: Foo
+Foo2 = {}
+function Foo2:Constructor()
+end
+
+---@type Foo2
+local v
+v.<?bar1?>
+]]
diff --git a/test/definition/luadoc.lua b/test/definition/luadoc.lua
index 31134135..4a23b2ac 100644
--- a/test/definition/luadoc.lua
+++ b/test/definition/luadoc.lua
@@ -169,3 +169,31 @@ end
AAAA.a.<?SSDF?>
]]
+
+TEST [[
+---@class Cat
+local <!m!> ---hahaha
+---@class Dog
+local m2
+---@type Cat
+local <?<!v!>?>
+]]
+
+TEST [[
+---@class Cat
+local <!m!> --hahaha
+---@class Dog
+local m2
+---@type Cat
+local <?<!v!>?>
+]]
+
+TEST [[
+---@class Cat
+ local <!m!> ---hahaha
+
+ ---@class Dog
+ local m2
+ ---@type Cat
+ local <?<!v!>?>
+]]
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index 5fdc3891..c593968e 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -76,7 +76,7 @@ local <!x!>
]]
TEST [[
-local x <close>
+local x <close> = print
]]
TEST [[
@@ -319,6 +319,16 @@ return [[
]]
]=]
+config.config.diagnostics.disable['close-non-object'] = true
+TEST [[
+local _ <close> = function () end
+]]
+
+config.config.diagnostics.disable['close-non-object'] = nil
+TEST [[
+local _ <close> = <!1!>
+]]
+
config.config.diagnostics.disable['unused-local'] = true
TEST [[
local f = <!function () end!>
@@ -824,10 +834,6 @@ TEST [[
local t
]]
-TEST [[
-local _ <close> = function () end
-]]
-
-- checkUndefinedField 通用
TEST [[
---@class Foo
@@ -947,6 +953,15 @@ v2:method2() -- 这个感觉实际应该报错更合适
]]
TEST [[
+---@type table
+T1 = {}
+print(T1.f1)
+---@type table*
+T2 = {}
+print(T2.<!f2!>)
+]]
+
+TEST [[
---@generic T
---@param arg1 T
---@return T
diff --git a/test/full/example.lua b/test/full/example.lua
index b19f0485..57d02c38 100644
--- a/test/full/example.lua
+++ b/test/full/example.lua
@@ -52,6 +52,8 @@ local function testIfExit(path)
print(('基准诊断测试[%s]单次耗时:%.10f'):format(path:filename():string(), need))
end
end
+
+require 'tracy' .enable()
testIfExit(ROOT / 'test' / 'example' / 'vm.txt')
testIfExit(ROOT / 'test' / 'example' / 'largeGlobal.txt')
testIfExit(ROOT / 'test' / 'example' / 'guide.txt')
diff --git a/test/signature/init.lua b/test/signature/init.lua
index 765e0814..fca995bd 100644
--- a/test/signature/init.lua
+++ b/test/signature/init.lua
@@ -174,3 +174,19 @@ function Foo(param01: any, param02: any)
]],
arg = {14, 25},
}
+
+TEST [[
+function f1(a, b)
+end
+
+function f2(c, d)
+end
+
+f2(f1(),$)
+]]
+{
+ label = [[
+function f2(c: any, d: any)
+]],
+ arg = {21, 26},
+}