async support #6

Open
opened 2021-06-07 07:36:28 +00:00 by bung87 · 2 comments
bung87 commented 2021-06-07 07:36:28 +00:00 (Migrated from github.com)

am wondering whether it's not hard add async pragma to method and prepend waitFor to all methods call

am wondering whether it's not hard add `async` pragma to method and prepend `waitFor` to all methods call
jyapayne commented 2021-06-08 00:24:08 +00:00 (Migrated from github.com)

Is there a benefit to doing this? I would suggest simply calling async methods inside the test bodies.

Is there a benefit to doing this? I would suggest simply calling async methods inside the test bodies.
bung87 commented 2021-06-08 03:38:36 +00:00 (Migrated from github.com)

to make the test code clean , so there's no much waitFor , just await, like asynctest does

proc someAsyncProc {.async.} =  # perform some async operations using await  
  discard
suite "test async proc":
  setup:    # invoke await in the test setup:   
    await someAsyncProc()
  teardown:    # invoke await in the test teardown:    
    await someAsyncProc()
  test "async test":    # invoke await in tests:    
    await someAsyncProc()
to make the test code clean , so there's no much `waitFor` , just `await`, like [asynctest](https://github.com/markspanbroek/asynctest) does ``` nim proc someAsyncProc {.async.} = # perform some async operations using await discard suite "test async proc": setup: # invoke await in the test setup: await someAsyncProc() teardown: # invoke await in the test teardown: await someAsyncProc() test "async test": # invoke await in tests: await someAsyncProc() ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jyapayne/einheit#6
No description provided.