diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-08-20 17:52:06 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-08-20 17:52:06 +0800 |
commit | cb1a412bc7c205c73aec3ef2b1f8f8baf4564fb0 (patch) | |
tree | 1175e6ac7bbf1a0747780b8bad6728b8b4da5b00 /test | |
parent | fd86458f11ee270884af730a4344ac000265e64e (diff) | |
download | lua-language-server-cb1a412bc7c205c73aec3ef2b1f8f8baf4564fb0.zip |
stash
Diffstat (limited to 'test')
-rw-r--r-- | test/crossfile/hover.lua | 21 | ||||
-rw-r--r-- | test/hover/init.lua | 37 |
2 files changed, 33 insertions, 25 deletions
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 <?"a"?>', }, - 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 <?F?>() ]] [[ -(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(<?f?>) ]] [[ -(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.<?f?>() end ]] [[ -(2 个定义,1 个原型) -(2) function c.f() +function c.f() ]] TEST [[ @@ -1409,8 +1421,7 @@ t = {} function t.<?f?>() end ]] [[ -(2 个定义,1 个原型) -(2) function t.f() +function t.f() ]] TEST [[ |