summaryrefslogtreecommitdiff
path: root/test/diagnostics/unreachable-code.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-08-11 17:57:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-08-11 17:57:29 +0800
commit5e5a1b2ebb103625bbbb686ab31abc11a78e9d73 (patch)
tree8140d6f9c04a51476e558a9b7fa661a068d6c49a /test/diagnostics/unreachable-code.lua
parentcd370225fc4eaf6e2f6baadfb5a8501943c86783 (diff)
downloadlua-language-server-5e5a1b2ebb103625bbbb686ab31abc11a78e9d73.zip
cleanup tests
Diffstat (limited to 'test/diagnostics/unreachable-code.lua')
-rw-r--r--test/diagnostics/unreachable-code.lua71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/diagnostics/unreachable-code.lua b/test/diagnostics/unreachable-code.lua
new file mode 100644
index 00000000..4444252f
--- /dev/null
+++ b/test/diagnostics/unreachable-code.lua
@@ -0,0 +1,71 @@
+TEST [[
+if X then
+ return false
+elseif X then
+ return false
+else
+ return false
+end
+<!return true!>
+]]
+
+TEST [[
+function X()
+ if X then
+ return false
+ elseif X then
+ return false
+ else
+ return false
+ end
+ <!return true!>
+end
+]]
+
+TEST [[
+while true do
+end
+
+<!print(1)!>
+]]
+
+TEST [[
+while true do
+end
+
+<!print(1)!>
+]]
+
+TEST [[
+while X do
+ X = 1
+end
+
+print(1)
+]]
+
+TEST [[
+while true do
+ if not X then
+ break
+ end
+end
+
+print(1)
+
+do return end
+]]
+
+TEST [[
+local done = false
+
+local function set_done()
+ done = true
+end
+
+while not done do
+ set_done()
+end
+
+print(1)
+]]