summaryrefslogtreecommitdiff
path: root/tests/control_flow.toc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/control_flow.toc')
-rw-r--r--tests/control_flow.toc31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/control_flow.toc b/tests/control_flow.toc
new file mode 100644
index 0000000..923a40b
--- /dev/null
+++ b/tests/control_flow.toc
@@ -0,0 +1,31 @@
+#include "io.toc", io;
+
+f ::= fn() int {
+ total := 0;
+ for i := 1..10 {
+ if i % 2 == 0 { continue; }
+ total += i;
+ if i == 7 { break; }
+ }
+ i := 0;
+ while {
+ i += 1;
+ total += i;
+ if i == 10 {
+ break;
+ }
+ }
+ while i < 100 {
+ i += 1;
+ if i == 100 {
+ return total;
+ }
+ }
+ 0
+}
+
+main ::= fn() {
+ x ::= f();
+ io.puti(x);
+ io.puti(f());
+} \ No newline at end of file