Skip to content

Commit

Permalink
Added Chibi defines for inexact->exact and exact->inexact since R7RS …
Browse files Browse the repository at this point in the history
…doesn't define them any more.
  • Loading branch information
geoff committed Jul 12, 2017
1 parent 5b02dca commit c84877f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
38 changes: 28 additions & 10 deletions run-tests.scm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@

(test-begin "SRFI 19")

(define (tm:date= d1 d2)
(and (= (date-year d1) (date-year d2))
(= (date-month d1) (date-month d2))
(= (date-day d1) (date-day d2))
(= (date-hour d1) (date-hour d2))
(= (date-second d1) (date-second d2))
(= (date-nanosecond d1) (date-nanosecond d2))
(= (date-zone-offset d1) (date-zone-offset d2))))


(test-group
"[Existence Check] Constants"
Expand Down Expand Up @@ -308,16 +317,6 @@
)


(define (tm:date= d1 d2)
(and (= (date-year d1) (date-year d2))
(= (date-month d1) (date-month d2))
(= (date-day d1) (date-day d2))
(= (date-hour d1) (date-hour d2))
(= (date-second d1) (date-second d2))
(= (date-nanosecond d1) (date-nanosecond d2))
(= (date-zone-offset d1) (date-zone-offset d2))))


(test-group
"[SRFI Tests] TAI-Date Conversions"
(test-assert "time-tai->date conversion test 1"
Expand Down Expand Up @@ -1126,4 +1125,23 @@
(tm:date= (make-date 0 14 13 12 1 1 2017 0)
(string->date "~ Sunday 01 1 12:13:14Z 17" "~~ ~A ~m ~e ~k:~M:~S~z ~y")))))

(test-group
"Round-tripping"
(let ((test-date (make-date 15 14 13 12 1 1 2017 0)))
(test-assert "Date equals itself"
(tm:date= test-date test-date))
(test-assert "UTC roundtrip conversion"
(tm:date= test-date
(time-utc->date (date->time-utc test-date) (date-zone-offset test-date))))
(test-assert "TAI roundtrip conversion"
(tm:date= test-date
(time-tai->date (date->time-tai test-date) (date-zone-offset test-date))))
;; Shouldn't this round-trip too?
#;
(test-assert "Monotonic roundtrip conversion"
(tm:date= test-date
(time-monotonic->date (date->time-monotonic test-date) (date-zone-offset test-date)))))
)


(test-end)
3 changes: 3 additions & 0 deletions srfi-19.scm
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
(define (date-time-zone-offset value)
(chibi:time-offset value))

(define inexact->exact exact)
(define exact->inexact inexact)

(define (current-process-milliseconds)
(floor (/ (chibi:timeval-microseconds
(chibi:resource-usage-time (chibi:get-resource-usage))) 1000)))
Expand Down

0 comments on commit c84877f

Please sign in to comment.