diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/completion/common.lua | 9 | ||||
-rw-r--r-- | test/completion/init.lua | 1 | ||||
-rw-r--r-- | test/crossfile/completion.lua | 109 | ||||
-rw-r--r-- | test/crossfile/definition.lua | 25 | ||||
-rw-r--r-- | test/crossfile/diagnostic.lua | 1 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 3 | ||||
-rw-r--r-- | test/definition/luadoc.lua | 5 | ||||
-rw-r--r-- | test/diagnostics/init.lua | 179 | ||||
-rw-r--r-- | test/document_symbol/init.lua | 1 | ||||
-rw-r--r-- | test/full/example.lua | 1 | ||||
-rw-r--r-- | test/full/projects.lua | 1 | ||||
-rw-r--r-- | test/full/self.lua | 1 | ||||
-rw-r--r-- | test/hover/init.lua | 79 | ||||
-rw-r--r-- | test/signature/init.lua | 3 | ||||
-rw-r--r-- | test/type_inference/init.lua | 5 |
15 files changed, 400 insertions, 23 deletions
diff --git a/test/completion/common.lua b/test/completion/common.lua index 73c6d7e6..15e2cc2a 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -1334,12 +1334,13 @@ end ]] { { - label = 'a, b, c', + label = 'a, b, c, ...', kind = define.CompletionItemKind.Snippet, insertText = [[ a ${1:any} ---@param b ${2:any} ----@param c ${3:any}]], +---@param c ${3:any} +---@param ... ${4:any}]], }, { label = 'self', @@ -1357,6 +1358,10 @@ a ${1:any} label = 'c', kind = define.CompletionItemKind.Interface, }, + { + label = '...', + kind = define.CompletionItemKind.Interface, + }, } TEST [[ diff --git a/test/completion/init.lua b/test/completion/init.lua index 58885149..11d39252 100644 --- a/test/completion/init.lua +++ b/test/completion/init.lua @@ -64,6 +64,7 @@ ContinueTyping = false function TEST(script) return function (expect) + ---@diagnostic disable: await-in-sync files.removeAll() local newScript, catched = catch(script, '?') diff --git a/test/crossfile/completion.lua b/test/crossfile/completion.lua index 172f9d6f..50ebad45 100644 --- a/test/crossfile/completion.lua +++ b/test/crossfile/completion.lua @@ -80,6 +80,7 @@ local function removeMetas(results) util.tableMultiRemove(results, removes) end +---@diagnostic disable: await-in-sync function TEST(data) files.removeAll() @@ -87,7 +88,7 @@ function TEST(data) local pos for _, info in ipairs(data) do local uri = furi.encode(info.path) - local script = info.content + local script = info.content or '' if info.main then local newScript, catched = catch(script, '?') pos = catched['?'][1][1] @@ -565,9 +566,115 @@ TEST { ]], main = true, }, + completion = nil, } TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require '<??>' + ]], + main = true, + }, + completion = { + { + label = 'a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'b', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.b', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require 'a<??>' + ]], + main = true, + }, + completion = { + { + label = 'a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +config.set('Lua.runtime.pathStrict', true) + +TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require '<??>' + ]], + main = true, + }, + completion = { + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + { + label = 'f.b', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +TEST { + { path = 'f/a.lua' }, + { path = 'f/b.lua' }, + { + path = 'c.lua', + content = [[ + require 'a<??>' + ]], + main = true, + }, + completion = { + { + label = 'f.a', + kind = CompletionItemKind.Reference, + textEdit = EXISTS, + }, + } +} + +config.set('Lua.runtime.pathStrict', false) + +TEST { { path = 'xxx.lua', content = '' diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua index b233141c..058f5d18 100644 --- a/test/crossfile/definition.lua +++ b/test/crossfile/definition.lua @@ -117,6 +117,31 @@ TEST { }, } +config.set('Lua.runtime.pathStrict', true) +TEST { + { + path = 'aaa/bbb.lua', + content = '', + }, + { + path = 'b.lua', + content = 'require "<?bbb?>"', + }, +} + +TEST { + { + path = 'aaa/bbb.lua', + content = '<!!>', + }, + { + path = 'b.lua', + content = 'require "<?aaa.bbb?>"', + }, +} + +config.set('Lua.runtime.pathStrict', false) + TEST { { path = 'a.lua', diff --git a/test/crossfile/diagnostic.lua b/test/crossfile/diagnostic.lua index 7735f4c5..c2d043f4 100644 --- a/test/crossfile/diagnostic.lua +++ b/test/crossfile/diagnostic.lua @@ -29,6 +29,7 @@ local function founded(targets, results) return true end +---@diagnostic disable: await-in-sync function TEST(datas) files.removeAll() diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 35528446..f23850a5 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -37,6 +37,7 @@ local function eq(a, b) return a == b end +---@diagnostic disable: await-in-sync function TEST(expect) files.removeAll() @@ -592,7 +593,7 @@ function f(arg1: integer, arg2: integer) --- ```lua -function f() +function f(arg3: any) ```]]} diff --git a/test/definition/luadoc.lua b/test/definition/luadoc.lua index 5f8c11ee..58c7c8fe 100644 --- a/test/definition/luadoc.lua +++ b/test/definition/luadoc.lua @@ -100,6 +100,11 @@ function f(<?...?>) end ]] TEST [[ +---@param ... <!fun():void!> +function f(<?...?>) end +]] + +TEST [[ ---@overload <!fun(y: boolean)!> ---@param x number ---@param y boolean diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua index ab55cd92..558ffc26 100644 --- a/test/diagnostics/init.lua +++ b/test/diagnostics/init.lua @@ -4,8 +4,9 @@ local config = require 'config' local util = require 'utility' local catch = require 'catch' -config.get 'Lua.diagnostics.neededFileStatus'['deprecated'] = 'Any' -config.get 'Lua.diagnostics.neededFileStatus'['type-check'] = 'Any' +config.get 'Lua.diagnostics.neededFileStatus'['deprecated'] = 'Any' +config.get 'Lua.diagnostics.neededFileStatus'['type-check'] = 'Any' +config.get 'Lua.diagnostics.neededFileStatus'['await-in-sync'] = 'Any' rawset(_G, 'TEST', true) @@ -25,6 +26,7 @@ local function founded(targets, results) return true end +---@diagnostic disable: await-in-sync function TEST(script, ...) files.removeAll() local newScript, catched = catch(script, '!') @@ -304,7 +306,7 @@ Instance = _G[InstanceName] ]] TEST [[ -(''):sub(1, 2) +local _ = (''):sub(1, 2) ]] TEST [=[ @@ -429,7 +431,7 @@ f(1, 2, 3, 4) ]] TEST [[ -next({}, 1, <!2!>) +local _ = next({}, 1, <!2!>) print(1, 2, 3, 4, 5) ]] @@ -461,7 +463,7 @@ f(1, 2, 3) ]] TEST [[ -<!unpack!>() +local _ = <!unpack!>() ]] TEST [[ @@ -674,10 +676,10 @@ T = {} T['x'], <!T['y']!>, <!T['z']!> = 1 ]] -TEST [[ ----@class <!Class!> ----@class <!Class!> -]] +--TEST [[ +-----@class <!Class!> +-----@class <!Class!> +--]] TEST [[ ---@class A : <!B!> @@ -718,7 +720,7 @@ TEST [[ ]] TEST [[ ----@class <!A!> +---@class A ---@class B ---@alias <!A B!> ]] @@ -1348,12 +1350,159 @@ end f() ]] ----TODO(arthur) -do return end - TEST [[ ---@type file* local f -f:read '*a' -f:read('*a') +local _ = f:read '*a' +local _ = f:read('*a') +]] + +TEST [[ +function F() + <!coroutine.yield!>() +end +]] + +TEST [[ +---@async +function F() + coroutine.yield() +end +]] + +TEST [[ +---@type async fun() +local f + +function F() + <!f!>() +end +]] + +TEST [[ +---@type async fun() +local f + +---@async +function F() + f() +end +]] + +TEST [[ +local function f(cb) + cb() +end + +<!f!>(function () ---@async + return nil +end) +]] + +TEST [[ +local function f(cb) + pcall(cb) +end + +<!f!>(function () ---@async + return nil +end) +]] + +TEST [[ +---@nodiscard +local function f() + return 1 +end + +<!f()!> +]] + +TEST [[ +---@nodiscard +local function f() + return 1 +end + +X = f() +]] + +config.get 'Lua.diagnostics.neededFileStatus'['not-yieldable'] = 'Any' +TEST [[ +local function f(cb) + return cb +end + +---@async +local function af() + return nil +end + +f(<!af!>) +]] + +TEST [[ +---@param cb async fun() +local function f(cb) + return cb +end + +---@async +local function af() + return nil +end + +f(af) +]] + +TEST [[ +local function f(cb) + cb() +end + +local function af() + <!f!>(function () ---@async + return nil + end) +end + +return af +]] + +TEST [[ +local function f(cb) + cb() +end + +---@async +local function af() + f(function () ---@async + return nil + end) +end + +return af +]] + +TEST [[ +local _ = type(function () ---@async + return nil +end) +]] + +TEST [[ +---@param ... number +local function f(...) + return ... +end + +return f +]] + +TEST [[ +---@type fun(...: string) +]] + +TEST [[ +---@type fun(xxx, yyy, ...): boolean ]] diff --git a/test/document_symbol/init.lua b/test/document_symbol/init.lua index d3168197..1324f29c 100644 --- a/test/document_symbol/init.lua +++ b/test/document_symbol/init.lua @@ -45,6 +45,7 @@ local function checkArcoss(symbols) end end +---@diagnostic disable: await-in-sync function TEST(script) return function (expect) files.removeAll() diff --git a/test/full/example.lua b/test/full/example.lua index 20de5528..0505f1a5 100644 --- a/test/full/example.lua +++ b/test/full/example.lua @@ -8,6 +8,7 @@ local luadoc = require "parser.luadoc" local noder = require 'core.noder' -- δΈ΄ζΆ +---@diagnostic disable: await-in-sync local function testIfExit(path) config.set('Lua.workspace.preloadFileSize', 1000000000) local buf = util.loadFile(path:string()) diff --git a/test/full/projects.lua b/test/full/projects.lua index b5523fed..a095f316 100644 --- a/test/full/projects.lua +++ b/test/full/projects.lua @@ -12,6 +12,7 @@ config.set('Lua.diagnostics.neededFileStatus', { ['not-yieldable'] = 'Any', }) +---@diagnostic disable: await-in-sync local function doProjects(pathname) files.removeAll() diff --git a/test/full/self.lua b/test/full/self.lua index eae53b72..b2c74271 100644 --- a/test/full/self.lua +++ b/test/full/self.lua @@ -25,6 +25,7 @@ diag.start() local clock = os.clock() +---@diagnostic disable: await-in-sync for uri in files.eachFile() do local fileClock = os.clock() diag.doDiagnostic(uri) diff --git a/test/hover/init.lua b/test/hover/init.lua index b3d675bb..15bf60d4 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -20,6 +20,7 @@ local accept = { ['function'] = true, } +---@diagnostic disable: await-in-sync function TEST(script) return function (expect) files.removeAll() @@ -245,7 +246,7 @@ TEST [[ <?print?>() ]] [[ -function print(...) +function print(...: any) ]] TEST [[ @@ -299,7 +300,7 @@ end <?x?>(1, 2, 3, 4, 5, 6, 7) ]] [[ -function x(a: any, ...) +function x(a: any, ...: any) ]] TEST [[ @@ -1120,6 +1121,45 @@ local t: Class[] ]] TEST [[ +---@class Class + +---@param ... Class +local function f(...) + local _, <?x?> = ... +end +f(1, 2, 3) +]] +[[ +local x: Class +]] + +TEST [[ +---@class Class + +---@param ... Class +local function f(...) + local t = {...} + local <?v?> = t[1] +end +]] +[[ +local v: Class +]] + +TEST [[ +---@class Class + +---@param ... Class +local function f(...) + local <?t?> = {...} +end +f(1, 2, 3) +]] +[[ +local t: Class[] +]] + +TEST [[ ---@type string[] local <?x?> ]] @@ -1456,7 +1496,7 @@ TEST [[ local function f(<?callback?>) end ]] [[ -local callback: fun(x: integer, ...: nil) +local callback: fun(x: integer, ...: any) ]] TEST [[ @@ -1728,3 +1768,36 @@ local function <?f?>() end function f() -> nil ]] + +TEST [[ +---@async +local function <?f?>() end +]] +[[ +async function f() +]] + +TEST [[ +---@type function +local <?f?> +]] +[[ +local f: function +]] + +TEST [[ +---@type async fun() +local <?f?> +]] +[[ +local f: async fun() +]] + +config.set('Lua.runtime.nonstandardSymbol', { '//' }) +TEST [[ +local <?x?> = 1 // 2 +]] +[[ +local x: integer = 1 +]] +config.set('runtime.nonstandardSymbol', {}) diff --git a/test/signature/init.lua b/test/signature/init.lua index 1dbe61e8..aa9d9094 100644 --- a/test/signature/init.lua +++ b/test/signature/init.lua @@ -4,6 +4,7 @@ local catch = require 'catch' rawset(_G, 'TEST', true) +---@diagnostic disable: await-in-sync function TEST(script) return function (expect) local newScript, catched1 = catch(script, '?') @@ -82,7 +83,7 @@ end x(1, 2, 3, <??> ]] -'function x(a: any, <!...!>)' +'function x(a: any, <!...: any!>)' TEST [[ (''):sub(<??> diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index 6d5a57dd..c76e372c 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -930,6 +930,11 @@ emit:on("died", function (<?i?>) end) ]] +TEST 'π' [[ +---@class π +local <?x?> +]] + TEST 'boolean' [[ ---@type boolean local x |