aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-04-03 22:51:50 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2019-04-03 22:51:50 +0200
commit55d7c18787360f934f5afa63d9361ac36319c6ff (patch)
treee1ea1d19d8ce07b4f2c7df8981d08cd53afe9d3d
parentMinor util update regarding quick-records. (diff)
downloadcalp-55d7c18787360f934f5afa63d9361ac36319c6ff.tar.gz
calp-55d7c18787360f934f5afa63d9361ac36319c6ff.tar.xz
Move examples from recurrence internal to tests.
-rw-r--r--module/vcalendar/recurrence/internal.scm7
-rw-r--r--tests/rrule-parse.scm35
2 files changed, 35 insertions, 7 deletions
diff --git a/module/vcalendar/recurrence/internal.scm b/module/vcalendar/recurrence/internal.scm
index b62d75c2..0f03abc0 100644
--- a/module/vcalendar/recurrence/internal.scm
+++ b/module/vcalendar/recurrence/internal.scm
@@ -4,13 +4,6 @@
#:export (make-recur-rule
weekdays intervals))
-;; (list
-;; (build-recur-rules "FREQ=HOURLY")
-;; (build-recur-rules "FREQ=HOURLY;COUNT=3")
-;; (build-recur-rules "FREQ=ERR;COUNT=3")
-;; (build-recur-rules "FREQ=HOURLY;COUNT=err")
-;; (build-recur-rules "FREQ=HOURLY;COUNT=-1"))
-
;; Immutable, since I easily want to be able to generate the recurence set for
;; the same event multiple times.
(define-quick-record recur-rule
diff --git a/tests/rrule-parse.scm b/tests/rrule-parse.scm
new file mode 100644
index 00000000..b3bbe770
--- /dev/null
+++ b/tests/rrule-parse.scm
@@ -0,0 +1,35 @@
+(test-begin "RRULE parse")
+
+(use-modules (vcalendar recurrence parse))
+
+(define-syntax mkrule
+ (syntax-rules ()
+ ((_ (key val) ...)
+ ((record-constructor (@@ (vcalendar recurrence internal) <recur-rule>)
+ (quote (key ...)))
+ (quote val) ...))))
+
+(test-equal (mkrule (freq HOURLY) (wkst MO) (interval 1))
+ (parse-recurrence-rule "FREQ=HOURLY"))
+
+(test-equal (mkrule (freq HOURLY) (count 3) (interval 1) (wkst MO))
+ (parse-recurrence-rule "FREQ=HOURLY;COUNT=3"))
+
+;;; TODO write tests for these cases
+
+(parse-recurrence-rule "FREQ=ERR;COUNT=3")
+ ; TODO this error seems to have an error
+;; => #<<recur-rule> freq: #<<recur-rule> freq: #f until: #f count: #f interval: 1 bysecond: #f byminute: #f byhour: #f byday: #f bymonthday: #f byyearday: #f byweekno: #f bymonth: #f bysetpos: #f wkst: MO> until: #f count: 3 interval: 1 bysecond: #f byminute: #f byhour: #f byday: #f bymonthday: #f byyearday: #f byweekno: #f bymonth: #f bysetpos: #f wkst: MO>
+;; ERR unfulfilled-constraint [ERR] doesn't fulfill constraint of type [FREQ], ignoring
+
+(parse-recurrence-rule "FREQ=HOURLY;COUNT=err")
+;; => #<<recur-rule> freq: HOURLY until: #f count: #f interval: 1
+;; bysecond: #f byminute: #f byhour: #f byday: #f bymonthday: #f
+;; byyearday: #f byweekno: #f bymonth: #f bysetpos: #f wkst: MO>
+;; ERR invalid-value [#f] for key [COUNT], ignoring.
+
+(parse-recurrence-rule "FREQ=HOURLY;COUNT=-1") ; TODO this error seems to have an error
+;; => #<<recur-rule> freq: HOURLY until: #f count: #<<recur-rule> freq: HOURLY until: #f count: #f interval: 1 bysecond: #f byminute: #f byhour: #f byday: #f bymonthday: #f byyearday: #f byweekno: #f bymonth: #f bysetpos: #f wkst: MO> interval: 1 bysecond: #f byminute: #f byhour: #f byday: #f bymonthday: #f byyearday: #f byweekno: #f bymonth: #f bysetpos: #f wkst: MO>
+;; ERR unfulfilled-constraint [-1] doesn't fulfill constraint of type [COUNT], ignoring
+
+(test-end "RRULE parse")