diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/defer.toc | 12 | ||||
-rw-r--r-- | tests/defer_expected | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/defer.toc b/tests/defer.toc index 77a4c4e..32165e7 100644 --- a/tests/defer.toc +++ b/tests/defer.toc @@ -1,6 +1,18 @@ #include "io.toc", io; +plusone ::= fn(n : int) x := n { + defer x += 1; +} + +same ::= fn(n : int) int { + x := n; + defer x += 1; + x +} + main ::= fn() { + io.puti(plusone(3)); + io.puti(same(3)); defer io.puts("deferred from main()"); for i := 1..10 { defer io.puts("deferred from for"); diff --git a/tests/defer_expected b/tests/defer_expected index 0a6daa7..99b45e1 100644 --- a/tests/defer_expected +++ b/tests/defer_expected @@ -1,3 +1,5 @@ +4 +3 1 deferred from for 2 |