summaryrefslogtreecommitdiff
path: root/tests/typ/code/break-continue.typ
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2022-02-28 13:41:15 +0100
committerMartin Haug <mhaug@live.de>2022-02-28 13:41:15 +0100
commit8e0f5993f12a590c42dfebfbc99b75dba00daf15 (patch)
treebea880a99ea9cb4697791a64b03655934ab9f016 /tests/typ/code/break-continue.typ
parentd007788db8bfc53089125456510216ea94667ff5 (diff)
Make loops and functions react to control flow
Diffstat (limited to 'tests/typ/code/break-continue.typ')
-rw-r--r--tests/typ/code/break-continue.typ44
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/typ/code/break-continue.typ b/tests/typ/code/break-continue.typ
index 2b38cf77..e54651f1 100644
--- a/tests/typ/code/break-continue.typ
+++ b/tests/typ/code/break-continue.typ
@@ -2,13 +2,55 @@
// Ref: false
---
+// Test break.
+
+#let error = false
+#let var = 0
+
#for i in range(10) {
+ var += i
if i > 5 {
- // Error: 5-10 break is not yet implemented
break
+ error = true
+ }
+}
+
+#test(error, false)
+#test(var, 21)
+
+---
+// Test continue.
+
+#let x = 0
+#let i = 0
+
+#while x < 8 {
+ i += 1
+
+ if mod(i, 3) == 0 {
+ continue
}
+ x += i
}
+// If continue did not work, this would equal 10.
+#test(x, 12)
+
+---
+// Test break outside of loop.
+
+#let f() = {
+ // Error: 3-8 cannot break outside of loop
+ break
+}
+#f()
+
+---
+// Test continue outside of loop.
+
+// Error: 12-20 cannot continue outside of loop
+#let x = { continue }
+
---
// Error: 1-10 unexpected keyword `continue`
#continue