]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - reports/slice-21m/api-preflight.lisp
Implement noncyclic XTM mergeMap content import (Slice 22E)
[topic-maps.git] / reports / slice-21m / 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 (let* ((map (make-topic-map)) (owner (intern-topic map :item-identifier "urn:owner"))
8 (a (add-default-name owner "N")) (r (intern-topic map :item-identifier "urn:r"))
9 (s (intern-topic map :item-identifier "urn:s")))
10 (assert (eq a (canonical-topic-name a)))
11 (assert (eq a (set-item-reifier a r)))
12 (assert (eq r (item-reifier a))) (assert (eq a (topic-reified r)))
13 (let ((same (add-default-name owner "N")))
14 (assert (eq a same)) (assert (eq a (set-item-reifier same r))))
15 (let ((returned (set-item-reifier a s)))
16 (assert (eq returned (canonical-topic-name a)))
17 (assert (eq (canonical-topic r) (canonical-topic s)))
18 (assert (eq returned (topic-reified r)))
19 (assert (same-identifiers-p '("urn:r" "urn:s") (item-identifiers (item-reifier a)))))
20 (let* ((other (add-default-name owner "different")) (before (map-reifier-state map))
21 (c (condition-from (lambda () (set-item-reifier other (item-reifier a))))))
22 (assert (eq 'reification-error (type-of c))) (assert (eq :reifier-conflict (reification-error-code c)))
23 (assert (equal before (map-reifier-state map)))
24 (format t "NAME-REIFIER-API-CONDITION: ~A ~A; rejected assignment atomic~%" (type-of c) (reification-error-code c)))
25 (assert (topic-maps.tmdm::validate-map-reification map)))
26 (dolist (both '(nil t))
27 (let* ((map (make-topic-map)) (p (intern-topic map :item-identifier "urn:p")) (q (intern-topic map :item-identifier "urn:q"))
28 (a (add-default-name p "N")) (b (add-default-name q "N"))
29 (r (intern-topic map :item-identifier "urn:r")) (s (intern-topic map :item-identifier "urn:s")))
30 (add-item-identifier a "urn:a") (add-item-identifier b "urn:b")
31 (set-item-reifier a r) (when both (set-item-reifier b s))
32 (merge-topics p q)
33 (let ((current (canonical-topic-name a)))
34 (assert (eq current (canonical-topic-name b))) (assert (not (eq current a)))
35 (assert (eq current (first (topic-names (canonical-topic p)))))
36 (assert (same-identifiers-p '("urn:a" "urn:b") (item-identifiers current)))
37 (assert (eq (canonical-topic r) (item-reifier current))) (assert (eq current (topic-reified r)))
38 (when both (assert (eq (canonical-topic r) (canonical-topic s))) (assert (eq current (topic-reified s))))
39 (assert (topic-maps.tmdm::validate-map-reification map))
40 (format t "NAME-REIFIER-API-NORMALIZATION: two old Names -> one new canonical Name; ~A Reifier relationship(s) preserved~%" (if both 2 1)))))
41 (let* ((map (make-topic-map)) (owner (intern-topic map :item-identifier "urn:owner"))
42 (a (add-default-name owner "A")) (b (add-default-name owner "B"))
43 (r (intern-topic map :item-identifier "urn:r")) (s (intern-topic map :item-identifier "urn:s")))
44 (set-item-reifier a r) (set-item-reifier b s)
45 (let* ((before (map-reifier-state map)) (c (condition-from (lambda () (merge-topics r s)))))
46 (assert (eq 'reification-error (type-of c))) (assert (eq :reifier-conflict (reification-error-code c)))
47 (assert (equal before (map-reifier-state map))))
48 (add-item-identifier a "urn:name")
49 (let* ((before (map-reifier-state map)) (c (condition-from (lambda () (intern-topic map :item-identifier "urn:name")))))
50 (assert (typep c 'item-identifier-error)) (assert (eq :duplicate-item-identifier (item-identifier-error-code c)))
51 (assert (equal before (map-reifier-state map)))
52 (format t "NAME-REIFIER-API-CONDITION: ~A ~A; rejected Topic creation atomic~%" (type-of c) (item-identifier-error-code c))))
53 (format t "NAME-REIFIER-API-PREFLIGHT-PASS: canonical add-name result, inverse, preserved/merged Reifiers, identifier union and native conflict atomicity~%")