(in-package #:topic-maps.xtm.tests) (defvar *occurrence-reifier-native* nil) (defun orr-native-tests () ;; The same native TMDM checks run before the Reader change and in ASDF. ;; These manually built API probes are never original corpus executions. (setf *occurrence-reifier-native* nil) (dolist (both '(nil t)) (let* ((label (if both "two-reifiers" "one-reifier")) (map (make-topic-map)) (p (intern-topic map :item-identifier "urn:p")) (q (intern-topic map :item-identifier "urn:q")) (type (intern-topic map :item-identifier "urn:type")) (s (intern-topic map :item-identifier "urn:scope")) (a (add-occurrence p type "V" :scope (list s))) (b (add-occurrence q type "V" :scope (list s))) (r (intern-topic map :item-identifier "urn:r")) (u (intern-topic map :item-identifier "urn:u"))) (add-item-identifier a "urn:o1") (add-item-identifier b "urn:o2") (check (format nil "occurrence-reifier-native:~A:assign-and-inverse" label) (and (eq a (set-item-reifier a r)) (eq r (item-reifier a)) (eq a (topic-reified r)))) (when both (set-item-reifier b u)) (merge-topics p q) (let ((current (canonical-occurrence a))) (check (format nil "occurrence-reifier-native:~A:equal-occurrences-old-handles-and-II-union" label) (and (eq current (canonical-occurrence b)) (not (eq a current)) (not (eq b current)) (= 1 (length (all-occurrences map))) (eq (canonical-topic p) (occurrence-parent current)) (same-identifiers-p '("urn:o1" "urn:o2") (item-identifiers current)) (eq (canonical-topic r) (item-reifier current)) (eq current (topic-reified r)) (equal "V" (occurrence-value current)) (equal (string-datatype) (occurrence-datatype current)) (equal (list s) (occurrence-scope current)) (ik-current-p map))) (when both (check "occurrence-reifier-native:two-reifiers:Topics-merge-identifiers-and-inverse" (and (eq (canonical-topic r) (canonical-topic u)) (eq current (topic-reified u)) (same-identifiers-p '("urn:r" "urn:u") (item-identifiers (item-reifier current)))))) (push (mm-fields "label" label "kind" "native-TMDM-probe-not-original-contract" "model" (ik-model map) "oldOccurrenceHandlesResolveEQ" :true "reifierTopicsMerged" (if both :true :false)) *occurrence-reifier-native*)))) (let* ((map (make-topic-map)) (p (intern-topic map :item-identifier "urn:p")) (type (intern-topic map :item-identifier "urn:type")) (a (add-occurrence p type "A")) (b (add-occurrence p type "B")) (r (intern-topic map :item-identifier "urn:r")) (u (intern-topic map :item-identifier "urn:u"))) (set-item-reifier a r) (set-item-reifier b u) (dolist (row (list (list "assignment-to-different-Occurrence" (lambda () (set-item-reifier b r))) (list "late-Reifier-Topic-merge" (lambda () (merge-topics r u))))) (let* ((before (ik-state map)) (c (condition-from (second row)))) (check (format nil "occurrence-reifier-native:~A:exact-atomic-conflict" (first row)) (and (eq (type-of c) 'reification-error) (eq :reifier-conflict (reification-error-code c)) (equal before (ik-state map)) (eq a (topic-reified r)) (eq b (topic-reified u)) (ik-current-p map))) (push (mm-fields "label" (first row) "kind" "native-TMDM-probe-not-original-contract" "condition" (mm-condition c) "nativeOperationUnchanged" :true) *occurrence-reifier-native*))) (add-item-identifier a "urn:occurrence-item") (let* ((before (ik-state map)) (c (condition-from (lambda () (intern-topic map :item-identifier "urn:occurrence-item"))))) (check "occurrence-reifier-native:II-not-Reifier-Topic-identity:atomic-native-conflict" (and (typep c 'item-identifier-error) (eq :duplicate-item-identifier (item-identifier-error-code c)) (equal before (ik-state map)))) (push (mm-fields "label" "own-II-versus-Reifier-Topic" "kind" "native-TMDM-probe-not-original-contract" "condition" (mm-condition c) "nativeOperationUnchanged" :true) *occurrence-reifier-native*))) (let* ((map (make-topic-map)) (p (intern-topic map :item-identifier "urn:p")) (type (intern-topic map :item-identifier "urn:type")) (o (add-occurrence p type "V")) (r (intern-topic map :item-identifier "urn:shared-Reifier"))) (set-item-reifier map r) (let* ((before (ik-state map)) (c (condition-from (lambda () (set-item-reifier o r))))) (check "occurrence-reifier-native:map-versus-Occurrence:specific-atomic-original-cause" (and (eq (type-of c) 'reification-error) (eq :reifier-conflict (reification-error-code c)) (equal "Topic already reifies a different information item." (topic-maps.tmdm::reification-error-detail c)) (equal before (ik-state map)) (eq map (topic-reified r)) (null (item-reifier o)))) (push (mm-fields "label" "map-versus-Occurrence" "kind" "native-TMDM-probe-not-original-contract" "condition" (mm-condition c) "nativeOperationUnchanged" :true) *occurrence-reifier-native*))) (setf *occurrence-reifier-native* (nreverse *occurrence-reifier-native*)))