summary refs log tree commit diff stats
path: root/tests/coroutines/tgc.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/coroutines/tgc.nim')
-rw-r--r--tests/coroutines/tgc.nim22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/coroutines/tgc.nim b/tests/coroutines/tgc.nim
new file mode 100644
index 000000000..770d413f5
--- /dev/null
+++ b/tests/coroutines/tgc.nim
@@ -0,0 +1,22 @@
+discard """
+  matrix: "--gc:refc; --gc:arc; --gc:orc"
+  targets: "c"
+"""
+
+when compileOption("gc", "refc") or not defined(openbsd):
+  # xxx openbsd gave: stdlib_coro.nim.c:406:22: error: array type 'jmp_buf' (aka 'long [11]') is not assignable (*dest).execContext = src.execContext;
+  import coro
+
+  var maxOccupiedMemory = 0
+
+  proc testGC() =
+    var numbers = newSeq[int](100)
+    maxOccupiedMemory = max(maxOccupiedMemory, getOccupiedMem())
+    suspend(0)
+
+  start(testGC)
+  start(testGC)
+  run()
+
+  GC_fullCollect()
+  doAssert(getOccupiedMem() < maxOccupiedMemory, "GC did not free any memory allocated in coroutines")