summaryrefslogtreecommitdiff
path: root/test/diagnostics
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-11-07 19:59:11 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-11-07 19:59:11 +0800
commitdbb392e3f3953c6ce821755ad14bc857840f899c (patch)
treef2fc91e6497ba29ef599cced40337f5b7e9ca368 /test/diagnostics
parent8ed72a93bc27d86b4a4b5e5f87e279d8644a39a3 (diff)
downloadlua-language-server-dbb392e3f3953c6ce821755ad14bc857840f899c.zip
full support for interface
Diffstat (limited to 'test/diagnostics')
-rw-r--r--test/diagnostics/type-check.lua59
1 files changed, 53 insertions, 6 deletions
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index 81cb1050..a8525ab0 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -3,7 +3,7 @@ local config = require 'config'
config.add(nil, 'Lua.diagnostics.disable', 'unused-local')
config.add(nil, 'Lua.diagnostics.disable', 'unused-function')
config.add(nil, 'Lua.diagnostics.disable', 'undefined-global')
-config.add(nil, 'Lua.diagnostics.disable', 'missing-return')
+config.add(nil, 'Lua.diagnostics.disable', 'redundant-return')
config.set(nil, 'Lua.type.castNumberToInteger', false)
TEST [[
@@ -522,7 +522,9 @@ end
TEST [[
---@return number, number
-local function f() end
+local function f()
+ return 1, 1
+end
---@return number, boolean
function F()
@@ -532,7 +534,9 @@ end
TEST [[
---@return boolean, number
-local function f() end
+local function f()
+ return true, 1
+end
---@return number, boolean
function F()
@@ -542,7 +546,9 @@ end
TEST [[
---@return boolean, number?
-local function f() end
+local function f()
+ return true, 1
+end
---@return number, boolean
function F()
@@ -552,7 +558,9 @@ end
TEST [[
---@return number, number?
-local function f() end
+local function f()
+ return 1, 1
+end
---@return number, boolean, number
function F()
@@ -969,8 +977,47 @@ local x
local t = { true, false, x }
]]
+TEST [[
+---@type fun():number
+local function f()
+<!!>end
+]]
+
+TEST [[
+---@type fun():number
+local function f()
+ <!return!>
+end
+]]
+
+TEST [[
+---@type fun():number
+local function f()
+ return 1, <!true!>
+end
+]]
+
+TEST [[
+---@type fun():number
+local function f()
+ return <!true!>
+end
+]]
+
+TEST [[
+---@type fun(x: number)
+local function f<!()!>
+end
+]]
+
+TEST [[
+---@type fun(x: number)
+local function f(x, <!y!>)
+end
+]]
+
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
config.remove(nil, 'Lua.diagnostics.disable', 'unused-function')
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')
-config.remove(nil, 'Lua.diagnostics.disable', 'missing-return')
+config.remove(nil, 'Lua.diagnostics.disable', 'redundant-return')
config.set(nil, 'Lua.type.castNumberToInteger', true)