summaryrefslogtreecommitdiff
path: root/tests/typ/control/if-value.typ
diff options
context:
space:
mode:
Diffstat (limited to 'tests/typ/control/if-value.typ')
-rw-r--r--tests/typ/control/if-value.typ21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/typ/control/if-value.typ b/tests/typ/control/if-value.typ
new file mode 100644
index 00000000..d7124255
--- /dev/null
+++ b/tests/typ/control/if-value.typ
@@ -0,0 +1,21 @@
+// Test return value of if expressions.
+// Ref: false
+
+---
+{
+ let x = 1
+ let y = 2
+ let z
+
+ // Returns if branch.
+ z = if x < y { "ok" }
+ test(z, "ok")
+
+ // Returns else branch.
+ z = if x > y { "bad" } else { "ok" }
+ test(z, "ok")
+
+ // Missing else evaluates to none.
+ z = if x > y { "bad" }
+ test(z, none)
+}