summaryrefslogtreecommitdiff
path: root/server/test
diff options
context:
space:
mode:
Diffstat (limited to 'server/test')
-rw-r--r--server/test/completion/init.lua6
-rw-r--r--server/test/crossfile/completion.lua4
-rw-r--r--server/test/crossfile/definition.lua6
-rw-r--r--server/test/crossfile/hover.lua6
-rw-r--r--server/test/definition/init.lua8
-rw-r--r--server/test/diagnostics/init.lua6
-rw-r--r--server/test/document_symbol/init.lua20
-rw-r--r--server/test/find_lib/init.lua8
-rw-r--r--server/test/hover/init.lua8
-rw-r--r--server/test/main.lua2
-rw-r--r--server/test/signature/init.lua6
-rw-r--r--server/test/type_inference/init.lua6
-rw-r--r--server/test/vm/example.lua2
-rw-r--r--server/test/vm/init.lua4
14 files changed, 53 insertions, 39 deletions
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index 46544b36..ee4e5f30 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local parser = require 'parser'
local CompletionItemKind = {
@@ -64,9 +64,9 @@ function TEST(script)
local pos = script:find('@', 1, true)
local new_script = script:gsub('@', ' ')
local ast = parser:ast(new_script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result = matcher.completion(vm, pos)
+ local result = core.completion(vm, pos)
if expect then
assert(result)
assert(eq(expect, result))
diff --git a/server/test/crossfile/completion.lua b/server/test/crossfile/completion.lua
index e35874b3..f136a057 100644
--- a/server/test/crossfile/completion.lua
+++ b/server/test/crossfile/completion.lua
@@ -1,7 +1,7 @@
local service = require 'service'
local workspace = require 'workspace'
local fs = require 'bee.filesystem'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -86,7 +86,7 @@ function TEST(data)
local vm = lsp:loadVM(mainUri)
assert(vm)
- local result = matcher.completion(vm, pos)
+ local result = core.completion(vm, pos)
local expect = data.completion
if expect then
assert(result)
diff --git a/server/test/crossfile/definition.lua b/server/test/crossfile/definition.lua
index dfc91c31..8d8c7569 100644
--- a/server/test/crossfile/definition.lua
+++ b/server/test/crossfile/definition.lua
@@ -1,7 +1,7 @@
local service = require 'service'
local workspace = require 'workspace'
local fs = require 'bee.filesystem'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -48,8 +48,8 @@ function TEST(data)
local sourceVM = lsp:getVM(sourceUri)
assert(sourceVM)
local sourcePos = (sourceList[1][1] + sourceList[1][2]) // 2
- local result = matcher.findResult(sourceVM, sourcePos)
- local positions = matcher.definition(sourceVM, result)
+ local result = core.findResult(sourceVM, sourcePos)
+ local positions = core.definition(sourceVM, result)
assert(positions and positions[1])
local start, finish, valueUri = positions[1][1], positions[1][2], positions[1][3]
assert(valueUri == targetUri)
diff --git a/server/test/crossfile/hover.lua b/server/test/crossfile/hover.lua
index 32fd7580..a4479280 100644
--- a/server/test/crossfile/hover.lua
+++ b/server/test/crossfile/hover.lua
@@ -1,7 +1,7 @@
local service = require 'service'
local workspace = require 'workspace'
local fs = require 'bee.filesystem'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -72,8 +72,8 @@ function TEST(data)
local sourceVM = lsp:loadVM(sourceUri)
assert(sourceVM)
local sourcePos = (sourceList[1][1] + sourceList[1][2]) // 2
- local result, source = matcher.findResult(sourceVM, sourcePos)
- local hover = matcher.hover(result, source, lsp)
+ local result, source = core.findResult(sourceVM, sourcePos)
+ local hover = core.hover(result, source, lsp)
assert(hover)
if data.hover.description then
data.hover.description = data.hover.description:gsub('%$ROOT%$', ws:uriEncode(ROOT):gsub('%%', '%%%%'))
diff --git a/server/test/definition/init.lua b/server/test/definition/init.lua
index 38201435..5ed638dd 100644
--- a/server/test/definition/init.lua
+++ b/server/test/definition/init.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local parser = require 'parser'
rawset(_G, 'TEST', true)
@@ -41,11 +41,11 @@ function TEST(script)
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast = parser:ast(new_script)
assert(ast)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result = matcher.findResult(vm, pos)
- local positions = matcher.definition(vm, result)
+ local result = core.findResult(vm, pos)
+ local positions = core.definition(vm, result)
if positions then
assert(founded(target, positions))
else
diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua
index 57a54e4d..9d9c7424 100644
--- a/server/test/diagnostics/init.lua
+++ b/server/test/diagnostics/init.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local parser = require 'parser'
rawset(_G, 'TEST', true)
@@ -41,9 +41,9 @@ function TEST(script)
local ast = parser:ast(new_script)
assert(ast)
local lines = parser:lines(new_script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local datas = matcher.diagnostics(vm, lines, 'test')
+ local datas = core.diagnostics(vm, lines, 'test')
local results = {}
for i, data in ipairs(datas) do
results[i] = { data.start, data.finish }
diff --git a/server/test/document_symbol/init.lua b/server/test/document_symbol/init.lua
index 5b1ed397..684e5449 100644
--- a/server/test/document_symbol/init.lua
+++ b/server/test/document_symbol/init.lua
@@ -1,5 +1,5 @@
local parser = require 'parser'
-local matcher = require 'matcher'
+local core = require 'core'
local SymbolKind = {
File = 1,
@@ -63,9 +63,9 @@ end
function TEST(script)
return function (expect)
local ast = parser:ast(script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result = matcher.documentSymbol(vm)
+ local result = core.documentSymbol(vm)
assert(eq(expect, result))
end
end
@@ -83,3 +83,17 @@ end
selectionRange = {16, 16},
}
}
+
+TEST [[
+return function ()
+end
+]]
+{
+ [1] = {
+ name = '',
+ detail = 'function f()',
+ kind = SymbolKind.Function,
+ range = {8, 22},
+ selectionRange = {8, 8},
+ }
+}
diff --git a/server/test/find_lib/init.lua b/server/test/find_lib/init.lua
index 63654b19..e55b33af 100644
--- a/server/test/find_lib/init.lua
+++ b/server/test/find_lib/init.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local parser = require 'parser'
rawset(_G, 'TEST', true)
@@ -11,10 +11,10 @@ function TEST(fullkey)
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast = parser:ast(new_script)
assert(ast)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result = matcher.findResult(vm, pos)
- local _, name = matcher.findLib(result)
+ local result = core.findResult(vm, pos)
+ local _, name = core.findLib(result)
assert(name == fullkey)
end
end
diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua
index 17913039..01c571d8 100644
--- a/server/test/hover/init.lua
+++ b/server/test/hover/init.lua
@@ -1,5 +1,5 @@
local parser = require 'parser'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -10,10 +10,10 @@ function TEST(script)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast = parser:ast(new_script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result, source = matcher.findResult(vm, pos)
- local hover = matcher.hover(result, source)
+ local result, source = core.findResult(vm, pos)
+ local hover = core.hover(result, source)
if expect then
assert(hover)
expect = expect:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n')
diff --git a/server/test/main.lua b/server/test/main.lua
index b7161870..cb01ca1f 100644
--- a/server/test/main.lua
+++ b/server/test/main.lua
@@ -23,7 +23,7 @@ local function main()
print(('测试[%s]用时[%.3f]'):format(name, os.clock() - clock))
end
- test 'matcher'
+ test 'core'
test 'vm'
test 'definition'
diff --git a/server/test/signature/init.lua b/server/test/signature/init.lua
index 81e002e6..86b5f05a 100644
--- a/server/test/signature/init.lua
+++ b/server/test/signature/init.lua
@@ -1,5 +1,5 @@
local parser = require 'parser'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -8,9 +8,9 @@ function TEST(script)
local pos = script:find('@', 1, true) + 1
local new_script = script:gsub('@', '')
local ast = parser:ast(new_script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local hovers = matcher.signature(vm, pos)
+ local hovers = core.signature(vm, pos)
if hovers then
local hover = hovers[#hovers]
diff --git a/server/test/type_inference/init.lua b/server/test/type_inference/init.lua
index 9f5887f1..47e94760 100644
--- a/server/test/type_inference/init.lua
+++ b/server/test/type_inference/init.lua
@@ -1,5 +1,5 @@
local parser = require 'parser'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -10,9 +10,9 @@ function TEST(res)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast = parser:ast(new_script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result = matcher.findResult(vm, pos)
+ local result = core.findResult(vm, pos)
assert(result)
assert(res == result.value.type)
end
diff --git a/server/test/vm/example.lua b/server/test/vm/example.lua
index 39ef4f4b..3b040a32 100644
--- a/server/test/vm/example.lua
+++ b/server/test/vm/example.lua
@@ -1 +1 @@
-TEST(io.load(ROOT / 'src' / 'matcher' / 'vm.lua'))
+TEST(io.load(ROOT / 'src' / 'core' / 'vm.lua'))
diff --git a/server/test/vm/init.lua b/server/test/vm/init.lua
index a95373f1..6e7dc3ac 100644
--- a/server/test/vm/init.lua
+++ b/server/test/vm/init.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local parser = require 'parser'
rawset(_G, 'TEST', true)
@@ -6,7 +6,7 @@ rawset(_G, 'TEST', true)
function TEST(script)
local ast = parser:ast(script)
assert(ast)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
local results = vm.results
assert(results)