Skip to content

Commit 965a87b

Browse files
committed
tests/extmod: Add test for sleep_ms value that overflows ticks.
Addresses micropython#9516. Signed-off-by: Damien George <[email protected]>
1 parent 815920c commit 965a87b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

tests/extmod/uasyncio_micropython.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ async def main():
2222
await uasyncio.sleep_ms(1)
2323
print(utime.ticks_diff(utime.ticks_ms(), t0) < 100)
2424

25+
try:
26+
# Sleep 1ms beyond maximum allowed sleep value
27+
await uasyncio.sleep_ms(utime.ticks_add(0, -1) // 2 + 1)
28+
except OverflowError:
29+
print("OverflowError")
30+
2531
# When task finished before the timeout
2632
print(await uasyncio.wait_for_ms(task(1, 5), 50))
2733

tests/extmod/uasyncio_micropython.py.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
True
2+
OverflowError
23
task start 1
34
task end 1
45
2

0 commit comments

Comments
 (0)