branch: elpa/with-simulated-input
commit 47aa40dbe115e578f0ed3b01c45a770371589e17
Author: Ryan C. Thompson <[email protected]>
Commit: Ryan C. Thompson <[email protected]>
Handle the case where SECS exactly equals a timer's time
To avoid floating point issues, we just unconditionally add 0.0001 to
SECS.
---
tests/test-with-simulated-input.el | 2 +-
with-simulated-input.el | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tests/test-with-simulated-input.el
b/tests/test-with-simulated-input.el
index 273ccffc3d..f533759a8b 100644
--- a/tests/test-with-simulated-input.el
+++ b/tests/test-with-simulated-input.el
@@ -107,7 +107,7 @@
(spy-calls-reset 'idle-canary))
(it "should run idle timers"
(run-with-idle-timer 500 nil 'idle-canary)
- (wsi-simulate-idle-time 501)
+ (wsi-simulate-idle-time 500)
(expect 'idle-canary :to-have-been-called))
(it "should not run idle times with longer times"
(run-with-idle-timer 500 nil 'set 'idle-canary)
diff --git a/with-simulated-input.el b/with-simulated-input.el
index e4787cb936..5eb8bdf8c8 100644
--- a/with-simulated-input.el
+++ b/with-simulated-input.el
@@ -247,6 +247,9 @@ though they would run during real idle time."
(setq secs
(cl-loop for timer in timer-idle-list
maximize (float-time (timer--time timer)))))
+ ;; Add a small fudge factor to deal with SECS being exactly equal to
+ ;; a timer's time, to avoid floating point issues.
+ (setq secs (+ secs 0.0001))
(cl-loop
with already-run-timers = nil
with stop-time = (seconds-to-time secs)
@@ -263,7 +266,7 @@ though they would run during real idle time."
if (time-less-p wsi-simulated-idle-time
(timer--time next-timer))
do (setq wsi-simulated-idle-time
- (timer--time next-timer))
+ (timer--time next-timer))
when actually-wait
do (sleep-for (float-time (time-subtract wsi-simulated-idle-time
previous-idle-time)))