(in-package #:topic-maps.xtm.tests) (defparameter *role-reifier-originals* '("role-reifier" "role-duplicate-reified" "role-duplicate-reified2" "role-duplicate-reified3" "role-duplicate-reified4")) (defun rrr-observe (raw key) (let ((saved (symbol-function 'topic-maps.xtm::read-item-reifier)) (held nil) (map nil) (native nil) (stages nil) (calls 0) (same nil) (counts nil)) (unwind-protect (progn (setf (symbol-function 'topic-maps.xtm::read-item-reifier) (lambda (node item model) (pushnew item held :test #'eq) (dolist (i (topic-maps.tmdm::map-information-items model)) (pushnew i held :test #'eq)) (prog1 (funcall saved node item model) (dolist (i (topic-maps.tmdm::map-information-items model)) (pushnew i held :test #'eq))))) (multiple-value-setq (map native stages calls same counts) (arr-observe raw key))) (setf (symbol-function 'topic-maps.xtm::read-item-reifier) saved)) (values map (union held native :test #'eq) stages calls same counts))) (defun rrr-pure (label map held) (let ((before (ik-state map)) (cx (mm-cxtm map))) (check (format nil "role-reifier:~A:pure-CXTM-all-II-inverses-and-old-handles" label) (and (equalp cx (mm-cxtm map)) (equal before (ik-state map)) (rrr-current-p map) (orr-held-p map held))) cx)) (defun rrr-original-model (name map) (let* ((a (first (topic-map-associations map))) (binary (member name '("role-duplicate-reified3" "role-duplicate-reified4") :test #'equal)) (both (equal name "role-duplicate-reified4")) (players (if binary '("topic" "topic2") '("topic"))) (types (if binary '("roletype" "roletype2") '("roletype"))) (reifiers (if binary (list "reifier" (when both "reifier2")) '("reifier")))) (check (format nil "role-reifier-original:~A:exact-native-Role-Parent-Type-Player-Reifier" name) (and (= 1 (length (topic-map-associations map))) (= (if binary (if both 7 6) 4) (length (topic-map-topics map))) (= (length players) (length (association-roles a))) (eq map (association-parent a)) (eq (by-id map "assoctype") (association-type a)) (null (association-scope a)) (null (item-reifier a)) (loop for p in players for rt in types for reifier in reifiers always (some (lambda (role) (and (eq (by-id map p) (association-role-player role)) (eq (by-id map rt) (association-role-type role)) (eq a (association-role-parent role)) (equal (list role) (topic-roles-played (by-id map p))) (if reifier (and (eq (by-id map reifier) (item-reifier role)) (eq role (topic-reified (by-id map reifier)))) (null (item-reifier role))) (null (item-identifiers role)))) (association-roles a))) (null (item-identifiers a)) (null (item-identifiers map)) (null (item-reifier map)) (null (all-occurrences map)) (null (name-reifier-names map)) (every (lambda (topic) (and (= 1 (length (item-identifiers topic))) (null (topic-subject-identifiers topic)) (null (topic-subject-locators topic)) (null (topic-names topic)))) (topic-map-topics map)) (rrr-current-p map))))) (defun rrr-condition-from (raw key) ;; Preserve the actual native condition and observe only the outer real call, ;; not nested disposable preflight copies. Do not add source slots to TMDM. (let ((saved (symbol-function 'set-item-reifier)) (parser (symbol-function 'topic-maps.xml:parse-octets)) (depth 0) (frames nil) (calls 0) (same nil) (c nil)) (unwind-protect (progn (setf (symbol-function 'topic-maps.xml:parse-octets) (lambda (input &rest args) (incf calls) (setf same (eq input raw)) (apply parser input args))) (setf (symbol-function 'set-item-reifier) (lambda (item topic) (incf depth) (unwind-protect (let* ((map (topic-maps.tmdm::item-topic-map item)) (before (ik-state map)) (prior (and topic (topic-reified topic))) (both (and (typep item 'association-role) (typep prior 'association-role)))) (handler-case (funcall saved item topic) (error (condition) (when (= depth 1) (push (mm-fields "assignedItemKind" (string (type-of item)) "priorReifiedItemKind" (when prior (string (type-of prior))) "actualMapAssociationCount" (length (topic-map-associations map)) "actualMapRoleCount" (length (as-roles map)) "sameRoleTypeAndPlayerEQ" (if (and both (eq (association-role-type item) (association-role-type prior)) (eq (association-role-player item) (association-role-player prior))) :true :false) "differentParentsEQ" (if (and both (not (eq (association-role-parent item) (association-role-parent prior)))) :true :false) "assignedParentTypeII" (coerce (when both (item-identifiers (association-type (association-role-parent item)))) 'vector) "priorParentTypeII" (coerce (when both (item-identifiers (association-type (association-role-parent prior)))) 'vector) "nativeAssignmentUnchanged" (if (equal before (ik-state map)) :true :false)) frames)) (error condition)))) (decf depth)))) (setf c (condition-from (lambda () (deserialize-octets raw :document-iri *document* :source-key key))))) (setf (symbol-function 'set-item-reifier) saved (symbol-function 'topic-maps.xml:parse-octets) parser)) (values c (nreverse frames) calls same))) (defun rrr-negative-original () (let* ((id "xtm2/invalid/role-duplicate-reified.xtm") (*document* (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" id)) (raw (file-bytes (corpus-path id))) (copy (copy-seq raw)) (spec '("role-duplicate-reified" reification-error :reifier-conflict "Topic already reifies a different information item." nil nil "XTM 4.3.2,4.19; TMDM 5.3.5,5.8: different Role Parents")) (case (topic-maps.test-foundation:make-test-case :id id :category :invalid :source-pathname (corpus-path id) :document-iri *document* :expected-outcome :ctm-rejection :clauses (list (seventh spec))))) (multiple-value-bind (c frames calls same) (rrr-condition-from raw id) (check "role-reifier-negative-original:actual-distinct-Parents-same-Type-Player-specific-native-cause" (and (intended-negative-p spec c *document* id) (= 1 calls) same (equalp copy raw) (= 1 (length frames)) (let ((f (topic-maps.test-foundation::json-object-members (first frames)))) (and (equal "ASSOCIATION-ROLE" (cdr (assoc "assignedItemKind" f :test #'equal))) (equal "ASSOCIATION-ROLE" (cdr (assoc "priorReifiedItemKind" f :test #'equal))) (= 2 (cdr (assoc "actualMapAssociationCount" f :test #'equal))) (= 2 (cdr (assoc "actualMapRoleCount" f :test #'equal))) (eq :true (cdr (assoc "sameRoleTypeAndPlayerEQ" f :test #'equal))) (eq :true (cdr (assoc "differentParentsEQ" f :test #'equal))) (equalp (vector (concatenate 'string *document* "#assoctype2")) (cdr (assoc "assignedParentTypeII" f :test #'equal))) (equalp (vector (concatenate 'string *document* "#assoctype")) (cdr (assoc "priorParentTypeII" f :test #'equal))) (eq :true (cdr (assoc "nativeAssignmentUnchanged" f :test #'equal))))))) (record-negative-original-result case spec c *document* id) (setf *cases* (append *cases* (list case))) (push (mm-fields "id" id "documentIRI" *document* "sourceKey" id "sourceBytes" (length raw) "sourceHex" (format nil "~{~2,'0X~}" (coerce raw 'list)) "sourceText" (babel:octets-to-string raw :encoding :utf-8) "qualifiedParserCalls" calls "originalOctetsEQ" (if same :true :false) "condition" (mm-condition c) "actualNativeAssignments" (coerce frames 'vector) "intendedCauseReached" :true "status" (string-downcase (string (topic-maps.test-foundation:test-case-status case)))) *role-reifier-outputs*) (check "role-reifier-negative-original:no-preliminary-Unsupported-counted-as-PASS" (and (not (typep c 'xtm-unsupported)) (eq :pass (topic-maps.test-foundation:test-case-status case))))))) (defun role-reifier-original-contracts () (setf *role-reifier-outputs* nil) (let ((previous (copy-list *cases*))) (dolist (name *role-reifier-originals*) (let* ((id (format nil "xtm2/in/~A.xtm" name)) (*document* (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" id)) (raw (file-bytes (corpus-path id))) (copy (copy-seq raw)) (baseline (corpus-path (format nil "xtm2/baseline/~A.xtm.cxtm" name))) (expected (file-bytes baseline)) (case (topic-maps.test-foundation:make-test-case :id id :category :valid :source-pathname (corpus-path id) :document-iri *document* :expected-outcome :cxtm-equal :expected-baseline baseline :clauses '("XTM 4.3.2,4.6,4.18-4.20" "TMDM 5.3.4-5.3.5,5.8,6.2,6.6-6.7"))) (map nil) (held nil) (stages nil) (calls 0) (same nil) (counts nil) (actual nil) (c nil)) (check (format nil "role-reifier-original:~A:unique-new-case" name) (null (find id *cases* :key #'topic-maps.test-foundation:test-case-id :test #'equal))) (setf *cases* (append *cases* (list case))) (handler-case (progn (multiple-value-setq (map held stages calls same counts) (rrr-observe raw id)) (rrr-original-model name map) (check (format nil "role-reifier-original:~A:actual-reads-qualified-parser-original-octets" name) (and (= 1 calls) same (equalp raw copy) (equal counts (if (member name '("role-reifier" "role-duplicate-reified2") :test #'equal) '(1) '(1 1))))) (check (format nil "role-reifier-original:~A:old-handles-live" name) (orr-held-p map held)) (unless (equal name "role-reifier") (check (format nil "role-reifier-original:~A:replaced-Role-handles" name) (some (lambda (i) (and (typep i 'association-role) (not (eq i (canonical-association-role i))))) held))) (setf actual (rrr-pure name map held)) (let ((other (deserialize-octets raw :document-iri *document* :source-key "different:Role-Reifier-provenance"))) (check (format nil "role-reifier-original:~A:source-key-independent" name) (and (equalp (rrr-model map) (rrr-model other)) (equalp actual (mm-cxtm other)))))) (error (condition) (setf c condition))) (record-original-result case actual expected c) (push (mm-fields "id" id "documentIRI" *document* "sourceKey" id "sourceBytes" (length raw) "sourceHex" (format nil "~{~2,'0X~}" (coerce raw 'list)) "sourceText" (babel:octets-to-string raw :encoding :utf-8) "qualifiedParserCalls" calls "originalOctetsEQ" (if same :true :false) "model" (when map (rrr-model map)) "associationCountsAfterEachRead" (coerce counts 'vector) "normalizationStages" (coerce (mapcar (lambda (s) (coerce s 'vector)) stages) 'vector) "oldHandlesCanonicalAndLive" (if (and map (orr-held-p map held)) :true :false) "actualBytes" (when actual (length actual)) "expectedBytes" (length expected) "actualCXTM" (when actual (babel:octets-to-string actual :encoding :utf-8)) "expectedCXTM" (babel:octets-to-string expected :encoding :utf-8) "firstDifferentByte" (when actual (mismatch actual expected)) "condition" (mm-condition c) "status" (string-downcase (string (topic-maps.test-foundation:test-case-status case)))) *role-reifier-outputs*) (when c (error c)) (check (format nil "role-reifier-original:~A:complete-original-CXTM-byte-exact" name) (equalp actual expected)))) (rrr-negative-original) (check "role-reifier-original:requested-six-once-all-prior-PASS-preserved" (and (every (lambda (case) (and (member case *cases* :test #'eq) (eq :pass (topic-maps.test-foundation:test-case-status case)))) previous) (same-identifiers-p (mapcar #'topic-maps.test-foundation:test-case-id (set-difference *cases* previous :test #'eq)) (append (mapcar (lambda (n) (format nil "xtm2/in/~A.xtm" n)) *role-reifier-originals*) '("xtm2/invalid/role-duplicate-reified.xtm"))) (every (lambda (case) (= 1 (count (topic-maps.test-foundation:test-case-id case) *cases* :key #'topic-maps.test-foundation:test-case-id :test #'equal))) *cases*)))) (setf *role-reifier-outputs* (nreverse *role-reifier-outputs*))) (defun rrr-role-xml (type player reifier &optional ids) (format nil "~A" (if reifier (format nil " reifier='~A'" reifier) "") (ik-ids ids) type player)) (defun rrr-xml (reifier &key association-reifier ids role-ids (type "#t") (role-type "#rt") (player "#p") themes extra-roles) (format nil "~A~A~A~A" (if association-reifier (format nil " reifier='~A'" association-reifier) "") (ik-ids ids) type (if themes (format nil "~{~}" themes) "") (rrr-role-xml role-type player reifier role-ids) (apply #'concatenate 'string extra-roles))) (defun rrr-probe (label body verify &optional replaced) (let* ((raw (bytes (document body))) (copy (copy-seq raw))) (multiple-value-bind (map held stages calls same counts) (rrr-observe raw label) (check (format nil "role-reifier:~A:productive-reader-qualified-XML-EQ-inverses" label) (and (= 1 calls) same (equalp raw copy) (rrr-current-p map) (orr-held-p map held))) (funcall verify map) (when replaced (check (format nil "role-reifier:~A:old-handles-replaced-and-resolvable" label) (some (lambda (i) (not (eq i (topic-maps.tmdm::canonical-item i)))) held))) (let ((cx (rrr-pure label map held))) (push (mm-fields "label" label "sourceText" (document body) "documentIRI" *document* "sourceKey" label "model" (rrr-model map) "CXTM" (babel:octets-to-string cx :encoding :utf-8) "readAssociationCounts" (coerce counts 'vector) "normalizationStages" (coerce (mapcar (lambda (s) (coerce s 'vector)) stages) 'vector) "oldHandlesCanonicalAndLive" :true) *role-reifier-controls*)) map))) (defun rrr-error (label body class code &key map-reifier) (let ((source (if map-reifier (map-reifier-xml map-reifier body) (document body)))) (multiple-value-bind (c frames calls same) (rrr-condition-from (bytes source) label) (let ((actual (cond ((typep c 'topic-maps.xtm:xtm-error) (error-code c)) ((typep c 'reification-error) (reification-error-code c)) ((typep c 'item-identifier-error) (item-identifier-error-code c))))) (check (format nil "role-reifier-error:~A:exact-class-code-parser-and-native-atomicity" label) (and (eq (type-of c) class) (eq code actual) (= 1 calls) same (every (lambda (f) (eq :true (cdr (assoc "nativeAssignmentUnchanged" (topic-maps.test-foundation::json-object-members f) :test #'equal)))) frames))) (when (typep c 'topic-maps.xtm:xtm-error) (check (format nil "role-reifier-error:~A:source-document-position-and-cause" label) (and (equal *document* (error-document-iri c)) (equal label (error-source-key c)) (if (typep c 'xtm-xml-error) (topic-maps.xtm:error-cause c) (and (integerp (error-line c)) (integerp (error-column c))))))) (push (mm-fields "label" label "sourceText" source "documentIRI" *document* "sourceKey" label "condition" (mm-condition c) "actualNativeAssignments" (coerce frames 'vector)) *role-reifier-controls*) c)))) (defun role-reifier-tests () (setf *role-reifier-controls* nil) (dolist (position '("unknown" "before" "after")) (rrr-probe (concatenate 'string "definition-" position) (concatenate 'string (if (equal position "before") "" "") (rrr-xml "#r") (if (equal position "after") "" "")) (lambda (map) (let* ((role (first (as-roles map))) (r (by-id map "r"))) (check (format nil "role-reifier:definition-~A:one-II-Topic-no-invented-SI-SL" position) (and (= 4 (length (topic-map-topics map))) (eq r (item-reifier role)) (eq role (topic-reified r)) (null (topic-subject-identifiers r)) (null (topic-subject-locators r)) (equal (list (concatenate 'string *document* "#r")) (item-identifiers r)))))))) (dolist (category '("itemIdentity" "subjectIdentifier" "subjectLocator")) (rrr-probe (concatenate 'string "lookup-" category) (format nil "<~A href='urn:r'/>~A" category (rrr-xml "urn:r")) (lambda (map) (let* ((known (by-id map "known")) (r (item-reifier (first (as-roles map)))) (sl (equal category "subjectLocator"))) (check (format nil "role-reifier:lookup-~A:II-only-and-native-cross-merge" category) (and (= (if sl 5 4) (length (topic-map-topics map))) (if sl (and (not (eq r known)) (equal '("urn:r") (item-identifiers r)) (equal (list (concatenate 'string *document* "#known")) (item-identifiers known)) (null (topic-reified known))) (and (eq r known) (same-identifiers-p (list (concatenate 'string *document* "#known") "urn:r") (item-identifiers r)))))))))) (dolist (ref '("urn:r" "../%E9%A6%AC#r")) (rrr-probe (concatenate 'string "resolved-IRI:" ref) (rrr-xml ref :ids '("urn:a") :role-ids '("urn:role")) (lambda (map) (let* ((a (first (topic-map-associations map))) (role (first (association-roles a)))) (check (format nil "role-reifier:~A:separate-Association-Role-Reifier-II" ref) (and (equal '("urn:a") (item-identifiers a)) (equal '("urn:role") (item-identifiers role)) (equal (list (mm-child-iri ref)) (item-identifiers (item-reifier role))))))))) (dolist (same-parent '(nil t)) (dolist (different '(nil t)) (let* ((label (format nil "duplicates:~A:~A" (if same-parent "same-parent" "equal-Associations") (if different "two-Reifiers" "same-Reifier"))) (second-role (rrr-role-xml "#rt" "#p" (if different "#u" "#r") '("urn:rb")))) (rrr-probe label (if same-parent (rrr-xml "#r" :association-reifier "#ar" :ids '("urn:a") :role-ids '("urn:ra") :extra-roles (list second-role)) (concatenate 'string (rrr-xml "#r" :association-reifier "#ar" :ids '("urn:a") :role-ids '("urn:ra")) (rrr-xml (if different "#u" "#r") :association-reifier "#ar" :ids '("urn:b") :role-ids '("urn:rb")))) (lambda (map) (let* ((a (first (topic-map-associations map))) (role (first (association-roles a)))) (check (format nil "role-reifier:~A:native-signature-normalization-and-all-II" label) (and (= 1 (length (topic-map-associations map))) (= 1 (length (as-roles map))) (same-identifiers-p (if same-parent '("urn:a") '("urn:a" "urn:b")) (item-identifiers a)) (same-identifiers-p '("urn:ra" "urn:rb") (item-identifiers role)) (eq (by-id map "r") (item-reifier role)) (eq a (topic-reified (by-id map "ar"))) (or (not different) (eq (by-id map "r") (by-id map "u"))))))) t)))) (rrr-probe "reversed-Role-order-and-duplicates" (concatenate 'string (rrr-xml "#r" :extra-roles (list (rrr-role-xml "#rt2" "#q" "#u"))) (rrr-xml "#u" :role-type "#rt2" :player "#q" :extra-roles (list (rrr-role-xml "#rt" "#p" "#r") (rrr-role-xml "#rt" "#p" "#r")))) (lambda (map) (check "role-reifier:reversed-order:canonical-Role-Reifier-mapping" (and (= 1 (length (topic-map-associations map))) (= 2 (length (as-roles map))) (eq (by-id map "p") (association-role-player (topic-reified (by-id map "r")))) (eq (by-id map "q") (association-role-player (topic-reified (by-id map "u"))))))) t) (rrr-probe "Reifier-merge-collapses-later-Role-signatures" (rrr-xml "#r" :role-ids '("urn:ra") :extra-roles (list (rrr-role-xml "#rt" "#p" "#u" '("urn:rb")) (rrr-role-xml "#rt2" "#r" "#r2" '("urn:later-a")) (rrr-role-xml "#rt2" "#u" "#r3" '("urn:later-b")))) (lambda (map) (check "role-reifier:cascade:later-source-Roles-match-current-Parent-and-Topics" (and (= 1 (length (topic-map-associations map))) (= 2 (length (as-roles map))) (eq (by-id map "r") (by-id map "u")) (eq (by-id map "r2") (by-id map "r3")) (same-identifiers-p '("urn:ra" "urn:rb") (item-identifiers (topic-reified (by-id map "r")))) (same-identifiers-p '("urn:later-a" "urn:later-b") (item-identifiers (topic-reified (by-id map "r2"))))))) t) (rrr-late-merges) (rrr-negative-tests) (rrr-import-test) (setf *role-reifier-controls* (nreverse *role-reifier-controls*))) (defun rrr-late-merges () (dolist (category '("subjectIdentifier" "subjectLocator" "itemIdentity")) (rrr-probe (concatenate 'string "late-" category) (concatenate 'string (rrr-xml "#r" :association-reifier "#ar" :ids '("urn:a") :role-ids '("urn:ra") :themes '("#s")) (rrr-xml "#u" :association-reifier "#au" :ids '("urn:b") :role-ids '("urn:rb") :type "#tt" :role-type "#rrt" :player "#q" :themes '("#ss")) (format nil "<~A href='urn:p'/><~A href='urn:p'/><~A href='urn:rt'/><~A href='urn:rt'/><~A href='urn:s'/><~A href='urn:s'/><~A href='urn:t'/><~A href='urn:t'/>" category category category category category category category category)) (lambda (map) (let* ((a (first (topic-map-associations map))) (role (first (association-roles a)))) (check (format nil "role-reifier:late-~A:Association-Role-Reifier-inverses-II-and-references" category) (and (= 1 (length (topic-map-associations map))) (= 1 (length (as-roles map))) (eq (by-id map "r") (by-id map "u")) (eq (by-id map "ar") (by-id map "au")) (eq a (topic-reified (by-id map "ar"))) (eq role (topic-reified (by-id map "r"))) (eq (by-id map "t") (association-type a)) (eq (by-id map "p") (association-role-player role)) (eq (by-id map "rt") (association-role-type role)) (equal (list (by-id map "s")) (association-scope a)) (same-identifiers-p '("urn:a" "urn:b") (item-identifiers a)) (same-identifiers-p '("urn:ra" "urn:rb") (item-identifiers role)))))) t))) (defun rrr-negative-tests () (dolist (row '(("bad-percent" "%GG" :invalid-percent-escape) ("bad-percent-UTF8" "%C3%28" :invalid-percent-utf8) ("bad-IRI" "x#y#z" :invalid-iri))) (rrr-error (first row) (rrr-xml (second row)) 'xtm-rejection (third row))) (dolist (row '(("extra-attribute" "" xtm-rejection :unexpected-attribute) ("reifier-on-type" "" xtm-rejection :unexpected-attribute) ("reifier-on-topicRef" "" xtm-rejection :unexpected-attribute) ("malformed-XML" "" xtm-xml-error :xml-not-well-formed) ("missing-Type" "" xtm-rejection :missing-type) ("missing-Player" "" xtm-rejection :missing-role-player) ("multiple-Players" "" xtm-rejection :role-player-cardinality))) (apply #'rrr-error row)) (rrr-error "different-Parents-same-Type-Player-and-Reifier" (concatenate 'string (rrr-xml "#r") (rrr-xml "#r" :type "#other")) 'reification-error :reifier-conflict) (rrr-error "different-Players-same-Reifier" (rrr-xml "#r" :extra-roles (list (rrr-role-xml "#rt" "#q" "#r"))) 'reification-error :reifier-conflict) (rrr-error "different-Role-Types-same-Reifier" (rrr-xml "#r" :extra-roles (list (rrr-role-xml "#rt2" "#p" "#r"))) 'reification-error :reifier-conflict) (rrr-error "Role-and-Association-same-Reifier" (rrr-xml "#r" :association-reifier "#r") 'reification-error :reifier-conflict) (rrr-error "Occurrence-and-Role-same-Reifier" (concatenate 'string "" (orr-xml "#r") "" (rrr-xml "#r")) 'reification-error :reifier-conflict) (rrr-error "Map-and-Role-same-Reifier" (rrr-xml "#r") 'reification-error :reifier-conflict :map-reifier "#r") (dolist (category '("subjectIdentifier" "subjectLocator" "itemIdentity")) (rrr-error (concatenate 'string "late-Reifier-conflict-" category) (concatenate 'string (rrr-xml "#r") (rrr-xml "#u" :type "#other") (format nil "<~A href='urn:r'/><~A href='urn:r'/>" category category)) 'reification-error :reifier-conflict)) (rrr-error "Role-II-not-Reifier-II" (rrr-xml "urn:same" :role-ids '("urn:same")) 'topic-maps.tmdm::occurrence-identifier-error :duplicate-item-identifier) (rrr-error "Role-II-not-Association-II" (rrr-xml "#r" :ids '("urn:same") :role-ids '("urn:same")) 'item-identifier-error :duplicate-item-identifier) (rrr-error "anyType-still-Unsupported" (concatenate 'string (rrr-xml "#r") "V") 'xtm-unsupported :resource-data-datatype)) (defun rrr-import-test () (let* ((child (mm-child-iri "child.xtm")) (raw (bytes (document (concatenate 'string "" (rrr-xml "#r" :association-reifier "#ar" :ids '("urn:imported-Association") :role-ids '("urn:imported-Role") :themes '("#s"))))))) (mm-call "Role-Reification-import" (document (concatenate 'string (mm-directive "child.xtm") "")) (list (list child raw "child:Role-Reification")) (lambda (map imports calls) (declare (ignore calls)) (let* ((a (first (topic-map-associations map))) (role (first (association-roles a))) (r (mm-local map child "r"))) (check "role-reifier:import:Parents-Player-II-Role-and-Association-inverses-source-preservation" (and (rrr-current-p map) (eq map (association-parent a)) (eq a (association-role-parent role)) (eq (by-id map "local") (association-role-player role)) (eq r (item-reifier role)) (eq role (topic-reified r)) (eq a (topic-reified (mm-local map child "ar"))) (null (item-identifiers map)) (equal '("urn:imported-Association") (item-identifiers a)) (equal '("urn:imported-Role") (item-identifiers role)) (every (lambda (record) (let* ((source (first record)) (resolve (second record)) (sa (first (topic-map-associations source))) (sr (first (association-roles sa)))) (and (rrr-current-p source) (eq a (funcall resolve sa)) (eq role (funcall resolve sr)) (eq r (funcall resolve (item-reifier sr)))))) imports)))) (push (mm-fields "label" "native-Role-Reification-import" "sourceText" (babel:octets-to-string raw :encoding :utf-8) "model" (rrr-model map) "sourceMapPreserved" :true) *role-reifier-controls*)))))