summaryrefslogtreecommitdiff
path: root/test/diagnostics/unreachable-code.lua
diff options
context:
space:
mode:
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)
+]]