From 0adb1c6223adf58329e1a9cd0d92c3493e00eafa Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 20 Jun 2019 08:38:29 +0200 Subject: newruntime: added yet another test --- tests/destructor/tsimpleclosure.nim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/destructor/tsimpleclosure.nim (limited to 'tests') diff --git a/tests/destructor/tsimpleclosure.nim b/tests/destructor/tsimpleclosure.nim new file mode 100644 index 000000000..df4c2c84b --- /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) -- cgit 1.4.1-2-gfad0