summaryrefslogtreecommitdiff
path: root/tests/typ/control/if.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-02-20 17:53:40 +0100
committerLaurenz <laurmaedje@gmail.com>2021-02-20 23:34:33 +0100
commit05727bfc3a9cfd45a8e2028dfd0806f7a8f88015 (patch)
tree6c0b66eb2a9dff224cb39eb6ccb478656a706c04 /tests/typ/control/if.typ
parent927341d93ae29678095e3b874bd68bfc57d4bc05 (diff)
Reorganize tests 🔀
Diffstat (limited to 'tests/typ/control/if.typ')
-rw-r--r--tests/typ/control/if.typ45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/typ/control/if.typ b/tests/typ/control/if.typ
new file mode 100644
index 00000000..4ed6b649
--- /dev/null
+++ b/tests/typ/control/if.typ
@@ -0,0 +1,45 @@
+// Test if-else expressions.
+
+---
+// Test condition evaluation.
+#if 1 < 2 [
+ Ok.
+]
+
+#if true == false [
+ Bad, but we {dont-care}!
+]
+
+---
+// Brace in condition.
+#if {true} [
+ Ok.
+]
+
+// Multi-line condition with parens.
+#if (
+ 1 + 1
+ == 1
+) {
+ nope
+} #else {
+ "Ok."
+}
+
+// Multiline.
+#if false [
+ Bad.
+] #else {
+ let pt = "."
+ "Ok" + pt
+}
+
+---
+// Condition must be boolean.
+// If it isn't, neither branch is evaluated.
+// Error: 5-14 expected boolean, found string
+#if "a" + "b" { nope } #else { nope }
+
+// Make sure that we don't complain twice.
+// Error: 5-12 cannot add integer and string
+#if 1 + "2" {}