(defpackage #:topic-maps.xtm.tests
(:use #:cl #:topic-maps.tmdm)
(:import-from #:topic-maps.xtm #:deserialize-octets #:xtm-rejection #:xtm-unsupported
#:xtm-xml-error #:error-code #:error-document-iri #:error-source-key #:error-line #:error-column)
(:export #:run-tests #:write-report))
(in-package #:topic-maps.xtm.tests)
(defparameter *document* "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/xtm2/in/example.xtm")
(defvar *checks* nil)
(defvar *cases* nil)
(defvar *outputs* nil)
(defvar *fixture* nil)
(defun check (name truth)
(push name *checks*)
(unless truth (error "XTM test failed: ~A" name))
(format t "XTM-CHECK-PASS ~A~%" name))
(defun bytes (text &optional (encoding :utf-8) bom)
(concatenate '(vector (unsigned-byte 8))
(if bom (ecase encoding (:utf-8 #(239 187 191)) (:utf-16le #(255 254)) (:utf-16be #(254 255))) #())
(babel:string-to-octets text :encoding encoding :use-bom nil)))
(defun file-bytes (path)
(with-open-file (in path :element-type '(unsigned-byte 8))
(let ((data (make-array (file-length in) :element-type '(unsigned-byte 8))))
(assert (= (read-sequence data in) (length data))) data)))
(defun corpus-path (relative) (merge-pathnames relative (topic-maps.test-foundation:default-corpus-root)))
(defun document (body) (format nil "~A" body))
(defun read-body (body &optional (iri *document*))
(deserialize-octets (bytes (document body)) :document-iri iri :source-key "local:xtm-semantic-test"))
(defun by-id (map name)
(find-if (lambda (topic) (member (concatenate 'string *document* "#" name)
(topic-item-identifiers topic) :test #'string=)) (topic-map-topics map)))
(defun by-si (map iri) (find iri (topic-map-topics map) :test (lambda (iri topic) (member iri (topic-subject-identifiers topic) :test #'string=))))
(defun core (map name) (by-si map (concatenate 'string "http://psi.topicmaps.org/iso13250/model/" name)))
(defun condition-from (thunk) (handler-case (progn (funcall thunk) nil) (error (c) c)))
(defun rejection (name source class code)
(let ((c (condition-from (lambda () (deserialize-octets (bytes source) :document-iri *document* :source-key name)))))
(check (concatenate 'string name ":class") (typep c class))
(check (concatenate 'string name ":code") (eq code (error-code c)))
(check (concatenate 'string name ":context") (and (equal (error-document-iri c) *document*) (equal (error-source-key c) name)))
(check (concatenate 'string name ":position") (and (integerp (error-line c)) (plusp (error-line c))
(integerp (error-column c)) (not (minusp (error-column c)))))))
(defun public-state (map)
;; Actual references are retained in the snapshot, not only equivalent XML.
(list (item-identifiers map)
(mapcar (lambda (topic) (list topic (topic-parent topic) (topic-item-identifiers topic)
(topic-subject-identifiers topic) (topic-subject-locators topic)
(topic-names topic) (topic-occurrences topic) (topic-roles-played topic))) (topic-map-topics map))
(mapcar (lambda (a) (list a (association-parent a) (association-type a) (association-scope a) (item-identifiers a)
(mapcar (lambda (r) (list r (association-role-parent r) (association-role-type r)
(association-role-player r) (item-identifiers r))) (association-roles a))))
(topic-map-associations map))))
(defun graph-checks (label map owner type)
(let* ((a (first (topic-map-associations map))) (roles (association-roles a))
(instance (find (core map "instance") roles :key #'association-role-type :test #'eq))
(type-role (find (core map "type") roles :key #'association-role-type :test #'eq)))
(check (concatenate 'string label ":counts") (and (= 5 (length (topic-map-topics map))) (= 1 (length (topic-map-associations map))) (= 2 (length roles))))
(check (concatenate 'string label ":map-parent-eq") (and (eq map (association-parent a)) (every (lambda (topic) (eq map (topic-parent topic))) (topic-map-topics map))))
(check (concatenate 'string label ":association-type-eq") (eq (association-type a) (core map "type-instance")))
(check (concatenate 'string label ":role-parent-eq") (every (lambda (role) (eq a (association-role-parent role))) roles))
(check (concatenate 'string label ":players-eq") (and (eq owner (association-role-player instance)) (eq type (association-role-player type-role))))
(check (concatenate 'string label ":roles-played-eq") (and (member instance (topic-roles-played owner) :test #'eq) (member type-role (topic-roles-played type) :test #'eq)))
(check (concatenate 'string label ":canonical-handles") (and (eq a (canonical-association a)) (every (lambda (r) (eq r (canonical-association-role r))) roles)))))
(defun original-contracts ()
(setf *cases* nil *outputs* nil)
(dolist (name '("empty" "topic" "itemid-tm" "topic-type" "topic-type-duplicate" "merge-three-way"))
(let* ((id (format nil "xtm2/in/~A.xtm" name))
(iri (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" id))
(source (corpus-path id)) (baseline (corpus-path (format nil "xtm2/baseline/~A.xtm.cxtm" name)))
(case (topic-maps.test-foundation:make-test-case :id id :category :valid :source-pathname source
:document-iri iri :expected-outcome :cxtm-equal :expected-baseline baseline
:clauses '("XTM 2.0 4.3-4.9,4.20" "TMDM 5.1-5.3,5.7-5.8,6,7.2" "CXTM 3.13,3.18,4")))
(map (deserialize-octets (file-bytes source) :document-iri iri :source-key id))
(before (public-state map))
(actual (topic-maps.cxtm:canonicalize-octets map :base-locator iri))
(expected (file-bytes baseline)))
(topic-maps.test-foundation:record-result case (if (equalp actual expected) :cxtm-match :cxtm-mismatch)
:diagnostics (list (format nil "Actual ~D bytes; original baseline ~D bytes." (length actual) (length expected))))
(push case *cases*) (push (list id actual expected) *outputs*)
(check (concatenate 'string name ":original-byte-exact") (equalp actual expected))
(check (concatenate 'string name ":pure") (equal before (public-state map)))
(check (concatenate 'string name ":deterministic") (equalp actual (topic-maps.cxtm:canonicalize-octets map :base-locator iri)))
(check (concatenate 'string name ":topic-count") (= (length (topic-map-topics map))
(cond ((member name '("empty" "itemid-tm") :test #'equal) 0) ((member name '("topic-type" "topic-type-duplicate") :test #'equal) 5) (t 1))))
(check (concatenate 'string name ":association-count") (= (length (topic-map-associations map))
(if (member name '("topic-type" "topic-type-duplicate") :test #'equal) 1 0)))
(when (equal name "topic")
(check "topic:actual-item-locator" (equal (topic-item-identifiers (first (topic-map-topics map))) (list (concatenate 'string iri "#topic")))))
(when (equal name "itemid-tm")
(check "map:actual-item-locator" (equal (item-identifiers map) (list (concatenate 'string iri "#the-topic-map")))))
(when (equal name "merge-three-way")
(check "merge:three-identifiers" (= 3 (length (topic-item-identifiers (first (topic-map-topics map)))))))
(when (member name '("topic-type" "topic-type-duplicate") :test #'equal)
(let ((*document* iri)) (graph-checks name map (by-id map "xtm") (by-id map "format"))))))
(setf *cases* (nreverse *cases*) *outputs* (nreverse *outputs*)))
(defun semantic-tests ()
(dolist (body '(""
""))
(let ((map (read-body body)))
(graph-checks (if (search "id='b'/>" body :start2 0 :end2 (min 20 (length body))) "backward" "forward") map (by-id map "a") (by-id map "b"))))
(let* ((map (read-body ""))
(type (by-id map "type")))
(graph-checks "si-hit" map (by-id map "a") type)
(check "si-hit:no-extra-ii" (equal (topic-item-identifiers type) (list (concatenate 'string *document* "#type")))))
(let* ((map (read-body ""))
(type (by-id map "type")))
(graph-checks "forward-si" map (by-id map "a") type)
(check "forward-si:created-ii-retained" (= 2 (length (topic-item-identifiers type)))))
(let* ((map (read-body ""))
(type (by-id map "type")))
(graph-checks "ii-hit" map (by-id map "a") type)
(check "ii-hit:identifiers-unchanged" (= 2 (length (topic-item-identifiers type)))))
(let* ((map (make-topic-map)) (si (intern-topic map :subject-identifier (concatenate 'string *document* "#s")))
(hit (topic-maps.xtm::find-reference-topic map (concatenate 'string *document* "#s"))))
(check "direct-si:actual-eq" (eq si hit))
(check "direct-si:no-ii" (null (topic-item-identifiers si))))
;; Retain the exact object produced by a forward reference, then deserialize
;; a later declaration with the same reader operation in the same context.
(let* ((map (make-topic-map))
(old (topic-maps.xtm::find-reference-topic map (concatenate 'string *document* "#future")))
(other (intern-topic map :subject-identifier "urn:shared"))
(a (make-association map (core-topic-for-test map "type-instance")
(list (list (core-topic-for-test map "instance") old) (list (core-topic-for-test map "type") other))))
(role (find old (association-roles a) :key #'association-role-player :test #'eq)))
(let* ((topic-maps.xtm::*document-iri* *document*) (topic-maps.xtm::*source-key* "retained-forward")
(root (topic-maps.xml:parse-octets
(bytes (document ""))
(make-instance 'topic-maps.xtm::source-handler))))
(topic-maps.xtm::validate-source root)
(topic-maps.xtm::read-topic (first (topic-maps.xtm::elements root)) map))
(check "retained:forward-handle-eq" (and (eq (canonical-topic old) (canonical-topic other)) (not (eq old (canonical-topic old)))))
(check "retained:role-player-canonical" (eq (association-role-player role) (canonical-topic old)))
(check "retained:role-parent-canonical" (eq (association-role-parent role) (canonical-association a)))
(let ((before (public-state map)) (pointer (topic-maps.tmdm::%topic-forward old)))
(topic-maps.cxtm:canonicalize map :base-locator *document*)
(check "retained:cxtm-does-not-mutate" (and (equal before (public-state map)) (eq pointer (topic-maps.tmdm::%topic-forward old))))))
(let ((a (read-body "") ) (b (read-body "" "https://other.example/map.xtm")))
(check "documents:distinct-object" (not (eq (first (topic-map-topics a)) (first (topic-map-topics b)))))
(check "documents:distinct-local-locators" (not (equal (topic-item-identifiers (first (topic-map-topics a))) (topic-item-identifiers (first (topic-map-topics b)))))))
(let ((map (read-body "")))
(check "identity:three-categories" (let ((topic (first (topic-map-topics map))))
(and (= 2 (length (topic-item-identifiers topic)))
(equal '("urn:subject") (topic-subject-identifiers topic))
(equal (list (concatenate 'string (subseq *document* 0 (1+ (position #\/ *document* :from-end t))) "resource")) (topic-subject-locators topic))))))
(let ((map (read-body "")))
(check "unicode:id-collapse" (by-id map "Ä水"))
(check "unicode:href-percent-utf8" (equal '("http://example.org/ä/🦊") (topic-subject-identifiers (first (topic-map-topics map))))))
(dolist (pair '(("../folder/./x#t" "https://example.test/folder/x#t")
("#t" "https://example.test/a/map.xtm#t")
("?q#t" "https://example.test/a/map.xtm?q#t")
("http://EXAMPLE.test:80/a" "http://EXAMPLE.test:80/a")
("http://example.test/a%20b#t" "http://example.test/a b#t")))
(let ((topic-maps.xtm::*document-iri* *document*) (topic-maps.xtm::*source-key* "iri-test"))
(check (concatenate 'string "iri:" (first pair))
(equal (topic-maps.xtm::resolve-iri (first pair) "https://example.test/a/map.xtm" nil) (second pair)))))
(let* ((source (document ""))
(one (read-body ""))
(two (read-body "")))
(check "order:canonical-independence" (equal (topic-maps.cxtm:canonicalize one :base-locator *document*) (topic-maps.cxtm:canonicalize two :base-locator *document*)))
(dolist (spec '((:utf-8 t "UTF-8") (:utf-16le t "UTF-16") (:utf-16be t "UTF-16")
(:utf-16le nil "UTF-16LE") (:utf-16be nil "UTF-16BE")))
(destructuring-bind (encoding bom label) spec
(let* ((xml (format nil "~A" label source))
(map (deserialize-octets (bytes xml encoding bom) :document-iri *document*)))
(check (format nil "encoding:~A:~A" encoding bom) (equal (topic-maps.cxtm:canonicalize one :base-locator *document*) (topic-maps.cxtm:canonicalize map :base-locator *document*))))))))
(defun core-topic-for-test (map name)
(intern-topic map :subject-identifier (concatenate 'string "http://psi.topicmaps.org/iso13250/model/" name)))
(defun identity-cascade-tests ()
(let ((map (read-body "")))
(check "transitive:mixed-identifiers-one-topic" (= 1 (length (topic-map-topics map))))
(check "transitive:three-ii-two-si" (let ((topic (first (topic-map-topics map))))
(and (= 3 (length (topic-item-identifiers topic))) (= 2 (length (topic-subject-identifiers topic)))))))
(let* ((map (read-body ""))
(s (by-id map "s")) (x (by-id map "x")))
(check "reference:subject-locator-is-not-si-or-ii" (and s x (not (eq s x)) (= 6 (length (topic-map-topics map))))))
(let* ((map (make-topic-map)) (topic-maps.xtm::*document-iri* *document*)
(topic-maps.xtm::*source-key* "association-cascade")
(root (topic-maps.xml:parse-octets
(bytes (document ""))
(make-instance 'topic-maps.xtm::source-handler)))
(nodes (topic-maps.xtm::elements (topic-maps.xtm::validate-source root))))
(topic-maps.xtm::read-topic (first nodes) map)
(let* ((associations (topic-map-associations map))
(roles (loop for a in associations append (association-roles a)))
(old-type (by-id map "t2")))
(check "cascade:before-two-associations" (= 2 (length associations)))
(topic-maps.xtm::read-topic (second nodes) map)
(let ((a (first (topic-map-associations map))))
(check "cascade:after-one-association" (and (= 1 (length (topic-map-associations map))) (= 2 (length (association-roles a)))))
(check "cascade:retained-association-handles-eq" (every (lambda (old) (eq a (canonical-association old))) associations))
(check "cascade:retained-role-handles-eq" (every (lambda (r) (member (canonical-association-role r) (association-roles a) :test #'eq)) roles))
(check "cascade:stored-type-player-canonical" (every (lambda (r) (and (eq a (association-role-parent r))
(eq (association-role-type r) (canonical-topic (association-role-type r)))
(eq (association-role-player r) (canonical-topic (association-role-player r))))) (association-roles a)))
(check "cascade:retained-topic-handle-eq" (eq (canonical-topic old-type) (by-id map "t1")))
(let* ((handles (append associations roles (list old-type)))
(pointers (mapcar #'topic-maps.tmdm::canonical-item handles))
(before (public-state map)))
(topic-maps.cxtm:canonicalize map :base-locator *document*)
(check "cascade:all-handles-pure" (and (equal before (public-state map))
(every #'eq pointers (mapcar #'topic-maps.tmdm::canonical-item handles))))))))
(let* ((prefixed "")
(source (bytes prefixed))
(a (deserialize-octets source :document-iri *document* :source-key "disk:a"))
(b (deserialize-octets source :document-iri *document* :source-key "memory:b")))
(check "namespace:prefix-equivalent" (by-id a "a"))
(check "source-key:not-topic-identity" (equal (topic-item-identifiers (by-id a "a")) (topic-item-identifiers (by-id b "a")))))
(let* ((map (read-body ""))
(type (find-if (lambda (topic) (member "https://external.example/map.xtm#unfetched" (topic-item-identifiers topic) :test #'equal)) (topic-map-topics map))))
(graph-checks "external-reference:no-retrieval" map (by-id map "a") type)))
(defun negative-tests ()
(dolist (spec '(("missing-id" "" :missing-id)
("invalid-id" "" :invalid-id)
("id-colon" "" :invalid-id)
("id-empty" "" :invalid-id)
("id-spaces" "" :invalid-id)
("duplicate-id" "" :duplicate-id)
("unknown-attribute" "" :unexpected-attribute)
("qualified-attribute" "" :unexpected-attribute)
("unknown-element" "" :unexpected-element)
("wrong-namespace-child" "" :invalid-namespace)
("topic-identity-order" "" :element-order)
("map-identity-order" "" :element-order)
("instance-duplicate" "" :duplicate-instance-of)
("empty-instance" "" :empty-instance-of)
("missing-href" "" :missing-attribute)
("nonempty-locator" "" :unexpected-child)
("locator-text" "text" :unexpected-text)
("non-whitespace" "text" :unexpected-text)
("no-ref-fragment" "" :invalid-topic-ref)
("bad-ref-fragment" "" :invalid-topic-ref)
("empty-ref-fragment" "" :invalid-topic-ref)
("xpointer-ref" "" :invalid-topic-ref)
("relative-colon" "" :invalid-iri)
("decoded-control" "" :invalid-iri)
("bad-percent" "" :invalid-percent-escape)
("bad-percent-utf8" "" :invalid-percent-utf8)
("invalid-iri" "" :invalid-iri)))
(rejection (first spec) (document (second spec)) 'xtm-rejection (third spec)))
(rejection "missing-version" "" 'xtm-rejection :missing-attribute)
(rejection "version-21" "" 'xtm-rejection :invalid-version)
(rejection "no-namespace" "" 'xtm-rejection :invalid-namespace)
(rejection "namespace-10" "" 'xtm-rejection :invalid-namespace)
(rejection "xml-misnested" "" 'xtm-xml-error :xml-not-well-formed)
(rejection "xml-duplicate-attribute" "" 'xtm-xml-error :xml-not-well-formed)
(rejection "xml-undeclared-prefix" "" 'xtm-xml-error :xml-not-well-formed)
(dolist (body '("" ""
""
"]>"))
(rejection (concatenate 'string "doctype:" body) (concatenate 'string body (document "")) 'xtm-xml-error :doctype-forbidden))
(dolist (spec '(("unsupported-name" "Name" :unsupported-construct)
("unsupported-occurrence" "v" :unsupported-construct)
("unsupported-association" "" :unsupported-construct)
("unsupported-mergemap" "" :unsupported-construct)))
(rejection (first spec) (document (second spec)) 'xtm-unsupported (third spec)))
(rejection "unsupported-reifier" "" 'xtm-unsupported :reification)
(let ((c (condition-from (lambda () (read-body (format nil "~%~%"))))))
(check "diagnostic:multiline-observed-position" (and (typep c 'xtm-rejection) (= 3 (error-line c)) (plusp (error-column c)))))
(dolist (iri '(nil "relative.xtm" "https://example.test/a#fragment"))
(let ((c (condition-from (lambda () (deserialize-octets (bytes (document "")) :document-iri iri :source-key "document")))))
(check (format nil "document-iri:~S" iri) (and (typep c 'xtm-rejection) (eq (error-code c) :invalid-document-iri)))))
(check "api:raw-bytes-required" (typep (condition-from (lambda () (deserialize-octets (document "") :document-iri *document*))) 'type-error))
(let* ((source "")
(c (condition-from (lambda () (read-body source)))))
(check "tmdm:identifier-conflict-not-xml-or-xtm" (and (typep c 'item-identifier-error) (not (typep c 'topic-maps.xtm:xtm-error))))
(check "tmdm:identifier-conflict-specific" (eq (item-identifier-error-code c) :duplicate-item-identifier)))
(let ((c (condition-from (lambda () (read-body "")))))
(check "tmdm:core-subject-conflict-preserved" (and (typep c 'core-subject-error) (eq :core-subject-conflict (core-subject-error-code c)))))
(dolist (bad '(#(195 40) #(192 175) #(226 130) #(237 160 128)))
(let ((c (condition-from (lambda () (deserialize-octets
(concatenate '(vector (unsigned-byte 8)) (bytes "")) :document-iri *document*)))))
(check (format nil "actual-reader:invalid-utf8:~S" bad) (and (typep c 'xtm-xml-error) (eq :xml-not-well-formed (error-code c))))))
;; Astral Unicode in an href exercises the qualified UTF-16 decoder through
;; the real XTM reader. No pre-decoding strings are accepted by its API.
(dolist (encoding '(:utf-16le :utf-16be))
(let ((map (deserialize-octets (bytes (document "") encoding t) :document-iri *document*)))
(check (format nil "actual-reader:astral-surrogate:~A" encoding) (by-si map "urn:🦊"))))
(dolist (bad '(#(0 216) #(0 220) #(0 216 65 0)))
(let ((c (condition-from (lambda ()
(deserialize-octets (concatenate '(vector (unsigned-byte 8))
(bytes "" :utf-16le t) (coerce bad '(vector (unsigned-byte 8))) (bytes "" :utf-16le)) :document-iri *document*)))))
(check (format nil "actual-reader:invalid-surrogate:~S" bad) (typep c 'xtm-xml-error))))
;; Verify the required entry point is actually called exactly once and sees
;; the original octet vector by EQ, not a reconstructed decoded XML string.
(let* ((original (symbol-function 'topic-maps.xml:parse-octets))
(source (bytes (document ""))) (calls 0) (same nil))
(unwind-protect
(progn (setf (symbol-function 'topic-maps.xml:parse-octets)
(lambda (bytes handler) (incf calls) (setf same (eq source bytes)) (funcall original bytes handler)))
(deserialize-octets source :document-iri *document*)
(check "boundary:real-parse-octets-only-once" (and (= 1 calls) same)))
(setf (symbol-function 'topic-maps.xml:parse-octets) original))))
(defun helper-source-test ()
(let* ((id "ctm/in/mergemap-xtm.sub")
(iri (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" id))
(*document* iri) (map (deserialize-octets (file-bytes (corpus-path id)) :document-iri iri :source-key id)))
(graph-checks "direct-sub" map (by-id map "lars") (by-id map "person"))
(check "direct-sub:exact-lars-ii" (equal (list (concatenate 'string iri "#lars")) (topic-item-identifiers (by-id map "lars"))))
(check "direct-sub:exact-person-ii" (equal (list (concatenate 'string iri "#person")) (topic-item-identifiers (by-id map "person"))))
(check "direct-sub:no-names-occurrences" (every (lambda (topic) (and (null (topic-names topic)) (null (topic-occurrences topic)))) (topic-map-topics map)))
(setf *fixture* map)))
(defun run-tests ()
(setf *checks* nil *fixture* nil)
(original-contracts) (semantic-tests) (identity-cascade-tests) (negative-tests) (helper-source-test)
(check "checks:unique-test-names" (= (length *checks*) (length (remove-duplicates *checks* :test #'equal))))
(format t "XTM-SUMMARY ~D PASS 0 FAIL; 6 original CXTM PASS; helper source PASS~%" (length *checks*))
(length *checks*))
(defun write-report (pathname)
(let ((cases *cases*) (fixture *fixture*))
(flet ((fields (&rest args) (apply #'topic-maps.test-foundation::fields args))
(array (items) (coerce items 'vector)))
(with-open-file (out pathname :direction :output :if-exists :supersede :external-format :utf-8)
(topic-maps.test-foundation::emit-json-value
(fields "scope" "XTM 2.0 identity subset, six registered positive contracts only; no CTM Mergemap integration"
"corpusCommit" "cd165b150176c1d6842b37be9cc9051b40d4996b"
"statuses" (fields "pass" (count :pass cases :key #'topic-maps.test-foundation:test-case-status)
"fail" (count :fail cases :key #'topic-maps.test-foundation:test-case-status)
"unsupported" 0 "not-run" 0)
"otherCorpusInputs" (fields "positiveUnexecuted" (- (length (directory (corpus-path "xtm2/in/*.xtm"))) (length cases))
"negativeUnregisteredUnexecuted" (length (directory (corpus-path "xtm2/invalid/*.xtm"))))
"checks" (array (reverse *checks*))
"cases" (array (loop for case in cases collect
(fields "id" (topic-maps.test-foundation:test-case-id case)
"documentIRI" (topic-maps.test-foundation:test-case-document-iri case)
"status" (string-downcase (symbol-name (topic-maps.test-foundation:test-case-status case)))
"actualOutcome" (string-downcase (symbol-name (topic-maps.test-foundation:test-case-actual-outcome case)))
"diagnostics" (array (topic-maps.test-foundation:test-case-diagnostics case)))))
"helperSource" (fields "id" "ctm/in/mergemap-xtm.sub" "status" "pass" "topics" (length (topic-map-topics fixture))
"associations" (length (topic-map-associations fixture)) "roles" 2
"ctmMergemapContract" "NOT-RUN; direct helper deserialization only")
"actualAndExpected" (array (loop for (id actual expected) in *outputs* collect
(fields "id" id "actual" (babel:octets-to-string actual :encoding :utf-8)
"expected" (babel:octets-to-string expected :encoding :utf-8) "byteLength" (length actual))))) out)
(terpri out)))))