aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-12-01 23:13:32 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2023-12-01 23:15:01 +0100
commit1a18c30f06b97392414a8a69f04b52918bdfe554 (patch)
tree421fdb303abf4adb3476debaa7287484076a4a84
parentProperly specify as-list and with-parameters interaction. (diff)
downloadcalp-1a18c30f06b97392414a8a69f04b52918bdfe554.tar.gz
calp-1a18c30f06b97392414a8a69f04b52918bdfe554.tar.xz
Repair format tests.
The test have been really broken for a while, since the return type of `parameters` changed somewhere along the line. The serializers are now updated to the new API, and the tests updated to compare components correctly!
-rw-r--r--doc/ref/vcomponent/general.texi2
-rw-r--r--module/vcomponent/formats/ical.scm4
-rw-r--r--module/vcomponent/formats/ical/output.scm5
-rw-r--r--module/vcomponent/formats/xcal/output.scm4
-rw-r--r--tests/unit/formats/run.scm50
5 files changed, 40 insertions, 25 deletions
diff --git a/doc/ref/vcomponent/general.texi b/doc/ref/vcomponent/general.texi
index ab914a5b..0f12b417 100644
--- a/doc/ref/vcomponent/general.texi
+++ b/doc/ref/vcomponent/general.texi
@@ -103,7 +103,7 @@ Curried version of @var{prop}.
@defun properties comopnent
@example
-((key . value) ...)
+((key value) ...)
@end example
@end defun
diff --git a/module/vcomponent/formats/ical.scm b/module/vcomponent/formats/ical.scm
index dddca946..6005c550 100644
--- a/module/vcomponent/formats/ical.scm
+++ b/module/vcomponent/formats/ical.scm
@@ -4,9 +4,7 @@
:use-module ((vcomponent formats ical parse)
:select (parse-calendar))
:export (serialize
- deserialize
- )
- )
+ deserialize))
(define (serialize component port)
diff --git a/module/vcomponent/formats/ical/output.scm b/module/vcomponent/formats/ical/output.scm
index 5fa004bb..9e227b56 100644
--- a/module/vcomponent/formats/ical/output.scm
+++ b/module/vcomponent/formats/ical/output.scm
@@ -148,16 +148,17 @@
(for-each
;; Special cases depending on key.
;; Value formatting is handled in @code{value-format}.
+
(match-lambda
[(? (compose internal-field? car)) 'noop]
- [(key vlines ...)
+ [(key (vlines ...))
(for vline in vlines
(display (vline->string vline))
(display "\r\n"))]
- [(key . vline)
+ [(key vline)
(display (vline->string vline))
(display "\r\n")])
(properties component))
diff --git a/module/vcomponent/formats/xcal/output.scm b/module/vcomponent/formats/xcal/output.scm
index 6d5e0656..a5f8a934 100644
--- a/module/vcomponent/formats/xcal/output.scm
+++ b/module/vcomponent/formats/xcal/output.scm
@@ -111,7 +111,7 @@
(match-lambda
[(? (compose internal-field? car)) #f]
- [(key vlines ...)
+ [(key (vlines ...))
(remove null?
`(,(xml xcal (downcase-symbol key))
,(parameters-tag (reduce assq-merge
@@ -120,7 +120,7 @@
,@(for vline in vlines
(vline->value-tag vline))))]
- [(key . vline)
+ [(key vline)
(remove null?
`(,(xml xcal (downcase-symbol key))
,(parameters-tag (parameters vline))
diff --git a/tests/unit/formats/run.scm b/tests/unit/formats/run.scm
index 775a1cdc..860ccae9 100644
--- a/tests/unit/formats/run.scm
+++ b/tests/unit/formats/run.scm
@@ -1,4 +1,5 @@
(define-module (test formats run)
+ :use-module (srfi srfi-1)
:use-module (srfi srfi-64)
:use-module (srfi srfi-88)
:use-module ((hnh util) :select (->))
@@ -11,6 +12,7 @@
:use-module ((vcomponent formats ical) :prefix #{ics:}#)
:use-module ((vcomponent formats xcal) :prefix #{xcs:}#)
:use-module ((vcomponent formats sxcal) :prefix #{sxcs:}#)
+ :use-module ((vcomponent) :select (vcomponent-equal?))
:use-module (sxml namespaced)
:use-module ((calp namespaces) :select (xcal))
:use-module (hnh test xmllint)
@@ -32,15 +34,18 @@
version: "2.0"
(list
(vevent
- attach: (with-parameters fmttype: "text/plain"
- encoding: "BASE64"
- value: "BINARY"
- (-> "\n"
- (string->bytevector
- (make-transcoder (utf-8-codec)))))
+ attach:
+ (as-list
+ ;; TODO this creates a vline with a vline as its value
+ (list (with-parameters fmttype: "text/plain"
+ encoding: "BASE64"
+ value: "BINARY"
+ (-> "\n"
+ (string->bytevector
+ (make-transcoder (utf-8-codec)))))))
;; categories: '("a" "b")
class: 'PUBLIC
- comment: "A comment"
+ comment: (as-list (list "A comment"))
description: "Descrition of the event"
description: (with-parameters language: "sv" "Beskrivning av händelsen")
;; geo: (geo y: 10 x: 20)
@@ -67,22 +72,32 @@
;; Assert serialize is set
+ ;; String representation of pre-vetted representation of the format
+ ;; (e.g. target.ics)
(define target
(call-with-input-file (path-append (dirname (current-filename))
reference)
read-string))
+ ;; The reference component (defined above),
+ ;; serialized into the target format
(define serialized-component
(call-with-output-string
(lambda (port) (serialize ev port))))
+ ;; Check that the serialization suceeded
(test-equal (string-append "serialise " name)
target serialized-component)
+ ;; If a parser is given, check that re-parsing the serialized component
+ ;; returns the original component.
(when parse
- (test-equal (string-append "parse " name)
- (list ev)
- (call-with-input-string serialized-component parse))))
+ (test-group (string-append "parse " name)
+ ;; List since parse always returns lists.
+ (for-each (lambda (target parsed)
+ (test-assert (vcomponent-equal? target parsed)))
+ (list ev)
+ (call-with-input-string serialized-component parse)))))
@@ -91,11 +106,6 @@
;;; to ensure that all implementations are compatible.
;;; However, reflowing data for better diffs is acceptable.
-;;; TODO remove this.
-;;; iCalendar disabled since the internal vcomponent format isn't yet
-;;; fully defined.
-(test-skip "iCalendar")
-
(test-group "iCalendar"
(run-test
"iCalendar" "target.ics"
@@ -111,7 +121,9 @@
(namespaced-sxml->sxml
((@@ (vcomponent formats sxcal) serialize/object) ev)
`((,xcal . xcal)))
- p))))
+ p))
+ ;; TODO parse
+ ))
(test-group "xCalendar"
(run-test
@@ -120,7 +132,9 @@
(-> (call-with-output-string
(lambda (port) (xcs:serialize ev port)))
xmllint
- (display p)))))
+ (display p)))
+ ;; TODO parse
+ ))
@@ -129,6 +143,8 @@
(vcomponent formats xcal parse)
(vcomponent formats xcal types)
+ (vcomponent formats sxcal)
+
(vcomponent formats ical)
(vcomponent formats ical output)
(vcomponent formats ical parse)