(require :asdf) (assert (string= "2.5.4" (lisp-implementation-version))) (setf *compile-verbose* nil *load-verbose* nil) (asdf:load-asd #P"/Users/rgb/workspace/topic-maps/topic-maps.asd") (asdf:load-system "topic-maps/xtm/tests") (in-package :topic-maps.xtm.tests) (let* ((map (make-topic-map)) (owner (intern-topic map :item-identifier "urn:owner")) (a (add-default-name owner "N")) (r (intern-topic map :item-identifier "urn:r")) (s (intern-topic map :item-identifier "urn:s"))) (assert (eq a (canonical-topic-name a))) (assert (eq a (set-item-reifier a r))) (assert (eq r (item-reifier a))) (assert (eq a (topic-reified r))) (let ((same (add-default-name owner "N"))) (assert (eq a same)) (assert (eq a (set-item-reifier same r)))) (let ((returned (set-item-reifier a s))) (assert (eq returned (canonical-topic-name a))) (assert (eq (canonical-topic r) (canonical-topic s))) (assert (eq returned (topic-reified r))) (assert (same-identifiers-p '("urn:r" "urn:s") (item-identifiers (item-reifier a))))) (let* ((other (add-default-name owner "different")) (before (map-reifier-state map)) (c (condition-from (lambda () (set-item-reifier other (item-reifier a)))))) (assert (eq 'reification-error (type-of c))) (assert (eq :reifier-conflict (reification-error-code c))) (assert (equal before (map-reifier-state map))) (format t "NAME-REIFIER-API-CONDITION: ~A ~A; rejected assignment atomic~%" (type-of c) (reification-error-code c))) (assert (topic-maps.tmdm::validate-map-reification map))) (dolist (both '(nil t)) (let* ((map (make-topic-map)) (p (intern-topic map :item-identifier "urn:p")) (q (intern-topic map :item-identifier "urn:q")) (a (add-default-name p "N")) (b (add-default-name q "N")) (r (intern-topic map :item-identifier "urn:r")) (s (intern-topic map :item-identifier "urn:s"))) (add-item-identifier a "urn:a") (add-item-identifier b "urn:b") (set-item-reifier a r) (when both (set-item-reifier b s)) (merge-topics p q) (let ((current (canonical-topic-name a))) (assert (eq current (canonical-topic-name b))) (assert (not (eq current a))) (assert (eq current (first (topic-names (canonical-topic p))))) (assert (same-identifiers-p '("urn:a" "urn:b") (item-identifiers current))) (assert (eq (canonical-topic r) (item-reifier current))) (assert (eq current (topic-reified r))) (when both (assert (eq (canonical-topic r) (canonical-topic s))) (assert (eq current (topic-reified s)))) (assert (topic-maps.tmdm::validate-map-reification map)) (format t "NAME-REIFIER-API-NORMALIZATION: two old Names -> one new canonical Name; ~A Reifier relationship(s) preserved~%" (if both 2 1))))) (let* ((map (make-topic-map)) (owner (intern-topic map :item-identifier "urn:owner")) (a (add-default-name owner "A")) (b (add-default-name owner "B")) (r (intern-topic map :item-identifier "urn:r")) (s (intern-topic map :item-identifier "urn:s"))) (set-item-reifier a r) (set-item-reifier b s) (let* ((before (map-reifier-state map)) (c (condition-from (lambda () (merge-topics r s))))) (assert (eq 'reification-error (type-of c))) (assert (eq :reifier-conflict (reification-error-code c))) (assert (equal before (map-reifier-state map)))) (add-item-identifier a "urn:name") (let* ((before (map-reifier-state map)) (c (condition-from (lambda () (intern-topic map :item-identifier "urn:name"))))) (assert (typep c 'item-identifier-error)) (assert (eq :duplicate-item-identifier (item-identifier-error-code c))) (assert (equal before (map-reifier-state map))) (format t "NAME-REIFIER-API-CONDITION: ~A ~A; rejected Topic creation atomic~%" (type-of c) (item-identifier-error-code c)))) (format t "NAME-REIFIER-API-PREFLIGHT-PASS: canonical add-name result, inverse, preserved/merged Reifiers, identifier union and native conflict atomicity~%")