]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - tests/ctm-report.lisp
test(ctm): register forty original Slice 20A contracts
[topic-maps.git] / tests / ctm-report.lisp
1 (in-package #:topic-maps.ctm.tests)
2
3 (defun model-observation (map)
4 "Plain observation data, not CXTM serialization or canonical ordering."
5 (let ((topics (topic-map-topics map)))
6 (topic-maps.test-foundation::fields
7 "topicCount" (length topics)
8 "nameCount" (reduce #'+ topics :key (lambda (topic) (length (topic-names topic))) :initial-value 0)
9 "topics"
10 (topic-maps.test-foundation::json-array
11 (loop for topic in topics for index from 1 collect
12 (topic-maps.test-foundation::fields
13 "ordinal" index "parentIsMap" (if (eq map (topic-parent topic)) :true :false)
14 "itemIdentifiers" (topic-maps.test-foundation::json-array (topic-item-identifiers topic))
15 "subjectIdentifiers" (topic-maps.test-foundation::json-array (topic-subject-identifiers topic))
16 "subjectLocators" (topic-maps.test-foundation::json-array (topic-subject-locators topic))
17 "names"
18 (topic-maps.test-foundation::json-array
19 (loop for name in (topic-names topic) collect
20 (topic-maps.test-foundation::fields
21 "value" (topic-name-value name)
22 "typeTopicOrdinal" (1+ (position (topic-name-type name) topics :test #'eq))
23 "parentTopicOrdinal" (1+ (position (topic-name-parent name) topics :test #'eq)))))))))))
24
25 (defun write-slice-report (pathname semantic-pathname)
26 (let ((*checks* nil))
27 (multiple-value-bind (corpus observations) (exercise-corpus)
28 (setf *observations* observations)
29 (topic-maps.test-foundation:write-validation-report
30 corpus pathname
31 :infrastructure-checks topic-maps.tests::*last-checks*
32 :implementation '(:ctm t :tmdm t :scope "Slice 3: unary/binary Associations and Roles with same-map reference replacement and duplicate merging; no CXTM canonicalizer"))
33 (with-open-file (out semantic-pathname :direction :output :if-exists :supersede :if-does-not-exist :create)
34 (topic-maps.test-foundation::emit-json-value
35 (topic-maps.test-foundation::fields
36 "schemaVersion" 1 "kind" "semantic-observations-not-cxtm"
37 "qualification" (getf (topic-maps.test-foundation:corpus-metadata corpus) :qualification)
38 "passed" (length *last-checks*) "failed" 0
39 "checks" (topic-maps.test-foundation::json-array *last-checks*)
40 "cases"
41 (topic-maps.test-foundation::json-array
42 (loop for observation in observations collect
43 (let* ((id (getf observation :id))
44 (case (first (topic-maps.test-foundation:select-cases corpus :id id))))
45 (topic-maps.test-foundation::fields
46 "id" id "status" "pass" "ctmSource"
47 (uiop:read-file-string (topic-maps.test-foundation:test-case-source-pathname case) :external-format :utf-8)
48 "documentIRI" (getf observation :document-iri)
49 "ctmClauses" (topic-maps.test-foundation::json-array (topic-maps.test-foundation:test-case-clauses case))
50 "tmdmClauses" (topic-maps.test-foundation::json-array
51 (append '("TMDM 5.1" "TMDM 5.2" "TMDM 5.3.5")
52 (when (string= id "ctm/in/name.ctm") '("TMDM 5.4"))))
53 "actualObjects" (model-observation (getf observation :topic-map))))))) out)
54 (terpri out)))))