From cb1a412bc7c205c73aec3ef2b1f8f8baf4564fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 20 Aug 2021 17:52:06 +0800 Subject: stash --- test/crossfile/hover.lua | 21 +++++++++------------ test/hover/init.lua | 37 ++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 04f7cc02..08773959 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -68,14 +68,8 @@ function TEST(expect) local sourcePos = (sourceList[1][1] + sourceList[1][2]) // 2 local hover = core.byUri(sourceUri, sourcePos) assert(hover) - if hover.label then - hover.label = hover.label:gsub('\r\n', '\n') - end - if hover.description then - hover.description = tostring(hover.description) - end - assert(eq(hover.label, expect.hover.label)) - assert(eq(hover.description, expect.hover.description)) + hover = tostring(hover):gsub('\r\n', '\n') + assert(eq(hover, expect.hover)) end TEST { @@ -87,10 +81,13 @@ TEST { path = 'b.lua', content = 'require ', }, - hover = { - label = '1 个字节', - description = [[* [a.lua](file:///a.lua) (搜索路径: `?.lua`)]], - } + hover = [[ +```lua +1 个字节 +``` + +--- +* [a.lua](file:///a.lua) (搜索路径: `?.lua`)]], } if require 'bee.platform'.OS == 'Windows' then diff --git a/test/hover/init.lua b/test/hover/init.lua index 62db4b6d..3f07ea30 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -1,8 +1,25 @@ -local core = require 'core.hover' -local files = require 'files' +local core = require 'core.hover' +local findSource = require 'core.find-source' +local getLabel = require 'core.hover.label' +local files = require 'files' rawset(_G, 'TEST', true) +local accept = { + ['local'] = true, + ['setlocal'] = true, + ['getlocal'] = true, + ['setglobal'] = true, + ['getglobal'] = true, + ['field'] = true, + ['method'] = true, + ['string'] = true, + ['number'] = true, + ['integer'] = true, + ['doc.type.name'] = true, + ['function'] = true, +} + function TEST(script) return function (expect) files.removeAll() @@ -14,7 +31,7 @@ function TEST(script) local hover = core.byUri('', pos) assert(hover) expect = expect:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n') - local label = hover.label:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n') + local label = tostring(hover):match('```lua[\r\n]*(.-)[\r\n]*```'):gsub('\r\n', '\n') assert(expect == label) end end @@ -571,9 +588,7 @@ end () ]] [[ -(3 个定义,2 个原型) -(2) function F(a: any) -(1) function F(b: any) +function F(a: any) ]] -- 不根据参数推断 @@ -1278,9 +1293,7 @@ function f(x, y, z) end print() ]] [[ -(2 个定义,2 个原型) -(1) function f(x: number, y: boolean, z: string) -(1) function f(y: boolean) +function f(x: number, y: boolean, z: string) ]] TEST [[ @@ -1397,8 +1410,7 @@ local t = {} function t.() end ]] [[ -(2 个定义,1 个原型) -(2) function c.f() +function c.f() ]] TEST [[ @@ -1409,8 +1421,7 @@ t = {} function t.() end ]] [[ -(2 个定义,1 个原型) -(2) function t.f() +function t.f() ]] TEST [[ -- cgit v1.2.3