summaryrefslogtreecommitdiff
path: root/tests/typ/compiler/while.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-29 13:37:25 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-29 14:18:13 +0100
commit0efe669278a5e1c3f2985eba2f3360e91159c54a (patch)
tree502712857c48f0decb5e698257c0a96d358a436e /tests/typ/compiler/while.typ
parent836692e73cff0356e409a9ba5b4887b86809d4ca (diff)
Reorganize library and tests
Diffstat (limited to 'tests/typ/compiler/while.typ')
-rw-r--r--tests/typ/compiler/while.typ58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/typ/compiler/while.typ b/tests/typ/compiler/while.typ
new file mode 100644
index 00000000..5dc5ae41
--- /dev/null
+++ b/tests/typ/compiler/while.typ
@@ -0,0 +1,58 @@
+// Test while expressions.
+
+---
+// Should output `2 4 6 8 10`.
+#let i = 0
+#while i < 10 [
+ { i += 2 }
+ #i
+]
+
+// Should output `Hi`.
+#let iter = true
+#while iter {
+ iter = false
+ "Hi."
+}
+
+#while false {
+ dont-care
+}
+
+---
+// Value of while loops.
+// Ref: false
+
+#test(while false {}, none)
+
+#let i = 0
+#test(type(while i < 1 [{ i += 1 }]), "content")
+
+---
+// Condition must be boolean.
+// Error: 8-14 expected boolean, found content
+#while [nope] [nope]
+
+---
+// Make sure that we terminate and don't complain multiple times.
+#while true {
+ // Error: 3-7 unknown variable
+ nope
+}
+
+---
+// Error: 7 expected expression
+#while
+
+// Error: 7 expected expression
+{while}
+
+// Error: 9 expected body
+#while x
+
+// Error: 7 expected expression
+#while
+x {}
+
+// Error: 9 expected body
+#while x something