From 20948a3d54ff560a3d029b8bfc9761dcbbad9312 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 20 Aug 2020 23:11:44 +1000 Subject: [PATCH] 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 --- tests/extmod/uasyncio_basic.py | 10 +++++++++- tests/extmod/uasyncio_basic.py.exp | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/extmod/uasyncio_basic.py b/tests/extmod/uasyncio_basic.py index f6685fa674..c88908d99b 100644 --- a/tests/extmod/uasyncio_basic.py +++ b/tests/extmod/uasyncio_basic.py @@ -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()) diff --git a/tests/extmod/uasyncio_basic.py.exp b/tests/extmod/uasyncio_basic.py.exp index 447d05d5e0..6673978769 100644 --- a/tests/extmod/uasyncio_basic.py.exp +++ b/tests/extmod/uasyncio_basic.py.exp @@ -2,4 +2,5 @@ start after sleep short long -took 20 40 +negative +took 20 40 0