aboutsummaryrefslogtreecommitdiff
path: root/tests/test/recurrence-simple.scm
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/test/recurrence-simple.scm (renamed from tests/recurrence-simple.scm)173
1 files changed, 91 insertions, 82 deletions
diff --git a/tests/recurrence-simple.scm b/tests/test/recurrence-simple.scm
index d5a35802..0f421b05 100644
--- a/tests/recurrence-simple.scm
+++ b/tests/test/recurrence-simple.scm
@@ -4,19 +4,23 @@
;; most are instead in recurrence-advanced.scm.
;;; Code:
-(((srfi srfi-41) stream-take stream-map stream->list stream-car)
- ((datetime) day-stream mon)
- ((vcomponent base) extract prop)
-
- ((hnh util exceptions) warnings-are-errors warning-handler)
- ((guile) format @@)
-
- ((vcomponent formats ical parse) parse-calendar)
- ((vcomponent formats xcal parse) sxcal->vcomponent)
- ((vcomponent recurrence)
- parse-recurrence-rule
- make-recur-rule
- generate-recurrence-set))
+(define-module (test recurrence-simple)
+ :use-module (srfi srfi-64)
+ :use-module (srfi srfi-88)
+ :use-module ((srfi srfi-41)
+ :select (stream-take stream-map stream->list stream-car))
+ :use-module ((datetime) :select (day-stream mon))
+ :use-module ((vcomponent base) :select (extract prop))
+ :use-module ((hnh util exceptions)
+ :select (warnings-are-errors warning-handler))
+ :use-module ((vcomponent formats ical parse)
+ :select (parse-calendar))
+ :use-module ((vcomponent formats xcal parse)
+ :select (sxcal->vcomponent))
+ :use-module ((vcomponent recurrence)
+ :select (parse-recurrence-rule
+ make-recur-rule
+ generate-recurrence-set)))
;;; Test that basic parsing or recurrence rules work.
@@ -24,28 +28,28 @@
(parse-recurrence-rule "FREQ=HOURLY"))
(test-equal (make-recur-rule freq: 'HOURLY count: 3 interval: 1 wkst: mon)
- (parse-recurrence-rule "FREQ=HOURLY;COUNT=3"))
+ (parse-recurrence-rule "FREQ=HOURLY;COUNT=3"))
;;; Test that recurrence rule parsing fails where appropriate
(parameterize ((warnings-are-errors #t)
- (warning-handler identity)) ; silence warnings
- (test-error "Invalid FREQ" 'warning
- (parse-recurrence-rule "FREQ=ERR;COUNT=3"))
-
- (test-error "Negative COUNT" 'warning
- (parse-recurrence-rule "FREQ=HOURLY;COUNT=-1"))
-
+ (warning-handler identity))
+ (test-error "Invalid FREQ"
+ 'warning
+ (parse-recurrence-rule "FREQ=ERR;COUNT=3"))
+ (test-error "Negative COUNT"
+ 'warning
+ (parse-recurrence-rule "FREQ=HOURLY;COUNT=-1"))
(test-error "Invalid COUNT"
- 'wrong-type-argument
- (parse-recurrence-rule "FREQ=HOURLY;COUNT=err")) )
+ 'wrong-type-argument
+ (parse-recurrence-rule "FREQ=HOURLY;COUNT=err")))
;;; Test that basic recurrence works
;;; also see the neighbour test file recurrence.scm for more tests.
(define ev
(call-with-input-string
- "BEGIN:VEVENT
+ "BEGIN:VEVENT
DTSTART;VALUE=DATE:20190302
RRULE:FREQ=DAILY
END:VEVENT"
@@ -55,44 +59,44 @@ END:VEVENT"
(stream-car (generate-recurrence-set ev)))
(test-assert "Generate some"
- (stream->list (stream-take 5 (generate-recurrence-set ev))))
+ (stream->list
+ (stream-take 5 (generate-recurrence-set ev))))
(test-equal "Generate First"
(stream->list
- 5 (stream-map (extract 'DTSTART)
- (generate-recurrence-set ev)))
- (stream->list
- 5 (day-stream
- (prop ev 'DTSTART))))
+ 5
+ (stream-map
+ (extract 'DTSTART)
+ (generate-recurrence-set ev)))
+ (stream->list 5 (day-stream (prop ev 'DTSTART))))
;; We run the exact same thing a secound time, since I had an error with
;; that during development.
(test-equal "Generate Again"
(stream->list
- (stream-take
- 5 (stream-map (extract 'DTSTART)
- (generate-recurrence-set ev))))
+ (stream-take
+ 5
+ (stream-map
+ (extract 'DTSTART)
+ (generate-recurrence-set ev))))
(stream->list
- (stream-take
- 5 (day-stream
- (prop ev 'DTSTART)))))
-
+ (stream-take 5 (day-stream (prop ev 'DTSTART)))))
(define ev
(call-with-input-string
- "BEGIN:VEVENT
+ "BEGIN:VEVENT
DTSTART:20190302T100000
RRULE:FREQ=DAILY
END:VEVENT"
- parse-calendar) )
+ parse-calendar))
(test-assert "daily 10:00"
(stream-car (generate-recurrence-set ev)))
(define ev
(call-with-input-string
- "BEGIN:VEVENT
+ "BEGIN:VEVENT
DTSTART:20190302T100000
DTEND:20190302T120000
RRULE:FREQ=DAILY
@@ -104,7 +108,7 @@ END:VEVENT"
(define ev
(call-with-input-string
- "BEGIN:VEVENT
+ "BEGIN:VEVENT
DTSTART:20190302T100000
DTEND:20190302T120000
RRULE:FREQ=WEEKLY
@@ -116,7 +120,7 @@ END:VEVENT"
(define ev
(call-with-input-string
- "BEGIN:VEVENT
+ "BEGIN:VEVENT
DTSTART;TZID=Europe/Stockholm:20190302T100000
DTEND;TZID=Europe/Stockholm:20190302T120000
RRULE:FREQ=WEEKLY
@@ -128,7 +132,7 @@ END:VEVENT"
(define ev
(call-with-input-string
- "BEGIN:VEVENT
+ "BEGIN:VEVENT
DTSTART;TZID=Europe/Stockholm:20190302T100000
DTEND;TZID=Europe/Stockholm:20190302T120000
RRULE:FREQ=WEEKLY
@@ -141,7 +145,7 @@ END:VEVENT"
(define ev
(call-with-input-string
- "BEGIN:VEVENT
+ "BEGIN:VEVENT
DTSTART;TZID=Europe/Stockholm:20190302T100000
RRULE:FREQ=WEEKLY
DTEND;TZID=Europe/Stockholm:20190302T120000
@@ -155,46 +159,45 @@ END:VEVENT"
(define ev
(call-with-input-string
- "BEGIN:VEVENT
+ "BEGIN:VEVENT
DTSTART:20180117T170000
RRULE:FREQ=WEEKLY
LOCATION:~
END:VEVENT"
- parse-calendar))
+ parse-calendar))
(test-assert "Just location"
(stream-car (generate-recurrence-set ev)))
-
(define ev
- (call-with-input-string
- "BEGIN:VEVENT
+ (call-with-input-string
+ "BEGIN:VEVENT
DTSTART;TZID=Europe/Stockholm:20180117T170000
DTEND;TZID=Europe/Stockholm:20180117T200000
RRULE:FREQ=WEEKLY
END:VEVENT"
- parse-calendar))
+ parse-calendar))
(test-assert "Same times"
(stream-car (generate-recurrence-set ev)))
(define ev
- (call-with-input-string
- "BEGIN:VEVENT
+ (call-with-input-string
+ "BEGIN:VEVENT
DTSTART;TZID=Europe/Stockholm:20180117T170000
RRULE:FREQ=WEEKLY
DTEND;TZID=Europe/Stockholm:20180117T200000
SEQUENCE:1
LOCATION:~
END:VEVENT"
- parse-calendar))
+ parse-calendar))
;; errer in dtend ?
(test-assert "Full test"
(stream-car (generate-recurrence-set ev)))
-;;; Tests that exceptions (in the recurrence-id meaning)
+;;; Tests that exceptions (in the recurrence-id meaning)
;;; in recurrence sets are handled correctly.
;;; TODO Is however far from done.
@@ -205,21 +208,27 @@ END:VEVENT"
(children
(vevent
(properties
- (summary (text "Changing type on Recurrence-id."))
+ (summary
+ (text "Changing type on Recurrence-id."))
(uid (text ,uid))
(dtstart (date "20090127"))))
(vevent
(properties
- (summary (text "Changing type on Recurrence-id."))
+ (summary
+ (text "Changing type on Recurrence-id."))
(uid (text ,uid))
- (dtstart (params (TZID "Europe/Stockholm"))
- (date-time "20100127T120000"))
+ (dtstart
+ (params (TZID "Europe/Stockholm"))
+ (date-time "20100127T120000"))
(recurrence-id (date "20100127"))
- (summary "This instance only has a time component")))))
+ (summary
+ "This instance only has a time component")))))
(define ev
- (call-with-input-string
- (format #f "BEGIN:VCALENDAR
+ (call-with-input-string
+ (format
+ #f
+ "BEGIN:VCALENDAR
BEGIN:VEVENT
SUMMARY:Changing type on Recurrence-id.
UID:~a
@@ -233,9 +242,9 @@ RECURRENCE-ID;VALUE=DATE:20100127
SUMMARY:This instance only has a time component
END:VEVENT
END:VCALENDAR"
- uid uid)
- parse-calendar))
-
+ uid
+ uid)
+ parse-calendar))
(test-assert "Changing type on Recurrence id."
(stream->list 10 (generate-recurrence-set ev)))
@@ -243,31 +252,31 @@ END:VCALENDAR"
;;; Earlier I failed to actually parse the recurrence parts, in short, 1 ≠ "1".
(test-assert "Test that xcal recur rules are parseable"
- ((@@ (vcomponent formats xcal parse) handle-value)
- 'recur 'props-are-unused-for-recur
- '((freq "WEEKLY")
- (interval "1")
- (wkst "MO"))))
+ ((@@ (vcomponent formats xcal parse) handle-value)
+ 'recur
+ 'props-are-unused-for-recur
+ '((freq "WEEKLY") (interval "1") (wkst "MO"))))
(define ev
(sxcal->vcomponent
- '(vevent
- (properties
- (summary (text "reptest"))
- (dtend (date-time "2021-01-13T02:00:00"))
- (dtstart (date-time "2021-01-13T01:00:00"))
- (uid (text "RNW198S6QANQPV1C4FDNFH6ER1VZX6KXEYNB"))
- (rrule (recur (freq "WEEKLY")
- (interval "1")
- (wkst "MO")))
- (dtstamp (date-time "2021-01-13T01:42:20Z"))
- (sequence (integer "0")))
- (components))))
+ '(vevent
+ (properties
+ (summary (text "reptest"))
+ (dtend (date-time "2021-01-13T02:00:00"))
+ (dtstart (date-time "2021-01-13T01:00:00"))
+ (uid (text "RNW198S6QANQPV1C4FDNFH6ER1VZX6KXEYNB"))
+ (rrule (recur (freq "WEEKLY")
+ (interval "1")
+ (wkst "MO")))
+ (dtstamp (date-time "2021-01-13T01:42:20Z"))
+ (sequence (integer "0")))
+ (components))))
(test-assert
- "Check that recurrence rule commint from xcal also works"
+ "Check that recurrence rule commint from xcal also works"
(generate-recurrence-set ev))
+
;;; TODO test here, for byday parsing, and multiple byday instances in one recur element
;;; TODO which should also test serializing and deserializing to xcal.
;;; For example, the following rules specify every workday