diff options
Diffstat (limited to 'tests/js/tasync.nim')
-rw-r--r-- | tests/js/tasync.nim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/js/tasync.nim b/tests/js/tasync.nim new file mode 100644 index 000000000..34ef97b8b --- /dev/null +++ b/tests/js/tasync.nim @@ -0,0 +1,32 @@ +discard """ + disabled: true + output: ''' +x +e +''' +""" + +import asyncjs + +# demonstrate forward definition +# for js +proc y(e: int): Future[string] {.async.} + +proc e: int {.discardable.} = + echo "e" + return 2 + +proc x(e: int): Future[void] {.async.} = + var s = await y(e) + echo s + e() + +proc y(e: int): Future[string] {.async.} = + if e > 0: + return await y(0) + else: + return "x" + + +discard x(2) + |