summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/async/tasync_misc.nim9
-rw-r--r--tests/async/tasync_noasync.nim15
-rw-r--r--tests/async/tasync_nofuture.nim11
-rw-r--r--tests/async/tasync_traceback.nim6
4 files changed, 39 insertions, 2 deletions
diff --git a/tests/async/tasync_misc.nim b/tests/async/tasync_misc.nim
index 298fa64a9..c5ee22a42 100644
--- a/tests/async/tasync_misc.nim
+++ b/tests/async/tasync_misc.nim
@@ -53,4 +53,13 @@ block: # nkCheckedFieldExpr
 
   waitFor foo()
 
+block: # 12743
+
+  template templ = await sleepAsync 0
+
+  proc prc {.async.} = templ
+
+  waitFor prc()
+
+
 echo "ok"
diff --git a/tests/async/tasync_noasync.nim b/tests/async/tasync_noasync.nim
new file mode 100644
index 000000000..812b40da6
--- /dev/null
+++ b/tests/async/tasync_noasync.nim
@@ -0,0 +1,15 @@
+discard """
+  errormsg: "undeclared identifier: 'await'"
+  cmd: "nim c $file"
+  file: "tasync_noasync.nim"
+"""
+import async
+
+proc a {.async.} =
+  discard
+
+await a()
+
+# if we overload a fallback handler to get
+# await only available within {.async.}
+# we would need `{.dirty.}` templates for await
\ No newline at end of file
diff --git a/tests/async/tasync_nofuture.nim b/tests/async/tasync_nofuture.nim
new file mode 100644
index 000000000..16155601a
--- /dev/null
+++ b/tests/async/tasync_nofuture.nim
@@ -0,0 +1,11 @@
+discard """
+  errormsg: "await expects Future[T], got int"
+  cmd: "nim c $file"
+  file: "asyncmacro.nim"
+"""
+import async
+
+proc a {.async.} =
+  await 0
+
+waitFor a()
diff --git a/tests/async/tasync_traceback.nim b/tests/async/tasync_traceback.nim
index 7cfbd563f..9f787929b 100644
--- a/tests/async/tasync_traceback.nim
+++ b/tests/async/tasync_traceback.nim
@@ -82,7 +82,7 @@ Async traceback:
     asyncmacro\.nim\(\d+?\)\s+?a
     asyncmacro\.nim\(\d+?\)\s+?aNimAsyncContinue
       ## Resumes an async procedure
-    tasync_traceback\.nim\(\d+?\)\s+?aIter
+    asyncmacro\.nim\(\d+?\)\s+?aIter
     asyncfutures\.nim\(\d+?\)\s+?read
   \]#
 Exception message: b failure
@@ -110,13 +110,15 @@ Async traceback:
       ## Executes pending callbacks
     asyncmacro\.nim\(\d+?\)\s+?fooNimAsyncContinue
       ## Resumes an async procedure
-    tasync_traceback\.nim\(\d+?\)\s+?fooIter
+    asyncmacro\.nim\(\d+?\)\s+?fooIter
     asyncfutures\.nim\(\d+?\)\s+?read
   \]#
 Exception message: bar failure
 Exception type:
 """
 
+# TODO: is asyncmacro good enough location for fooIter traceback/debugging? just put the callsite info for all?
+
 let resLines = splitLines(result.strip)
 let expLines = splitLines(expected.strip)