summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-27 10:02:23 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-27 10:02:23 +0800
commit60542465a509c5993a04a9fa97d150b39b0e6a1b (patch)
tree53eb7dc0b86ae9a58c29ba24425d51f984a0494b /server
parentb99a2b5fc819d2a519f6bae52b8fbd8babf834d4 (diff)
downloadlua-language-server-60542465a509c5993a04a9fa97d150b39b0e6a1b.zip
加个测试
Diffstat (limited to 'server')
-rw-r--r--server/test/crossfile/references.lua53
1 files changed, 45 insertions, 8 deletions
diff --git a/server/test/crossfile/references.lua b/server/test/crossfile/references.lua
index cc57842c..5f29eb25 100644
--- a/server/test/crossfile/references.lua
+++ b/server/test/crossfile/references.lua
@@ -63,6 +63,12 @@ local function founded(targets, results)
return true
end
+local function compileAll(lsp)
+ while lsp._needCompile[1] do
+ lsp:compileVM(lsp._needCompile[1])
+ end
+end
+
function TEST(data)
local lsp = service()
local ws = workspace(lsp, 'test')
@@ -74,6 +80,10 @@ function TEST(data)
local expect = {}
for _, info in ipairs(data) do
local uri = ws:uriEncode(fs.path(info.path))
+ ws:addFile(uri)
+ end
+ for _, info in ipairs(data) do
+ local uri = ws:uriEncode(fs.path(info.path))
local script = info.content
local list = catch_target(script)
for _, location in ipairs(list) do
@@ -91,18 +101,12 @@ function TEST(data)
end
local newScript = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
lsp:saveText(uri, 1, newScript)
- ws:addFile(uri)
- end
-
- while lsp._needCompile[1] do
- lsp:compileVM(lsp._needCompile[1])
+ compileAll(lsp)
end
local vm = lsp:loadVM(mainUri)
- while lsp._needCompile[1] do
- lsp:compileVM(lsp._needCompile[1])
- end
+ compileAll(lsp)
assert(vm)
local result = core.references(vm, pos, true)
@@ -175,3 +179,36 @@ TEST {
]],
},
}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ return <?function () end?>
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local <!t!> = require 'a'
+ ]],
+ },
+}