]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - reports/slice-21o/api-preflight.lisp
perf(tmdm): index topic normalization merge candidates
[topic-maps.git] / reports / slice-21o / api-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 #P"/Users/rgb/workspace/topic-maps/topic-maps.asd")
5 (asdf:load-system "topic-maps/xtm/tests")
6 (in-package :topic-maps.xtm.tests)
7 (dolist (both '(nil t))
8 (let* ((map (make-topic-map)) (p (intern-topic map :item-identifier "urn:p")) (q (intern-topic map :item-identifier "urn:q"))
9 (s (intern-topic map :item-identifier "urn:scope")) (n (add-default-name p "N")) (m (add-default-name q "N"))
10 (a (add-variant n "V" :scope (list s))) (b (add-variant m "V" :scope (list s)))
11 (r (intern-topic map :item-identifier "urn:r")) (u (intern-topic map :item-identifier "urn:u")))
12 (assert (eq a (canonical-variant a))) (assert (eq a (set-item-reifier a r)))
13 (assert (eq r (item-reifier a))) (assert (eq a (topic-reified r)))
14 (let ((same (add-variant n "V" :scope (list s))))
15 (assert (eq same (canonical-variant a))) (assert (eq r (item-reifier same)))
16 (assert (eq same (topic-reified r))))
17 (add-item-identifier a "urn:a") (add-item-identifier b "urn:b")
18 (when both (set-item-reifier b u))
19 (merge-topics p q)
20 (let ((current (canonical-variant a)))
21 (assert (eq current (canonical-variant b))) (assert (not (eq current a)))
22 (assert (eq (canonical-topic-name n) (variant-parent current)))
23 (assert (eq (canonical-topic-name n) (canonical-topic-name m)))
24 (assert (same-identifiers-p '("urn:a" "urn:b") (item-identifiers current)))
25 (assert (eq (canonical-topic r) (item-reifier current))) (assert (eq current (topic-reified r)))
26 (when both (assert (eq (canonical-topic r) (canonical-topic u))) (assert (eq current (topic-reified u))))
27 (assert (topic-maps.tmdm::validate-map-reification map))
28 (format t "VARIANT-REIFIER-API-NORMALIZATION: ~A existing Reifier(s), identifiers and old handles preserved~%" (if both 2 1)))))
29 (let* ((map (make-topic-map)) (p (intern-topic map :item-identifier "urn:p")) (s (intern-topic map :item-identifier "urn:s"))
30 (n (add-default-name p "N")) (a (add-variant n "A" :scope (list s))) (b (add-variant n "B" :scope (list s)))
31 (r (intern-topic map :item-identifier "urn:r")) (u (intern-topic map :item-identifier "urn:u")))
32 (set-item-reifier a r) (set-item-reifier b u)
33 (dolist (operation (list (lambda () (set-item-reifier b r)) (lambda () (merge-topics r u))))
34 (let* ((before (map-reifier-state map)) (c (condition-from operation)))
35 (assert (eq 'reification-error (type-of c))) (assert (eq :reifier-conflict (reification-error-code c)))
36 (assert (equal before (map-reifier-state map)))
37 (format t "VARIANT-REIFIER-API-CONDITION: ~A ~A; atomic~%" (type-of c) (reification-error-code c))))
38 (add-item-identifier a "urn:variant")
39 (let* ((before (map-reifier-state map)) (c (condition-from (lambda () (intern-topic map :item-identifier "urn:variant")))))
40 (assert (typep c 'item-identifier-error)) (assert (eq :duplicate-item-identifier (item-identifier-error-code c)))
41 (assert (equal before (map-reifier-state map)))
42 (format t "VARIANT-REIFIER-API-CONDITION: ~A ~A; atomic~%" (type-of c) (item-identifier-error-code c))))
43 (format t "VARIANT-REIFIER-API-PREFLIGHT-PASS: normalize, assign II, resolve Reifier by II, set on current Variant, retain canonical result~%")