summary refs log blame commit diff stats
path: root/tests/js/tasync.nim
blob: 31823765195fb9f608b4cbddee4b3b734f4083f3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
           
             
 
 






                                
                                        
 




                                        
                    

           
        
     

                                          



                     

 

            
discard """
  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)
  if e > 2:
    return
  echo s
  e()

proc y(e: int): Future[string] {.async.} =
  if e > 0:
    return await y(0)
  else:
    return "x"


discard x(2)