From 3755ea8479b54cd823a6151e230e6cda8894d69a Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Wed, 18 Mar 2020 18:12:13 -0400 Subject: defer seems to be fully working --- tests/defer.toc | 36 ++++++++++++++++++++++++++++++++++++ tests/defer_expected | 41 +++++++++++++++++++++++++++++++++++++++++ tests/test.sh | 1 + 3 files changed, 78 insertions(+) create mode 100644 tests/defer.toc create mode 100644 tests/defer_expected (limited to 'tests') 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 -- cgit v1.2.3