summary refs log tree commit diff stats
path: root/tests/async
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-06-19 06:08:00 -0700
committerGitHub <noreply@github.com>2020-06-19 15:08:00 +0200
commit2039e3e883ac42cd9b6012335a92564ca2b56387 (patch)
treef2e2238c0973b6927aca358aeac9752a1e58d0a1 /tests/async
parent65c7884a3c84d7e1750cf630940b089ed204bc1a (diff)
downloadNim-2039e3e883ac42cd9b6012335a92564ca2b56387.tar.gz
fix #13899 defer now works with async (#14723)
Diffstat (limited to 'tests/async')
-rw-r--r--tests/async/tasync_misc.nim25
1 files changed, 18 insertions, 7 deletions
diff --git a/tests/async/tasync_misc.nim b/tests/async/tasync_misc.nim
index c5ee22a42..29e6faa72 100644
--- a/tests/async/tasync_misc.nim
+++ b/tests/async/tasync_misc.nim
@@ -1,8 +1,3 @@
-discard """
-  exitcode: 0
-  output: "ok"
-"""
-
 import json, asyncdispatch
 block: #6100
   let done = newFuture[int]()
@@ -61,5 +56,21 @@ block: # 12743
 
   waitFor prc()
 
-
-echo "ok"
+block: # issue #13899
+  proc someConnect() {.async.} =
+    await sleepAsync(1)
+  proc someClose() {.async.} =
+    await sleepAsync(2)
+  proc testFooFails(): Future[bool] {.async.} =
+    await someConnect()
+    defer:
+      await someClose()
+      result = true
+  proc testFooSucceed(): Future[bool] {.async.} =
+    try:
+      await someConnect()
+    finally:
+      await someClose()
+      result = true
+  doAssert waitFor testFooSucceed()
+  doAssert waitFor testFooFails()