summaryrefslogtreecommitdiff
path: root/server-beta/test/diagnostics
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-04 17:28:42 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-04 17:28:42 +0800
commit137ede024f4ddeac7c602351371447cd6cf36091 (patch)
treebff1d78ec63125294bf9337a192902f706db731a /server-beta/test/diagnostics
parenteb1fffc9ddfaa804973b1e05c7001d84194ce5a6 (diff)
downloadlua-language-server-137ede024f4ddeac7c602351371447cd6cf36091.zip
更新诊断
Diffstat (limited to 'server-beta/test/diagnostics')
-rw-r--r--server-beta/test/diagnostics/init.lua239
1 files changed, 117 insertions, 122 deletions
diff --git a/server-beta/test/diagnostics/init.lua b/server-beta/test/diagnostics/init.lua
index bd922825..b0438eb2 100644
--- a/server-beta/test/diagnostics/init.lua
+++ b/server-beta/test/diagnostics/init.lua
@@ -1,8 +1,7 @@
-local core = require 'core'
-local buildVM = require 'vm'
-local parser = require 'parser'
-local service = require 'service'
-local config = require 'config'
+local core = require 'core.diagnostics'
+local files = require 'files'
+local config = require 'config'
+local util = require 'utility'
rawset(_G, 'TEST', true)
@@ -48,14 +47,10 @@ local function founded(targets, results)
end
function TEST(script, ...)
+ files.removeAll()
local new_script, target = catch_target(script, ...)
- local lsp = service()
- local ast = parser:parse(new_script, 'lua', 'Lua 5.3')
- assert(ast)
- local lines = parser:lines(new_script)
- local vm = buildVM(ast, lsp, 'test')
- assert(vm)
- local datas = core.diagnostics(vm, lines, 'test')
+ files.setText('', new_script)
+ local datas = core('')
local results = {}
for i, data in ipairs(datas) do
results[i] = { data.start, data.finish }
@@ -63,7 +58,7 @@ function TEST(script, ...)
if results[1] then
if not founded(target, results) then
- error(('%s\n%s'):format(table.dump(target), table.dump(results)))
+ error(('%s\n%s'):format(util.dump(target), util.dump(results)))
end
else
assert(#target == 0)
@@ -402,108 +397,108 @@ local <!t!> = {}
t[1] = 1
]]
-TEST [[
----@class <!Class!>
----@class <!Class!>
-]]
-
-TEST [[
----@class A : <!B!>
-]]
-
-TEST [[
----@class <!A : B!>
----@class <!B : C!>
----@class <!C : D!>
----@class <!D : A!>
-]]
-
-TEST [[
----@class A : B
----@class B : C
----@class C : D
----@class D
-]]
-
-TEST [[
----@type <!A!>
-]]
-
-TEST [[
----@class A
----@type A|<!B!>|<!C!>
-]]
-
-TEST [[
----@class AAA
----@alias B AAA
-
----@type B
-]]
-
-TEST [[
----@alias B <!AAA!>
-]]
-
-TEST [[
----@class <!A!>
----@class B
----@alias <!A B!>
-]]
-
-TEST [[
----@param x <!Class!>
-]]
-
-TEST [[
----@class Class
----@param <!y!> Class
-local function f(x)
- return x
-end
-f()
-]]
-
-TEST [[
----@class Class
----@param <!y!> Class
-function F(x)
- return x
-end
-F()
-]]
-
-TEST [[
----@class Class
----@param <!x!> Class
----@param y Class
----@param <!x!> Class
-local function f(x, y)
- return x, y
-end
-f()
-]]
-
-TEST [[
----@field <!x Class!>
----@class Class
-]]
-
-TEST [[
----@class Class
----@field <!x!> Class
----@field <!x!> Class
-]]
-
-TEST [[
----@class Class : any
-]]
-
-TEST [[
----@type fun(a: integer)
-local f
-f()
-]]
+--TEST [[
+-----@class <!Class!>
+-----@class <!Class!>
+--]]
+--
+--TEST [[
+-----@class A : <!B!>
+--]]
+--
+--TEST [[
+-----@class <!A : B!>
+-----@class <!B : C!>
+-----@class <!C : D!>
+-----@class <!D : A!>
+--]]
+--
+--TEST [[
+-----@class A : B
+-----@class B : C
+-----@class C : D
+-----@class D
+--]]
+--
+--TEST [[
+-----@type <!A!>
+--]]
+--
+--TEST [[
+-----@class A
+-----@type A|<!B!>|<!C!>
+--]]
+--
+--TEST [[
+-----@class AAA
+-----@alias B AAA
+--
+-----@type B
+--]]
+--
+--TEST [[
+-----@alias B <!AAA!>
+--]]
+--
+--TEST [[
+-----@class <!A!>
+-----@class B
+-----@alias <!A B!>
+--]]
+--
+--TEST [[
+-----@param x <!Class!>
+--]]
+--
+--TEST [[
+-----@class Class
+-----@param <!y!> Class
+--local function f(x)
+-- return x
+--end
+--f()
+--]]
+--
+--TEST [[
+-----@class Class
+-----@param <!y!> Class
+--function F(x)
+-- return x
+--end
+--F()
+--]]
+--
+--TEST [[
+-----@class Class
+-----@param <!x!> Class
+-----@param y Class
+-----@param <!x!> Class
+--local function f(x, y)
+-- return x, y
+--end
+--f()
+--]]
+--
+--TEST [[
+-----@field <!x Class!>
+-----@class Class
+--]]
+--
+--TEST [[
+-----@class Class
+-----@field <!x!> Class
+-----@field <!x!> Class
+--]]
+--
+--TEST [[
+-----@class Class : any
+--]]
+--
+--TEST [[
+-----@type fun(a: integer)
+--local f
+--f()
+--]]
TEST [[
local x <const> = 1
@@ -531,13 +526,13 @@ local x
x = x or -1
]]
---TEST [[
---local t = {}
---function t:<!a!>()
---end
---function t:<!a!>()
---end
---]]
+TEST [[
+local t = {}
+function t:<!a!>()
+end
+function t:<!a!>()
+end
+]]
TEST [[
local t = {}