diff options
Diffstat (limited to 'test/hover/init.lua')
-rw-r--r-- | test/hover/init.lua | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/test/hover/init.lua b/test/hover/init.lua index 3f07ea30..8058317d 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -1,7 +1,6 @@ local core = require 'core.hover' -local findSource = require 'core.find-source' -local getLabel = require 'core.hover.label' local files = require 'files' +local catch = require 'catch' rawset(_G, 'TEST', true) @@ -23,12 +22,9 @@ local accept = { 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 new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ') - files.setText('', new_script) - local hover = core.byUri('', pos) + local newScript, catched = catch(script, '?') + files.setText('', newScript) + local hover = core.byUri('', catched['?'][1][1]) assert(hover) expect = expect:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n') local label = tostring(hover):match('```lua[\r\n]*(.-)[\r\n]*```'):gsub('\r\n', '\n') @@ -1703,3 +1699,18 @@ print(b.<?x?>) [[ field A.x: any ]] + +TEST [[ +---@class A +---@field x number +---@field y number + +---@type A<string, number> +local <?t?> +]] +[[ +local t: A<string, number> { + x: number, + y: number, +} +]] |