summaryrefslogtreecommitdiff
path: root/test/references
diff options
context:
space:
mode:
authorunknown <luoxingyue@cn.net.ntes>2021-09-27 11:01:28 +0800
committerunknown <luoxingyue@cn.net.ntes>2021-09-27 11:01:28 +0800
commit426e5d48378fb1679c13fc8923967507d2750871 (patch)
tree3176c3f32289486f75353cd02a6750c4ae672bee /test/references
parentc1d8340fd6ce6703b9abd187367f8093e01d5f3a (diff)
parent1f0a2d0e9283a4cb7f7b3fc72258eb1c5ba4e5dd (diff)
downloadlua-language-server-426e5d48378fb1679c13fc8923967507d2750871.zip
Merge branch 'master' into ar/typecheck
Diffstat (limited to 'test/references')
-rw-r--r--test/references/common.lua24
-rw-r--r--test/references/init.lua27
2 files changed, 9 insertions, 42 deletions
diff --git a/test/references/common.lua b/test/references/common.lua
index 3669486b..4245a79d 100644
--- a/test/references/common.lua
+++ b/test/references/common.lua
@@ -221,30 +221,12 @@ TEST [[
---@class A
local a
-a.<!xxx!> = 1
-
---@type A
local b
-b.xxx = 1 -- Dont search this
-
----@class C: A
-local c
-print(c.<?xxx?>)
-]]
-
-TEST [[
----@class A
-local <?a?>
-
----@class B
-local b
-
-b.xx = 1 -- Dont search this
-
----@type B
+---@type A
local c
----@type A
-c.<!xx!> = 1
+b.<?x?> = 1
+c.<!x!> = 1
]]
diff --git a/test/references/init.lua b/test/references/init.lua
index 2fba92e5..351c80b6 100644
--- a/test/references/init.lua
+++ b/test/references/init.lua
@@ -1,19 +1,6 @@
local core = require 'core.reference'
local files = require 'files'
-
-local function catch_target(script)
- local list = {}
- local cur = 1
- while true do
- local start, finish = script:find('<[!?].-[!?]>', cur)
- if not start then
- break
- end
- list[#list+1] = { start + 2, finish - 2 }
- cur = finish + 1
- end
- return list
-end
+local catch = require 'catch'
local function founded(targets, results)
if #targets ~= #results then
@@ -33,14 +20,12 @@ end
function TEST(script)
files.removeAll()
- local expect = catch_target(script)
- local start = script:find('<[?~]')
- local finish = script:find('[?~]>')
- local pos = (start + finish) // 2 + 1
- local new_script = script:gsub('<[!?~]', ' '):gsub('[!?~]>', ' ')
- files.setText('', new_script)
+ local newScript, catched = catch(script, '!?~')
+ files.setText('', newScript)
- local results = core('', pos)
+ local input = catched['?'] + catched['~']
+ local expect = catched['!'] + catched['?']
+ local results = core('', input[1][1])
if results then
local positions = {}
for i, result in ipairs(results) do