summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-15 17:40:43 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-15 17:40:43 +0800
commitb22505b90c6df5fadfcad08bee82ec2f6d91bbaa (patch)
treecb45d1189a2b87d11f98d05ae22d51b45ce388a5 /test
parente6b82117616e5d055399aa1568fee90a99ba8d64 (diff)
downloadlua-language-server-b22505b90c6df5fadfcad08bee82ec2f6d91bbaa.zip
resolve #1105 infer type by `type(x)`
Diffstat (limited to 'test')
-rw-r--r--test/type_inference/init.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index a12e702f..20d2c6e9 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -2580,3 +2580,37 @@ local n
n = ff[n and <?n?>.x]
]]
+
+TEST 'integer' [[
+local x
+
+if type(x) == 'integer' then
+ print(<?x?>)
+end
+]]
+
+TEST 'boolean|integer' [[
+local x
+
+if type(x) == 'integer'
+or type(x) == 'boolean' then
+ print(<?x?>)
+end
+]]
+
+TEST 'fun()' [[
+---@type fun()?
+local x
+
+if type(x) == 'function' then
+ print(<?x?>)
+end
+]]
+
+TEST 'function' [[
+local x
+
+if type(x) == 'function' then
+ print(<?x?>)
+end
+]]