diff options
| author | Eli Zaretskii | 2018-10-20 12:52:52 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-10-20 12:52:52 +0300 |
| commit | efb214622a0f4e077c09e721d134552dfe76ef70 (patch) | |
| tree | cd2394d5da30aded30a73c22b44b6e9512da96c2 | |
| parent | d684f5d5bc33249038e779a4b2009fd0761f09d5 (diff) | |
| download | emacs-efb214622a0f4e077c09e721d134552dfe76ef70.tar.gz emacs-efb214622a0f4e077c09e721d134552dfe76ef70.zip | |
Fix 'timer-next-integral-multiple-of-time'
* lisp/emacs-lisp/timer.el
(timer-next-integral-multiple-of-time): Fix recent change for
fractional values of SECS. (Bug#33071)
* test/lisp/emacs-lisp/timer-tests.el
(timer-next-integral-multiple-of-time-2): New test.
| -rw-r--r-- | lisp/emacs-lisp/timer.el | 2 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/timer-tests.el | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el index 927e640feaa..e140738d9f3 100644 --- a/lisp/emacs-lisp/timer.el +++ b/lisp/emacs-lisp/timer.el | |||
| @@ -101,7 +101,7 @@ of SECS seconds since the epoch. SECS may be a fraction." | |||
| 101 | time | 101 | time |
| 102 | (encode-time time 1000000000000))) | 102 | (encode-time time 1000000000000))) |
| 103 | (hz (cdr ticks-hz)) | 103 | (hz (cdr ticks-hz)) |
| 104 | (s-ticks (* secs hz)) | 104 | (s-ticks (round (* secs hz))) |
| 105 | (more-ticks (+ (car ticks-hz) s-ticks))) | 105 | (more-ticks (+ (car ticks-hz) s-ticks))) |
| 106 | (encode-time (cons (- more-ticks (% more-ticks s-ticks)) hz)))) | 106 | (encode-time (cons (- more-ticks (% more-ticks s-ticks)) hz)))) |
| 107 | 107 | ||
diff --git a/test/lisp/emacs-lisp/timer-tests.el b/test/lisp/emacs-lisp/timer-tests.el index c5971ee7687..7a5b9263b0b 100644 --- a/test/lisp/emacs-lisp/timer-tests.el +++ b/test/lisp/emacs-lisp/timer-tests.el | |||
| @@ -44,4 +44,12 @@ | |||
| 44 | (timer-next-integral-multiple-of-time '(0 0 0 1) (1+ (ash 1 53))) | 44 | (timer-next-integral-multiple-of-time '(0 0 0 1) (1+ (ash 1 53))) |
| 45 | (list (ash 1 (- 53 16)) 1)))) | 45 | (list (ash 1 (- 53 16)) 1)))) |
| 46 | 46 | ||
| 47 | (ert-deftest timer-next-integral-multiple-of-time-2 () | ||
| 48 | "Test bug#33071." | ||
| 49 | (let* ((tc (current-time)) | ||
| 50 | (tce (encode-time tc 100)) | ||
| 51 | (nt (timer-next-integral-multiple-of-time tc 0.01)) | ||
| 52 | (nte (encode-time nt 100))) | ||
| 53 | (should (= (car nte) (1+ (car tce)))))) | ||
| 54 | |||
| 47 | ;;; timer-tests.el ends here | 55 | ;;; timer-tests.el ends here |