From 905fc43abe81f685367a918b71ae143af67898fd Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 20 Jun 2019 08:38:29 +0200 Subject: [PATCH] newruntime: added yet another test (cherry picked from commit 0adb1c6223adf58329e1a9cd0d92c3493e00eafa) --- tests/destructor/tsimpleclosure.nim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/destructor/tsimpleclosure.nim diff --git a/tests/destructor/tsimpleclosure.nim b/tests/destructor/tsimpleclosure.nim new file mode 100644 index 0000000000..df4c2c84b7 --- /dev/null +++ b/tests/destructor/tsimpleclosure.nim @@ -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)