tests/extmod: Add test for uasyncio.sleep of a negative time.

It should take 0 time to await on a negative sleep.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2020-08-20 23:11:44 +10:00
parent 5f9b105244
commit 20948a3d54
2 changed files with 11 additions and 2 deletions

View File

@ -36,8 +36,16 @@ async def main():
t1 = ticks()
await delay_print(0.04, "long")
t2 = ticks()
await delay_print(-1, "negative")
t3 = ticks()
print("took {} {}".format(round(ticks_diff(t1, t0), -1), round(ticks_diff(t2, t1), -1)))
print(
"took {} {} {}".format(
round(ticks_diff(t1, t0), -1),
round(ticks_diff(t2, t1), -1),
round(ticks_diff(t3, t2), -1),
)
)
asyncio.run(main())

View File

@ -2,4 +2,5 @@ start
after sleep
short
long
took 20 40
negative
took 20 40 0