summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/code_action/init.lua6
-rw-r--r--test/command/auto-require.lua8
-rw-r--r--test/completion/init.lua10
-rw-r--r--test/crossfile/completion.lua8
-rw-r--r--test/definition/init.lua8
-rw-r--r--test/diagnostics/init.lua8
-rw-r--r--test/document_symbol/init.lua6
-rw-r--r--test/full/example.lua8
-rw-r--r--test/highlight/init.lua6
-rw-r--r--test/hover/init.lua6
-rw-r--r--test/references/init.lua6
-rw-r--r--test/rename/init.lua10
-rw-r--r--test/signature/init.lua6
-rw-r--r--test/type_formatting/init.lua6
-rw-r--r--test/type_inference/init.lua10
15 files changed, 56 insertions, 56 deletions
diff --git a/test/code_action/init.lua b/test/code_action/init.lua
index 67528d59..2329ce4c 100644
--- a/test/code_action/init.lua
+++ b/test/code_action/init.lua
@@ -39,11 +39,11 @@ end
function TEST(script)
return function (expect)
local newScript, catched = catch(script, '?')
- files.setText('', newScript)
- local results = core('', catched['?'][1][1], catched['?'][1][2])
+ files.setText(TESTURI, newScript)
+ local results = core(TESTURI, catched['?'][1][1], catched['?'][1][2])
assert(results)
assert(eq(expect, results))
- files.remove('')
+ files.remove(TESTURI)
end
end
diff --git a/test/command/auto-require.lua b/test/command/auto-require.lua
index 38cc0012..c55fd334 100644
--- a/test/command/auto-require.lua
+++ b/test/command/auto-require.lua
@@ -19,12 +19,12 @@ end
function TEST(text)
return function (name)
return function (expect)
- files.setText('', text)
+ files.setText(TESTURI, text)
EditResult = nil
- local row, fmt = findInsertRow('')
- applyAutoRequire('', row, name, name, fmt)
+ local row, fmt = findInsertRow(TESTURI)
+ applyAutoRequire(TESTURI, row, name, name, fmt)
assert(util.equal(EditResult, expect))
- files.remove('')
+ files.remove(TESTURI)
end
end
end
diff --git a/test/completion/init.lua b/test/completion/init.lua
index 4ae185ca..1ac7fd4b 100644
--- a/test/completion/init.lua
+++ b/test/completion/init.lua
@@ -68,8 +68,8 @@ function TEST(script)
---@diagnostic disable: await-in-sync
local newScript, catched = catch(script, '?')
- files.setText('', newScript)
- local state = files.getState('')
+ files.setText(TESTURI, newScript)
+ local state = files.getState(TESTURI)
local inputPos = catched['?'][1][2]
if ContinueTyping then
local triggerCharacter = script:sub(inputPos - 1, inputPos - 1)
@@ -77,7 +77,7 @@ function TEST(script)
or triggerCharacter:find '%w_' then
triggerCharacter = nil
end
- core.completion('', inputPos, triggerCharacter)
+ core.completion(TESTURI, inputPos, triggerCharacter)
end
local offset = guide.positionToOffset(state, inputPos)
local triggerCharacter = script:sub(offset, offset)
@@ -85,7 +85,7 @@ function TEST(script)
or triggerCharacter:find '%w_' then
triggerCharacter = nil
end
- local result = core.completion('', inputPos, triggerCharacter)
+ local result = core.completion(TESTURI, inputPos, triggerCharacter)
if not expect then
assert(result == nil)
@@ -131,7 +131,7 @@ function TEST(script)
assert(eq(expect, result))
end
end
- files.remove('')
+ files.remove(TESTURI)
end
end
diff --git a/test/crossfile/completion.lua b/test/crossfile/completion.lua
index 4e573c0e..24a5f6c9 100644
--- a/test/crossfile/completion.lua
+++ b/test/crossfile/completion.lua
@@ -376,7 +376,7 @@ config.set(nil, 'Lua.runtime.path', {
TEST {
{
- path = 'D:/xxxx/1.lua',
+ path = 'tt/xxxx/1.lua',
content = '',
},
{
@@ -386,7 +386,7 @@ TEST {
},
completion = {
{
- label = 'D:.xxxx',
+ label = 'tt.xxxx',
kind = CompletionItemKind.File,
textEdit = EXISTS,
},
@@ -402,12 +402,12 @@ config.set(nil, 'Lua.runtime.path', originRuntimePath)
local originRuntimePath = config.get(nil, 'Lua.runtime.path')
config.set(nil, 'Lua.runtime.path', {
- 'D:/?/1.lua',
+ 'tt/?/1.lua',
})
TEST {
{
- path = 'D:/xxxx/1.lua',
+ path = 'tt/xxxx/1.lua',
content = '',
},
{
diff --git a/test/definition/init.lua b/test/definition/init.lua
index 3badaadf..7e0a7989 100644
--- a/test/definition/init.lua
+++ b/test/definition/init.lua
@@ -24,14 +24,14 @@ end
function TEST(script)
local newScript, catched = catch(script, '!?')
- files.setText('', newScript)
+ files.setText(TESTURI, newScript)
- local results = core('', catched['?'][1][1])
+ local results = core(TESTURI, catched['?'][1][1])
if results then
local positions = {}
for i, result in ipairs(results) do
if not vm.isMetaFile(result.uri) then
- positions[i] = { result.target.start, result.target.finish }
+ positions[#positions+1] = { result.target.start, result.target.finish }
end
end
assert(founded(catched['!'], positions))
@@ -39,7 +39,7 @@ function TEST(script)
assert(#catched['!'] == 0)
end
- files.remove('')
+ files.remove(TESTURI)
end
require 'definition.local'
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index 2c5dba11..2d2374a5 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -29,11 +29,11 @@ end
---@diagnostic disable: await-in-sync
function TEST(script, ...)
local newScript, catched = catch(script, '!')
- files.setText('', newScript)
- files.open('')
+ files.setText(TESTURI, newScript)
+ files.open(TESTURI)
local origins = {}
local results = {}
- core('', false, function (result)
+ core(TESTURI, false, function (result)
results[#results+1] = { result.start, result.finish }
origins[#origins+1] = result
end)
@@ -46,7 +46,7 @@ function TEST(script, ...)
assert(#catched['!'] == 0)
end
- files.remove('')
+ files.remove(TESTURI)
end
require 'diagnostics.common'
diff --git a/test/document_symbol/init.lua b/test/document_symbol/init.lua
index 66babc9b..157ba372 100644
--- a/test/document_symbol/init.lua
+++ b/test/document_symbol/init.lua
@@ -48,11 +48,11 @@ end
---@diagnostic disable: await-in-sync
function TEST(script)
return function (expect)
- files.setText('', script)
- local result = core('')
+ files.setText(TESTURI, script)
+ local result = core(TESTURI)
assert(eq(expect, result))
checkArcoss(result)
- files.remove('')
+ files.remove(TESTURI)
end
end
diff --git a/test/full/example.lua b/test/full/example.lua
index 7740d23c..de32d60b 100644
--- a/test/full/example.lua
+++ b/test/full/example.lua
@@ -51,15 +51,15 @@ local function testIfExit(path)
local max = 100
local need
for i = 1, max do
- files.open('')
- files.setText('', buf)
- diag('', false, function () end)
+ files.open(TESTURI)
+ files.setText(TESTURI, buf)
+ diag(TESTURI, false, function () end)
local passed = os.clock() - clock
if passed >= 1.0 or i == max then
need = passed / i
break
end
- files.remove('')
+ files.remove(TESTURI)
end
print(('基准诊断测试[%s]单次耗时:%.10f'):format(path:filename():string(), need))
end
diff --git a/test/highlight/init.lua b/test/highlight/init.lua
index 0cca79f1..399012a8 100644
--- a/test/highlight/init.lua
+++ b/test/highlight/init.lua
@@ -21,18 +21,18 @@ end
function TEST(script)
local newScript, catched = catch(script, '!')
- files.setText('', newScript)
+ files.setText(TESTURI, newScript)
for _, enter in ipairs(catched['!']) do
local start, finish = enter[1], enter[2]
local pos = (start + finish) // 2
- local positions = core('', pos)
+ local positions = core(TESTURI, pos)
local results = {}
for _, position in ipairs(positions) do
results[#results+1] = { position.start, position.finish }
end
assert(founded(catched['!'], results))
end
- files.remove('')
+ files.remove(TESTURI)
end
TEST [[
diff --git a/test/hover/init.lua b/test/hover/init.lua
index 6d58f051..c9e1ecdb 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -9,13 +9,13 @@ rawset(_G, 'TEST', true)
function TEST(script)
return function (expect)
local newScript, catched = catch(script, '?')
- files.setText('', newScript)
- local hover = core.byUri('', catched['?'][1][1])
+ files.setText(TESTURI, newScript)
+ local hover = core.byUri(TESTURI, catched['?'][1][1])
assert(hover)
expect = expect:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n')
local label = hover:string():gsub('\r\n', '\n'):match('```lua[\r\n]*(.-)[\r\n]*```')
assert(expect == label)
- files.remove('')
+ files.remove(TESTURI)
end
end
diff --git a/test/references/init.lua b/test/references/init.lua
index 1b1cc73b..eee0ac61 100644
--- a/test/references/init.lua
+++ b/test/references/init.lua
@@ -21,11 +21,11 @@ end
function TEST(script)
local newScript, catched = catch(script, '!?~')
- files.setText('', newScript)
+ files.setText(TESTURI, newScript)
local input = catched['?'] + catched['~']
local expect = catched['!'] + catched['~']
- local results = core('', input[1][1])
+ local results = core(TESTURI, input[1][1])
if results then
local positions = {}
for i, result in ipairs(results) do
@@ -35,7 +35,7 @@ function TEST(script)
else
assert(#expect == 0)
end
- files.remove('')
+ files.remove(TESTURI)
end
require 'references.common'
diff --git a/test/rename/init.lua b/test/rename/init.lua
index 64e3916a..d4252d1e 100644
--- a/test/rename/init.lua
+++ b/test/rename/init.lua
@@ -6,7 +6,7 @@ local guide = require 'parser.guide'
local config = require 'config'
local function replace(text, positions)
- local state = files.getState('')
+ local state = files.getState(TESTURI)
local buf = {}
table.sort(positions, function (a, b)
return a.start < b.start
@@ -26,19 +26,19 @@ end
function TEST(oldName, newName)
return function (oldScript)
return function (expectScript)
- files.setText('', oldScript)
- local state = files.getState('')
+ files.setText(TESTURI, oldScript)
+ local state = files.getState(TESTURI)
local offset = oldScript:find('[^%w_]'..oldName..'[^%w_]')
assert(offset)
local position = guide.offsetToPosition(state, offset)
- local positions = core.rename('', position, newName)
+ local positions = core.rename(TESTURI, position, newName)
local script = oldScript
if positions then
script = replace(script, positions)
end
assert(script == expectScript)
- files.remove('')
+ files.remove(TESTURI)
end
end
end
diff --git a/test/signature/init.lua b/test/signature/init.lua
index 18a0fc30..b78fdaa5 100644
--- a/test/signature/init.lua
+++ b/test/signature/init.lua
@@ -8,8 +8,8 @@ rawset(_G, 'TEST', true)
function TEST(script)
return function (expect)
local newScript, catched1 = catch(script, '?')
- files.setText('', newScript)
- local hovers = core('', catched1['?'][1][1])
+ files.setText(TESTURI, newScript)
+ local hovers = core(TESTURI, catched1['?'][1][1])
if hovers then
assert(#hovers == #expect)
for i, hover in ipairs(hovers) do
@@ -28,7 +28,7 @@ function TEST(script)
else
assert(expect == nil)
end
- files.remove('')
+ files.remove(TESTURI)
end
end
diff --git a/test/type_formatting/init.lua b/test/type_formatting/init.lua
index 08c978b7..4e9ce556 100644
--- a/test/type_formatting/init.lua
+++ b/test/type_formatting/init.lua
@@ -8,15 +8,15 @@ rawset(_G, 'TEST', true)
function TEST(script)
return function(expect)
local newScript, catched = catch(script, '?')
- files.setText('', newScript)
- local edits = core('', catched['?'][1][1], expect.ch)
+ files.setText(TESTURI, newScript)
+ local edits = core(TESTURI, catched['?'][1][1], expect.ch)
if edits then
assert(expect.edits)
assert(util.equal(edits, expect.edits))
else
assert(expect.edits == nil)
end
- files.remove('')
+ files.remove(TESTURI)
end
end
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index f0948b49..43177dc7 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -7,7 +7,7 @@ local vm = require 'vm'
rawset(_G, 'TEST', true)
local function getSource(pos)
- local state = files.getState('')
+ local state = files.getState(TESTURI)
if not state then
return
end
@@ -31,15 +31,15 @@ end
function TEST(wanted)
return function (script)
local newScript, catched = catch(script, '?')
- files.setText('', newScript)
+ files.setText(TESTURI, newScript)
local source = getSource(catched['?'][1][1])
assert(source)
- local result = vm.getInfer(source):view('')
+ local result = vm.getInfer(source):view(TESTURI)
if wanted ~= result then
- vm.getInfer(source):view('')
+ vm.getInfer(source):view(TESTURI)
end
assert(wanted == result)
- files.remove('')
+ files.remove(TESTURI)
end
end