summaryrefslogtreecommitdiff
path: root/test/diagnostics/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/diagnostics/init.lua')
-rw-r--r--test/diagnostics/init.lua179
1 files changed, 164 insertions, 15 deletions
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
]]