;; Supplemental diagnostic evidence for obligations absent from the 397 originals.
;; No Case Records are created, recorded or registered.
(require :asdf)
(assert (string= "2.5.4" (lisp-implementation-version)))
(setf *compile-verbose* nil *load-verbose* nil)
(asdf:load-asd (merge-pathnames "topic-maps.asd" (uiop:ensure-directory-pathname (uiop:getenv "TOPIC_MAPS_22A_ROOT"))))
(asdf:load-system "topic-maps/ctm/encoding-tests")
(asdf:load-system "topic-maps/xtm/tests")
(in-package :cl-user)
(defvar *profile-rows* nil)
(defun profile-probe (id notation text)
(let* ((doc "https://example.invalid/slice-22a/profile") (map nil) (actual nil) (phase "deserialize")
(c (handler-case
(progn
(setf map (if (eq notation :xtm)
(topic-maps.xtm:deserialize-octets (babel:string-to-octets text :encoding :utf-8) :document-iri doc :source-key id)
(topic-maps.ctm:deserialize-string text :document-iri doc :source-name id)))
(setf phase "canonicalize" actual (topic-maps.cxtm:canonicalize-octets map :base-locator doc)) nil)
(error (c) c))))
(push (topic-maps.test-foundation::fields "id" id "notation" (symbol-name notation) "sourceText" text
"documentIRI" doc "phase" phase "registered" :false
"condition" (if (typep c 'topic-maps.cxtm:cxtm-error)
(topic-maps.test-foundation::fields "class" (string (type-of c))
"code" (string-downcase (string (topic-maps.cxtm:error-code c))) "message" (princ-to-string c)
"line" nil "column" nil "cause" nil)
(if (eq notation :xtm) (topic-maps.xtm.tests::map-reifier-condition-data c)
(topic-maps.registered-original.tests::condition-data c)))
"model" (when map (topic-maps.template.tests::observe map))
"actualCXTM" (when actual (babel:octets-to-string actual :encoding :utf-8))) *profile-rows*)))
(defun variant-document (resource)
(topic-maps.xtm.tests::document (format nil "N~A" resource)))
(profile-probe "unknown-text-datatype" :xtm (variant-document "BOGUS"))
(profile-probe "anyType-XML" :xtm (variant-document "X&Y"))
(profile-probe "non-anyType-element-content" :xtm (variant-document "X"))
(profile-probe "anyURI-element-content" :xtm (variant-document "X"))
(profile-probe "DOCTYPE-policy" :xtm (concatenate 'string "" (topic-maps.xtm.tests::document "")))
(profile-probe "declared-Shift-JIS-ASCII" :ctm "%encoding \"Shift-JIS\" topic.")
(profile-probe "date-timezone-canonicalization" :ctm "topic occ: \"2000-01-01+02:00\"^^.")
(profile-probe "BCE-datetime-rollover" :ctm "topic occ: \"-0001-12-31T23:00:00-02:00\"^^.")
(assert (not topic-maps.xtm.tests::*cases*))
(with-open-file (out (uiop:getenv "TOPIC_MAPS_22A_PROFILE_REPORT") :direction :output :if-exists :supersede :external-format :utf-8)
(topic-maps.test-foundation::emit-json-value (coerce (reverse *profile-rows*) 'vector) out) (terpri out))
(format t "PROFILE-OBSERVATIONS: 8 supplemental probes; zero Case Records and zero new original PASS~%")