diff options
Diffstat (limited to 'tests/async')
-rw-r--r-- | tests/async/t7192.nim | 14 | ||||
-rw-r--r-- | tests/async/t7758.nim | 6 | ||||
-rw-r--r-- | tests/async/t8982.nim | 33 | ||||
-rw-r--r-- | tests/async/tasyncRecvLine.nim | 3 | ||||
-rw-r--r-- | tests/async/tasync_gcunsafe.nim | 2 | ||||
-rw-r--r-- | tests/async/tasyncall.nim | 3 | ||||
-rw-r--r-- | tests/async/tasyncawait.nim | 1 | ||||
-rw-r--r-- | tests/async/tasyncconnect.nim | 3 | ||||
-rw-r--r-- | tests/async/tasyncdial.nim | 1 | ||||
-rw-r--r-- | tests/async/tasyncexceptions.nim | 5 | ||||
-rw-r--r-- | tests/async/tasyncfile.nim | 8 | ||||
-rw-r--r-- | tests/async/tasyncrecursion.nim | 5 | ||||
-rw-r--r-- | tests/async/tasyncsend4757.nim | 3 | ||||
-rw-r--r-- | tests/async/tasyncssl.nim | 9 | ||||
-rw-r--r-- | tests/async/tasynctry.nim | 4 | ||||
-rw-r--r-- | tests/async/tawaitsemantics.nim | 4 | ||||
-rw-r--r-- | tests/async/tcallbacks.nim | 5 | ||||
-rw-r--r-- | tests/async/tfuturestream.nim | 6 | ||||
-rw-r--r-- | tests/async/tfuturevar.nim | 6 | ||||
-rw-r--r-- | tests/async/tioselectors.nim | 1 | ||||
-rw-r--r-- | tests/async/tnewasyncudp.nim | 1 | ||||
-rw-r--r-- | tests/async/tpendingcheck.nim | 3 | ||||
-rw-r--r-- | tests/async/twinasyncrw.nim | 1 |
23 files changed, 78 insertions, 49 deletions
diff --git a/tests/async/t7192.nim b/tests/async/t7192.nim new file mode 100644 index 000000000..9ac0e07c0 --- /dev/null +++ b/tests/async/t7192.nim @@ -0,0 +1,14 @@ +discard """ +output: ''' +testCallback() +''' +""" + +import asyncdispatch + +proc testCallback() = + echo "testCallback()" + +when true: + callSoon(testCallback) + poll() diff --git a/tests/async/t7758.nim b/tests/async/t7758.nim index 102a4ce4c..ce4df1fc9 100644 --- a/tests/async/t7758.nim +++ b/tests/async/t7758.nim @@ -1,7 +1,3 @@ -discard """ - file: "t7758.nim" - exitcode: 0 -""" import asyncdispatch proc task() {.async.} = @@ -16,4 +12,4 @@ proc main() = doAssert counter <= 4 -for i in 0 .. 10: main() \ No newline at end of file +for i in 0 .. 10: main() diff --git a/tests/async/t8982.nim b/tests/async/t8982.nim new file mode 100644 index 000000000..5face7edf --- /dev/null +++ b/tests/async/t8982.nim @@ -0,0 +1,33 @@ +discard """ +output: ''' +timeout +runForever should throw ValueError, this is expected +''' +""" + + +import asyncdispatch + +proc failingAwaitable(p: int) {.async.} = + await sleepAsync(500) + if p > 0: + raise newException(Exception, "my exception") + +proc main() {.async.} = + let fut = failingAwaitable(1) + try: + await fut or sleepAsync(100) + if fut.finished: + echo "finished" + else: + echo "timeout" + except: + echo "failed" + + +# Previously this would raise "An attempt was made to complete a Future more than once." +try: + asyncCheck main() + runForever() +except ValueError: + echo "runForever should throw ValueError, this is expected" diff --git a/tests/async/tasyncRecvLine.nim b/tests/async/tasyncRecvLine.nim index 679831b27..a13a171c3 100644 --- a/tests/async/tasyncRecvLine.nim +++ b/tests/async/tasyncRecvLine.nim @@ -1,6 +1,5 @@ discard """ - file: "tasyncRecvLine.nim" - output: ''' +output: ''' Hello World Hello World ''' diff --git a/tests/async/tasync_gcunsafe.nim b/tests/async/tasync_gcunsafe.nim index f4e2cdcf2..55b66aaef 100644 --- a/tests/async/tasync_gcunsafe.nim +++ b/tests/async/tasync_gcunsafe.nim @@ -1,7 +1,7 @@ discard """ + errormsg: "'anotherGCSafeAsyncProcIter' is not GC-safe as it calls 'asyncGCUnsafeProc'" cmd: "nim c --threads:on $file" file: "asyncmacro.nim" - errormsg: "'anotherGCSafeAsyncProcIter' is not GC-safe as it calls 'asyncGCUnsafeProc'" """ assert compileOption("threads"), "this test will not do anything useful without --threads:on" diff --git a/tests/async/tasyncall.nim b/tests/async/tasyncall.nim index 775dd0c6f..3c318dbf7 100644 --- a/tests/async/tasyncall.nim +++ b/tests/async/tasyncall.nim @@ -1,8 +1,7 @@ discard """ - file: "tasyncall.nim" exitcode: 0 """ -import times, sequtils, unittest +import times, sequtils import asyncdispatch const diff --git a/tests/async/tasyncawait.nim b/tests/async/tasyncawait.nim index e7a2ec1d9..fcb48a1f5 100644 --- a/tests/async/tasyncawait.nim +++ b/tests/async/tasyncawait.nim @@ -1,5 +1,4 @@ discard """ - file: "tasyncawait.nim" output: "5000" """ import asyncdispatch, nativesockets, net, strutils, os diff --git a/tests/async/tasyncconnect.nim b/tests/async/tasyncconnect.nim index 3dac379b2..f63a87990 100644 --- a/tests/async/tasyncconnect.nim +++ b/tests/async/tasyncconnect.nim @@ -1,7 +1,6 @@ discard """ - file: "tasyncconnect.nim" - exitcode: 1 outputsub: "Error: unhandled exception: Connection refused" + exitcode: 1 """ import diff --git a/tests/async/tasyncdial.nim b/tests/async/tasyncdial.nim index fa81235fe..815520294 100644 --- a/tests/async/tasyncdial.nim +++ b/tests/async/tasyncdial.nim @@ -1,5 +1,4 @@ discard """ - file: "tasyncdial.nim" output: ''' OK AF_INET OK AF_INET6 diff --git a/tests/async/tasyncexceptions.nim b/tests/async/tasyncexceptions.nim index 7aa1d7fb0..de61c099d 100644 --- a/tests/async/tasyncexceptions.nim +++ b/tests/async/tasyncexceptions.nim @@ -1,7 +1,6 @@ discard """ - file: "tasyncexceptions.nim" - exitcode: 1 outputsub: "Error: unhandled exception: foobar" + exitcode: 1 """ import asyncdispatch @@ -28,7 +27,7 @@ proc serve() {.async.} = var fut = await accept() await processClient(fut) -when isMainModule: +when true: proc main = var fut = serve() fut.callback = diff --git a/tests/async/tasyncfile.nim b/tests/async/tasyncfile.nim index c7b71a2f7..d95850c31 100644 --- a/tests/async/tasyncfile.nim +++ b/tests/async/tasyncfile.nim @@ -1,10 +1,9 @@ discard """ - output: '''13 +output: ''' +13 hello humans! 13 ''' - file: "tasyncfile.nim" - exitcode: 0 """ import asyncfile, asyncdispatch, os @@ -54,8 +53,7 @@ proc main() {.async.} = # Issue #7347 block: - let appDir = getAppDir() - var file = openAsync(appDir & DirSep & "hello.txt") + var file = openAsync( parentDir(currentSourcePath) / "hello.txt") echo file.getFileSize() echo await file.readAll() echo file.getFilePos() diff --git a/tests/async/tasyncrecursion.nim b/tests/async/tasyncrecursion.nim index 1aeebe9b4..7c12dbb0e 100644 --- a/tests/async/tasyncrecursion.nim +++ b/tests/async/tasyncrecursion.nim @@ -1,6 +1,5 @@ discard """ - file: "tasyncrecursion.nim" - output: "50005000" +output: "50005000" """ import asyncdispatch @@ -16,7 +15,7 @@ proc asyncRecursionTest*(): Future[int] {.async.} = inc(result, await asyncRecursionCycle(i)) inc(i) -when isMainModule: +when true: setGlobalDispatcher(newDispatcher()) var i = waitFor asyncRecursionTest() echo i diff --git a/tests/async/tasyncsend4757.nim b/tests/async/tasyncsend4757.nim index 752bb3e75..a87c5df95 100644 --- a/tests/async/tasyncsend4757.nim +++ b/tests/async/tasyncsend4757.nim @@ -1,6 +1,5 @@ discard """ - file: "tasyncsend4754.nim" - output: "Finished" +output: "Finished" """ import asyncdispatch, asyncnet diff --git a/tests/async/tasyncssl.nim b/tests/async/tasyncssl.nim index 0607cf3c6..88a5eb32e 100644 --- a/tests/async/tasyncssl.nim +++ b/tests/async/tasyncssl.nim @@ -1,8 +1,13 @@ discard """ - file: "tasyncssl.nim" cmd: "nim $target --hints:on --define:ssl $options $file" output: "500" + disabled: "windows" + target: c + action: compile """ + +# XXX, deactivated + import asyncdispatch, asyncnet, net, strutils, os when defined(ssl): @@ -62,5 +67,3 @@ when defined(ssl): assert msgCount == swarmSize * messagesToSend echo msgCount - - diff --git a/tests/async/tasynctry.nim b/tests/async/tasynctry.nim index 0fe9efdc1..b13c57951 100644 --- a/tests/async/tasynctry.nim +++ b/tests/async/tasynctry.nim @@ -1,7 +1,5 @@ discard """ - file: "tasynctry.nim" - exitcode: 0 - output: ''' +output: ''' Generic except: Test Specific except Multiple idents in except diff --git a/tests/async/tawaitsemantics.nim b/tests/async/tawaitsemantics.nim index 98fb5dfd5..67903cc5e 100644 --- a/tests/async/tawaitsemantics.nim +++ b/tests/async/tawaitsemantics.nim @@ -1,7 +1,5 @@ discard """ - file: "tawaitsemantics.nim" - exitcode: 0 - output: ''' +output: ''' Error can be caught using yield Infix `or` raises Infix `and` raises diff --git a/tests/async/tcallbacks.nim b/tests/async/tcallbacks.nim index 8c08032cd..bd82d5824 100644 --- a/tests/async/tcallbacks.nim +++ b/tests/async/tcallbacks.nim @@ -1,8 +1,9 @@ discard """ exitcode: 0 - output: '''3 -2 + output: ''' 1 +2 +3 5 ''' """ diff --git a/tests/async/tfuturestream.nim b/tests/async/tfuturestream.nim index 69ad80f47..b5772d5ac 100644 --- a/tests/async/tfuturestream.nim +++ b/tests/async/tfuturestream.nim @@ -1,7 +1,5 @@ discard """ - file: "tfuturestream.nim" - exitcode: 0 - output: ''' +output: ''' 0 1 2 @@ -70,4 +68,4 @@ waitFor testCompletion() # echo("Finished") -# waitFor omega() \ No newline at end of file +# waitFor omega() diff --git a/tests/async/tfuturevar.nim b/tests/async/tfuturevar.nim index ea2c63e03..9e3134261 100644 --- a/tests/async/tfuturevar.nim +++ b/tests/async/tfuturevar.nim @@ -1,3 +1,8 @@ +discard """ +action: compile +""" +# XXX: action should be run! + import asyncdispatch proc completeOnReturn(fut: FutureVar[string], x: bool) {.async.} = @@ -44,4 +49,3 @@ proc main() {.async.} = waitFor main() - diff --git a/tests/async/tioselectors.nim b/tests/async/tioselectors.nim index 7a8986644..be6d3a167 100644 --- a/tests/async/tioselectors.nim +++ b/tests/async/tioselectors.nim @@ -1,5 +1,4 @@ discard """ - file: "tioselectors.nim" output: "All tests passed!" """ import selectors diff --git a/tests/async/tnewasyncudp.nim b/tests/async/tnewasyncudp.nim index b442c0524..7dbd5a3d0 100644 --- a/tests/async/tnewasyncudp.nim +++ b/tests/async/tnewasyncudp.nim @@ -1,5 +1,4 @@ discard """ - file: "tnewasyncudp.nim" output: "5000" """ import asyncdispatch, nativesockets, net, strutils, os diff --git a/tests/async/tpendingcheck.nim b/tests/async/tpendingcheck.nim index 825acb613..a5537d8cb 100644 --- a/tests/async/tpendingcheck.nim +++ b/tests/async/tpendingcheck.nim @@ -1,6 +1,4 @@ discard """ - file: "tpendingcheck.nim" - exitcode: 0 output: "" """ @@ -18,4 +16,3 @@ while not f.finished: f.read doAssert(not hasPendingOperations()) - diff --git a/tests/async/twinasyncrw.nim b/tests/async/twinasyncrw.nim index 94193e921..64c5d6c26 100644 --- a/tests/async/twinasyncrw.nim +++ b/tests/async/twinasyncrw.nim @@ -1,5 +1,4 @@ discard """ - file: "twinasyncrw.nim" output: "5000" """ when defined(windows): |