diff options
author | Damien George <damien.p.george@gmail.com> | 2015-03-20 23:50:33 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-03-20 23:50:33 +0000 |
commit | db80b65402237345aecb1bc4c9575ae975624e2c (patch) | |
tree | 55c777f9ccf10faffd1d0362e3188ea9661b5c29 /tests | |
parent | 49d8e5ebaa195b0227aa04332749f7910d72d1ff (diff) | |
download | micropython-db80b65402237345aecb1bc4c9575ae975624e2c.tar.gz micropython-db80b65402237345aecb1bc4c9575ae975624e2c.zip |
tests: Make pyb/timer test check callback timing properly.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pyb/timer_callback.py | 24 | ||||
-rw-r--r-- | tests/pyb/timer_callback.py.exp | 4 |
2 files changed, 20 insertions, 8 deletions
diff --git a/tests/pyb/timer_callback.py b/tests/pyb/timer_callback.py index 060182053d..864dd479ed 100644 --- a/tests/pyb/timer_callback.py +++ b/tests/pyb/timer_callback.py @@ -22,20 +22,28 @@ def cb3(x): return cb4 # create a timer with a callback, using callback(None) to stop -tim = Timer(1, freq=1000, callback=cb1) -pyb.delay(10) +tim = Timer(1, freq=100, callback=cb1) +pyb.delay(5) +print("before cb1") +pyb.delay(15) # create a timer with a callback, using deinit to stop -tim = Timer(2, freq=1000, callback=cb2) -pyb.delay(10) +tim = Timer(2, freq=100, callback=cb2) +pyb.delay(5) +print("before cb2") +pyb.delay(15) # create a timer, then set the freq, then set the callback tim = Timer(4) -tim.init(freq=2000) +tim.init(freq=100) tim.callback(cb1) -pyb.delay(10) +pyb.delay(5) +print("before cb1") +pyb.delay(15) # test callback with a closure -tim.init(freq=3000) +tim.init(freq=100) tim.callback(cb3(3)) -pyb.delay(10) +pyb.delay(5) +print("before cb4") +pyb.delay(15) diff --git a/tests/pyb/timer_callback.py.exp b/tests/pyb/timer_callback.py.exp index 5fd751fde3..9be7cf5b90 100644 --- a/tests/pyb/timer_callback.py.exp +++ b/tests/pyb/timer_callback.py.exp @@ -1,4 +1,8 @@ +before cb1 cb1 +before cb2 cb2 +before cb1 cb1 +before cb4 cb4 3 |