summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/async/config.nims2
-rw-r--r--tests/async/tjsandnativeasync.nim30
-rw-r--r--tests/js/tasync.nim1
-rw-r--r--tests/testament/categories.nim3
4 files changed, 32 insertions, 4 deletions
diff --git a/tests/async/config.nims b/tests/async/config.nims
deleted file mode 100644
index 97c2e0aa4..000000000
--- a/tests/async/config.nims
+++ /dev/null
@@ -1,2 +0,0 @@
-when defined(upcoming):
-  patchFile("stdlib", "asyncdispatch", "$lib/upcoming/asyncdispatch")
diff --git a/tests/async/tjsandnativeasync.nim b/tests/async/tjsandnativeasync.nim
new file mode 100644
index 000000000..45839899f
--- /dev/null
+++ b/tests/async/tjsandnativeasync.nim
@@ -0,0 +1,30 @@
+discard """
+  output: '''hi
+bye'''
+"""
+
+import async, times
+when defined(js):
+    proc sleepAsync(t: int): Future[void] =
+        var promise = newPromise() do(resolve: proc()):
+            {.emit: """
+            setTimeout(function(){
+                `resolve`();
+            }, `t`);
+            """.}
+        result = promise
+else:
+    from asyncdispatch import sleepAsync, waitFor
+
+proc foo() {.async.} =
+    echo "hi"
+    var s = epochTime()
+    await sleepAsync(500)
+    var e = epochTime()
+    doAssert(e - s > 0.1)
+    echo "bye"
+
+when defined(js):
+    discard foo()
+else:
+    waitFor foo()
diff --git a/tests/js/tasync.nim b/tests/js/tasync.nim
index 34ef97b8b..76db38b27 100644
--- a/tests/js/tasync.nim
+++ b/tests/js/tasync.nim
@@ -1,5 +1,4 @@
 discard """
-  disabled: true
   output: '''
 x
 e
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index 33b93e3c4..9a8d80273 100644
--- a/tests/testament/categories.nim
+++ b/tests/testament/categories.nim
@@ -225,7 +225,8 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
                    "actiontable/tactiontable", "method/tmultim1",
                    "method/tmultim3", "method/tmultim4",
                    "varres/tvarres0", "varres/tvarres3", "varres/tvarres4",
-                   "varres/tvartup", "misc/tints", "misc/tunsignedinc"]:
+                   "varres/tvartup", "misc/tints", "misc/tunsignedinc",
+                   "async/tjsandnativeasync"]:
     test "tests/" & testfile & ".nim"
 
   for testfile in ["strutils", "json", "random", "times", "logging"]: