summaryrefslogtreecommitdiff
path: root/test/basic
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-14 19:32:31 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-14 19:32:31 +0800
commit4d1b606cc875803cc07031c63cde351300ea664a (patch)
tree4af8f798f86285b41e376cec1fdf9f65f91f5b01 /test/basic
parent5a43c5f78a9d13b9d18ba58bd45c85e7521d9f08 (diff)
downloadlua-language-server-4d1b606cc875803cc07031c63cde351300ea664a.zip
update
Diffstat (limited to 'test/basic')
-rw-r--r--test/basic/noder.lua24
1 files changed, 11 insertions, 13 deletions
diff --git a/test/basic/noder.lua b/test/basic/noder.lua
index bc572a4c..4c0a1620 100644
--- a/test/basic/noder.lua
+++ b/test/basic/noder.lua
@@ -2,6 +2,7 @@ local noder = require 'core.noder'
local files = require 'files'
local util = require 'utility'
local guide = require 'parser.guide'
+local catch = require 'catch'
local function getSource(pos)
local ast = files.getState('')
@@ -30,12 +31,9 @@ local CARE = {}
local function TEST(script)
return function (expect)
files.removeAll()
- local start = script:find('<?', 1, true)
- local finish = script:find('?>', 1, true)
- local pos = (start + finish) // 2 + 1
- local newScript = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
+ local newScript, catched = catch(script, '?')
files.setText('', newScript)
- local source = getSource(pos)
+ local source = getSource(catched[1][1])
assert(source)
local result = {
id = noder.getID(source),
@@ -53,21 +51,21 @@ CARE['id'] = true
TEST [[
local <?x?>
]] {
- id = 'l:9',
+ id = 'l:6',
}
TEST [[
local x
print(<?x?>)
]] {
- id = 'l:7',
+ id = 'l:6',
}
TEST [[
local x
<?x?> = 1
]] {
- id = 'l:7',
+ id = 'l:6',
}
TEST [[
@@ -86,14 +84,14 @@ TEST [[
local x
print(x.y.<?z?>)
]] {
- id = 'l:7|.y|.z',
+ id = 'l:6|.y|.z',
}
TEST [[
local x
function x:<?f?>() end
]] {
- id = 'l:7|.f',
+ id = 'l:6|.f',
}
TEST [[
@@ -113,7 +111,7 @@ TEST [[
<?x?> = 1,
}
]] {
- id = 't:1|.x',
+ id = 't:0|.x',
}
TEST [[
@@ -134,12 +132,12 @@ TEST [[
::<?label?>::
goto label
]] {
- id = 'l:5',
+ id = 'l:2',
}
TEST [[
::label::
goto <?label?>
]] {
- id = 'l:3',
+ id = 'l:2',
}