From c84877fb8641d6ced25118026b9b1c3cf7e16a71 Mon Sep 17 00:00:00 2001 From: geoff Date: Wed, 12 Jul 2017 20:12:59 +0100 Subject: [PATCH] Added Chibi defines for inexact->exact and exact->inexact since R7RS doesn't define them any more. --- run-tests.scm | 38 ++++++++++++++++++++++++++++---------- srfi-19.scm | 3 +++ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/run-tests.scm b/run-tests.scm index 57efbc9..a5f5965 100644 --- a/run-tests.scm +++ b/run-tests.scm @@ -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" @@ -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" @@ -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) diff --git a/srfi-19.scm b/srfi-19.scm index be55331..9ba3131 100644 --- a/srfi-19.scm +++ b/srfi-19.scm @@ -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)))