[other] newruntime: add a simple closure iterator test

This commit is contained in:
Araq
2019-06-20 11:29:30 +02:00
parent 6adcc09877
commit 678beb8ef9

View File

@@ -1,7 +1,8 @@
discard """
cmd: '''nim c --newruntime $file'''
output: '''a b
0 0 alloc/dealloc pairs: 0'''
70
2 2 alloc/dealloc pairs: 0'''
"""
import core / allocators
@@ -13,10 +14,17 @@ proc main(): owned(proc()) =
result = proc() =
echo a, " ", b
proc foo(f: (iterator(): int)) =
for i in f(): echo i
proc wrap =
let p = main()
p()
let fIt = iterator(): int = yield 70
foo fIt
wrap()
let (a, d) = allocCounters()
discard cprintf("%ld %ld alloc/dealloc pairs: %ld\n", a, d, system.allocs)