summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-03-18 18:12:13 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-03-18 18:12:13 -0400
commit3755ea8479b54cd823a6151e230e6cda8894d69a (patch)
treecd88d7d6b3bf55aabb54b6aabe49e79e70da4f4b /tests
parent729531697131582f4bc992be886e7a4c6030fbc7 (diff)
defer seems to be fully working
Diffstat (limited to 'tests')
-rw-r--r--tests/defer.toc36
-rw-r--r--tests/defer_expected41
-rwxr-xr-xtests/test.sh1
3 files changed, 78 insertions, 0 deletions
diff --git a/tests/defer.toc b/tests/defer.toc
new file mode 100644
index 0000000..77a4c4e
--- /dev/null
+++ b/tests/defer.toc
@@ -0,0 +1,36 @@
+#include "io.toc", io;
+
+main ::= fn() {
+ defer io.puts("deferred from main()");
+ for i := 1..10 {
+ defer io.puts("deferred from for");
+ io.puti(i);
+ if i == 2 {
+ defer io.puts("deferred from if1");
+ defer io.puts("deferred from if2");
+ defer io.puts("deferred from if3");
+ defer io.puts("deferred from if4");
+ defer io.puts("deferred from if5");
+ defer io.puts("deferred from if6");
+ defer io.puts("deferred from if7");
+ defer io.puts("deferred from if8");
+ continue;
+ }
+ if i == 8 {
+ break;
+ }
+ }
+ i := 0;
+ while {
+ defer io.puts("deferred from while");
+ i += 1;
+ io.puti(i);
+ if i % 2 == 0 { continue; }
+ if i == 7 {
+ defer io.puts("deferred from if");
+ break;
+ }
+
+ }
+ io.puts("end of main()");
+}
diff --git a/tests/defer_expected b/tests/defer_expected
new file mode 100644
index 0000000..0a6daa7
--- /dev/null
+++ b/tests/defer_expected
@@ -0,0 +1,41 @@
+1
+deferred from for
+2
+deferred from if8
+deferred from if7
+deferred from if6
+deferred from if5
+deferred from if4
+deferred from if3
+deferred from if2
+deferred from if1
+deferred from for
+3
+deferred from for
+4
+deferred from for
+5
+deferred from for
+6
+deferred from for
+7
+deferred from for
+8
+deferred from for
+1
+deferred from while
+2
+deferred from while
+3
+deferred from while
+4
+deferred from while
+5
+deferred from while
+6
+deferred from while
+7
+deferred from if
+deferred from while
+end of main()
+deferred from main()
diff --git a/tests/test.sh b/tests/test.sh
index 4cb04dc..3d728d3 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -2,6 +2,7 @@
tests='bf
control_flow
+defer
sizeof
new
arr