mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 04:27:44 +00:00
newruntime: added yet another test
(cherry picked from commit 0adb1c6223)
This commit is contained in:
22
tests/destructor/tsimpleclosure.nim
Normal file
22
tests/destructor/tsimpleclosure.nim
Normal file
@@ -0,0 +1,22 @@
|
||||
discard """
|
||||
cmd: '''nim c --newruntime $file'''
|
||||
output: '''a b
|
||||
0 0 alloc/dealloc pairs: 0'''
|
||||
"""
|
||||
|
||||
import core / allocators
|
||||
import system / ansi_c
|
||||
|
||||
proc main(): owned(proc()) =
|
||||
var a = "a"
|
||||
var b = "b"
|
||||
result = proc() =
|
||||
echo a, " ", b
|
||||
|
||||
proc wrap =
|
||||
let p = main()
|
||||
p()
|
||||
|
||||
wrap()
|
||||
let (a, d) = allocCounters()
|
||||
discard cprintf("%ld %ld alloc/dealloc pairs: %ld\n", a, d, system.allocs)
|
||||
Reference in New Issue
Block a user