[other] newruntime: add a simple closure iterator test
This commit is contained in:
parent
6adcc09877
commit
678beb8ef9
1 changed files with 9 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue