]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - reports/slice-21f/model-preflight.lisp
Support XTM topic map reification (Slice 21L)
[topic-maps.git] / reports / slice-21f / model-preflight.lisp
1 (require :asdf)
2 (assert (string= "2.5.4" (lisp-implementation-version)))
3 (setf *compile-verbose* nil *load-verbose* nil)
4 (asdf:load-asd (merge-pathnames "topic-maps.asd" (uiop:ensure-directory-pathname (uiop:getenv "TOPIC_MAPS_21F_ROOT"))))
5 (asdf:load-system "topic-maps/xtm/tests")
6 (in-package :topic-maps.xtm.tests)
7 (let ((rows nil) (*checks* nil))
8 (dolist (target '("parent" "theme"))
9 (dolist (kind '("subjectIdentifier" "subjectLocator" "itemIdentity"))
10 (let ((names nil) (label (format nil "preflight:~A:~A" target kind)) (*name-controls* nil))
11 (flet ((theme-source (id locator)
12 (if (equal kind "itemIdentity") (format nil "<topic id='~A'/>" id)
13 (format nil "<topic id='~A'><~A href='~A'/></topic>" id kind locator))))
14 (staged-name-control label
15 (if (equal target "parent")
16 (format nil "<topic id='a'>~A<name><scope><topicRef href='#s'/></scope><value>N</value></name></topic><topic id='b'>~A<name><scope><topicRef href='#s'/></scope><value>N</value></name></topic><topic id='bridge'><~A href='~A'/><~A href='~A'/></topic>"
17 (if (equal kind "itemIdentity") "" (format nil "<~A href='urn:one'/>" kind))
18 (if (equal kind "itemIdentity") "" (format nil "<~A href='urn:two'/>" kind))
19 kind (if (equal kind "itemIdentity") "#a" "urn:one") kind (if (equal kind "itemIdentity") "#b" "urn:two"))
20 (concatenate 'string "<topic id='a'><name><scope><topicRef href='#s1'/></scope><value>N</value></name><name><scope><topicRef href='#s2'/></scope><value>N</value></name></topic>"
21 (theme-source "s1" "urn:one") (theme-source "s2" "urn:two")
22 (format nil "<topic id='bridge'><~A href='~A'/><~A href='~A'/></topic>"
23 kind (if (equal kind "itemIdentity") "#s1" "urn:one") kind (if (equal kind "itemIdentity") "#s2" "urn:two"))))
24 (lambda (map step)
25 (if (equal target "parent")
26 (when (<= step 2)
27 (let ((name (first (topic-names (by-id map (if (= step 1) "a" "b"))))))
28 (push name names) (add-item-identifier name (format nil "urn:name:~A" step))))
29 (when (= step 1)
30 (setf names (topic-names (by-id map "a")))
31 (add-item-identifier (first names) "urn:name:1") (add-item-identifier (second names) "urn:name:2"))))
32 (lambda (map)
33 (let* ((owner (by-id map "a")) (name (first (topic-names owner))))
34 (check (concatenate 'string label ":retained-eq-and-identifier-union")
35 (and (= 1 (length (topic-names owner)))
36 (every (lambda (old) (and (eq name (canonical-topic-name old)) (eq owner (topic-name-parent old))
37 (same-identifiers-p '("urn:name:1" "urn:name:2") (item-identifiers old)))) names)
38 (same-identifiers-p '("urn:name:1" "urn:name:2") (item-identifiers name))))))))
39 (push (first *name-controls*) rows))))
40 (assert (= 6 (length rows)))
41 (with-open-file (out (uiop:getenv "TOPIC_MAPS_21F_PREFLIGHT") :direction :output :if-exists :supersede)
42 (topic-maps.test-foundation::emit-json-value
43 (topic-maps.test-foundation::fields "kind" "pre-implementation-existing-TMDM-identifier-retention"
44 "allSixMergesPassed" :true "checks" (coerce (reverse *checks*) 'vector) "controls" (coerce (nreverse rows) 'vector)) out)
45 (terpri out)))