mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +02:00
(test-time-comparision, test-time-arithmatic): New procs.
Add time comparison tests using new procs. Thanks to Alex Shinn.
This commit is contained in:
parent
fa5a8c00ec
commit
176d0e0bfd
1 changed files with 30 additions and 6 deletions
|
@ -80,6 +80,14 @@ incomplete numerical tower implementation.)"
|
|||
(let ((time (make-time ,a 12345 67890123)))
|
||||
(time=? time (,b->a-sym (,a->b-sym time)))))))
|
||||
|
||||
(define (test-time-comparison cmp a b)
|
||||
(pass-if (format #f "~A works" cmp)
|
||||
(cmp a b)))
|
||||
|
||||
(define (test-time-arithmetic op a b res)
|
||||
(pass-if (format #f "~A works" op)
|
||||
(time=? (op a b) res)))
|
||||
|
||||
(with-test-prefix "SRFI date/time library"
|
||||
;; check for typos and silly errors
|
||||
(pass-if "date-zone-offset is defined"
|
||||
|
@ -126,7 +134,23 @@ incomplete numerical tower implementation.)"
|
|||
(with-tz "CET"
|
||||
(string->date "2001-06-01@14:00" "~Y-~m-~d@~H:~M")))
|
||||
(date->time-utc
|
||||
(make-date 0 0 0 12 1 6 2001 0)))))
|
||||
(make-date 0 0 0 12 1 6 2001 0))))
|
||||
;; check time comparison procedures
|
||||
(let* ((time1 (make-time time-monotonic 0 0))
|
||||
(time2 (make-time time-monotonic 0 0))
|
||||
(time3 (make-time time-monotonic 385907 998360432))
|
||||
(time4 (make-time time-monotonic 385907 998360432)))
|
||||
(test-time-comparison time<=? time1 time3)
|
||||
(test-time-comparison time<? time1 time3)
|
||||
(test-time-comparison time=? time1 time2)
|
||||
(test-time-comparison time>=? time3 time3)
|
||||
(test-time-comparison time>? time3 time2))
|
||||
;; check time arithmetic procedures
|
||||
(let* ((time1 (make-time time-monotonic 0 0))
|
||||
(time2 (make-time time-monotonic 385907 998360432))
|
||||
(diff (time-difference time2 time1)))
|
||||
(test-time-arithmetic add-duration time1 diff time2)
|
||||
(test-time-arithmetic subtract-duration time2 diff time1)))
|
||||
|
||||
;; Local Variables:
|
||||
;; eval: (put 'with-tz 'scheme-indent-function 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue