diff options
Diffstat (limited to 'tests/new.toc')
-rw-r--r-- | tests/new.toc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/new.toc b/tests/new.toc new file mode 100644 index 0000000..bb6a5fa --- /dev/null +++ b/tests/new.toc @@ -0,0 +1,27 @@ +#include "mem.toc", mem; +#include "io.toc", io; + +calculation ::= fn() int { + total := 0; + i := mem.new(int); + *i = 3; + ns := mem.news(int, 10); + for n, i := &ns { + if i % 2 == 0 { + *n = i; + } + } + for n := ns { + total += n; + } + total += *i; + mem.del(i); + mem.dels(ns); + total +} + +main ::= fn() { + io.puti(calculation()); + x ::= calculation(); + io.puti(x); +} |