summary refs log tree commit diff stats
path: root/tests/coroutines/texceptions.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/coroutines/texceptions.nim')
-rw-r--r--tests/coroutines/texceptions.nim29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/coroutines/texceptions.nim b/tests/coroutines/texceptions.nim
new file mode 100644
index 000000000..31feffdff
--- /dev/null
+++ b/tests/coroutines/texceptions.nim
@@ -0,0 +1,29 @@
+discard """
+  targets: "c"
+  disabled: true
+"""
+
+import coro
+var
+  stackCheckValue = 1100220033
+  numbers = newSeqOfCap[int](10)
+
+proc testExceptions(id: int, sleep: float) =
+  try:
+    numbers.add(id)
+    suspend(sleep)
+    numbers.add(id)
+    raise (ref ValueError)()
+  except:
+    suspend(sleep)
+    numbers.add(id)
+    suspend(sleep)
+    numbers.add(id)
+  suspend(sleep)
+  numbers.add(id)
+
+start(proc() = testExceptions(1, 0.01))
+start(proc() = testExceptions(2, 0.011))
+coro.run()
+doAssert(stackCheckValue == 1100220033, "Thread stack got corrupted")
+doAssert(numbers == @[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], "Coroutines executed in incorrect order")