From 0acf868bb72e0b94683f447baa367999d401b770 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 4 Mar 2018 00:38:15 +1100 Subject: [PATCH] tests/extmod/time_ms_us: Fix ticks tests, ticks_diff args are reversed. --- tests/extmod/time_ms_us.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/extmod/time_ms_us.py b/tests/extmod/time_ms_us.py index 4d0287da31..135cf1e096 100644 --- a/tests/extmod/time_ms_us.py +++ b/tests/extmod/time_ms_us.py @@ -7,8 +7,16 @@ except AttributeError: utime.sleep_ms(1) utime.sleep_us(1) -print(utime.ticks_diff(utime.ticks_ms(), utime.ticks_ms()) <= 1) -print(utime.ticks_diff(utime.ticks_us(), utime.ticks_us()) <= 500) + +t0 = utime.ticks_ms() +t1 = utime.ticks_ms() +print(0 <= utime.ticks_diff(t1, t0) <= 1) + +t0 = utime.ticks_us() +t1 = utime.ticks_us() +print(0 <= utime.ticks_diff(t1, t0) <= 500) # ticks_cpu may not be implemented, at least make sure it doesn't decrease -print(utime.ticks_diff(utime.ticks_cpu(), utime.ticks_cpu()) >= 0) +t0 = utime.ticks_cpu() +t1 = utime.ticks_cpu() +print(utime.ticks_diff(t1, t0) >= 0)