diff options
Diffstat (limited to 'tests/async/tasynctry.nim')
-rw-r--r-- | tests/async/tasynctry.nim | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/tests/async/tasynctry.nim b/tests/async/tasynctry.nim index 5930f296f..25eab87fb 100644 --- a/tests/async/tasynctry.nim +++ b/tests/async/tasynctry.nim @@ -1,51 +1,51 @@ discard """ - file: "tasynctry.nim" - exitcode: 0 - output: ''' +output: ''' Generic except: Test Specific except Multiple idents in except Multiple except branches Multiple except branches 2 +success ''' +targets: "c" """ -import asyncdispatch +import asyncdispatch, strutils # Here we are testing the ability to catch exceptions. proc foobar() {.async.} = if 5 == 5: - raise newException(EInvalidIndex, "Test") + raise newException(IndexDefect, "Test") proc catch() {.async.} = # TODO: Create a test for when exceptions are not caught. try: await foobar() except: - echo("Generic except: ", getCurrentExceptionMsg()) + echo("Generic except: ", getCurrentExceptionMsg().splitLines[0]) try: await foobar() - except EInvalidIndex: + except IndexDefect: echo("Specific except") try: await foobar() - except OSError, EInvalidField, EInvalidIndex: + except OSError, FieldDefect, IndexDefect: echo("Multiple idents in except") try: await foobar() - except OSError, EInvalidField: + except OSError, FieldDefect: assert false - except EInvalidIndex: + except IndexDefect: echo("Multiple except branches") try: await foobar() - except EInvalidIndex: + except IndexDefect: echo("Multiple except branches 2") - except OSError, EInvalidField: + except OSError, FieldDefect: assert false waitFor catch() @@ -102,3 +102,17 @@ assert y.waitFor() == 2 y = test4() assert y.waitFor() == 2 + +# bug #14279 + +proc expandValue: Future[int] {.async.} = + return 0 + +proc a(b: int): Future[void] {.async.} = + return + +proc b: Future[void] {.async.} = + await a(await expandValue()) + echo "success" + +waitFor(b()) |