X-Git-Url: https://dreyeck.freedombox.rocks/gitweb/topic-maps.git/blobdiff_plain/d024dc96ce091db06b9d09ea7c1ccb5f90b2886d..b2eecffa:/tests/ctm-registered-originals.lisp diff --git a/tests/ctm-registered-originals.lisp b/tests/ctm-registered-originals.lisp index ab66689..66c9d99 100644 --- a/tests/ctm-registered-originals.lisp +++ b/tests/ctm-registered-originals.lisp @@ -1,7 +1,8 @@ (defpackage #:topic-maps.registered-original.tests (:use #:cl #:topic-maps.tmdm) (:export #:run-tests #:write-reports #:candidate-groups - #:run-negative-tests #:write-negative-reports)) + #:run-negative-tests #:write-negative-reports + #:run-empty2-tests #:write-empty2-reports)) (in-package #:topic-maps.registered-original.tests) ;; One selection of the existing discovered Case Records, not another registry. @@ -50,7 +51,7 @@ (ecase group (:comments (plain-locals-p map doc - (cond ((member name '("empty" "comment-sl3") :test #'equal) nil) + (cond ((member name '("empty" "empty2" "comment-sl3") :test #'equal) nil) ((member name '("comment-ml" "comment-ml-nested" "comment-ml-nested2" "comment-sl2") :test #'equal) '("topic1" "topic3")) ((equal name "comment-sl6") '("topic" "topic2")) (t '("topic"))))) (:identity @@ -85,6 +86,9 @@ (type (local map doc (if (equal name "occurrence-qname-value") "wikipedia" "occtype"))) (items (when owner (topic-occurrences owner))) (o (first items)) (expected (cond + ((equal name "occurrence-string-triple") (list "Occurrence \" Value" (string-datatype))) + ((equal name "occurrence-string-triple2") (list "Occurrence\"\" \" Value\"" (string-datatype))) + ((equal name "occurrence-ctm-integer") (list "*" "http://psi.topicmaps.org/iso13250/ctm-integer")) ((equal name "occurrence-decimal-dot-neg2") (list "-0.03" (decimal-datatype))) ((equal name "occurrence-decimal-dot-pos") (list "0.3" (decimal-datatype))) ((equal name "occurrence-decimal-leading-zeros2") (list "2.3" (decimal-datatype))) @@ -100,11 +104,15 @@ (equal expected (list (occurrence-value o) (occurrence-datatype o))) (null (occurrence-scope o)) (null (item-identifiers o))))) (:escapes - (let* ((owner (local map doc (cond ((equal name "string-escape") "topic") ((equal name "string-escape2") "A00") (t "zztop")))) + (let* ((owner (local map doc (cond ((equal name "string-escape") "topic") ((equal name "string-escape2") "A00") ((equal name "encoding-8859-5") "russia") (t "zztop")))) (names (when owner (topic-names owner))) (type (find-if (lambda (topic) (member (default-name-type-identifier) (topic-subject-identifiers topic) :test #'equal)) (topic-map-topics map))) (expected (cond ((equal name "string-escape") (list "\\" "Quote (\") character" (format nil "Some whitespace ~C~C~C" #\Newline #\Return #\Tab))) - ((equal name "string-escape2") '("A00")) (t '("ZZ Top"))))) + ((equal name "string-escape2") '("A00")) + ((equal name "encoding-8859-5") '("Россия")) + ((member name '("unicode-escape-u4-triple-string" "unicode-escape-u6-triple-string") :test #'equal) + (list (format nil "ZZ ~%Top"))) + (t '("ZZ Top"))))) (and owner type (= 2 (length (topic-map-topics map))) (null (topic-map-associations map)) (same-set expected (mapcar #'topic-name-value names)) (every (lambda (n) (and (eq owner (topic-name-parent n)) (eq type (topic-name-type n)) @@ -506,3 +514,96 @@ (concatenate 'string prefix ".validation.json") (concatenate 'string prefix ".cxtm.json") :additional-checks *negative-checks* :scope "Slice 20B: seven negative originals actually executed; only intended syntax rejections registered. Earlier positive comparisons and four known DateTime/Include FAILs preserved; full retained regression, Slice 20A and XTM evidence separate.")) + + +;;; Slice 20E: one more existing positive Case Record, using EXERCISE-CASE. +;;; Run after the retained 20A/20B/20C stages to preserve their snapshots. +(defvar *empty2-checks* nil) +(defvar *empty2-row* nil) +(defvar *empty2-entry-statuses* nil) +(defun run-empty2-tests () + (unless topic-maps.ctm.tests::*cxtm-corpus* + (run-tests) + (run-negative-tests) + (uiop:symbol-call :topic-maps.prolog.tests :run-tests)) + (setf *empty2-checks* nil *empty2-row* nil) + (let* ((*checks* nil) + (corpus topic-maps.ctm.tests::*cxtm-corpus*) + (root (topic-maps.test-foundation:corpus-root corpus)) + (id "ctm/in/empty2.ctm") + (selected (topic-maps.test-foundation:select-cases corpus :id id)) + (case (first selected)) + (cases (topic-maps.test-foundation:corpus-cases corpus)) + (previous (mapcar (lambda (c) (cons c (case-state c))) cases)) + (old-results (copy-tree topic-maps.ctm.tests::*cxtm-results*)) + (base (format nil "https://ctm-tests.example.invalid/~A/" + (getf (topic-maps.test-foundation:corpus-metadata corpus) :commit)))) + (setf *empty2-entry-statuses* + (copy-list (getf (topic-maps.test-foundation:summarize-corpus corpus) :statuses))) + (check "empty2:unique-existing-NOT-RUN-positive-contract" + (and (= 1 (length selected)) (member case cases :test #'eq) + (eq :valid (topic-maps.test-foundation:test-case-category case)) + (eq :cxtm-equal (topic-maps.test-foundation:test-case-expected-outcome case)) + (eq :not-run (topic-maps.test-foundation:test-case-status case)) + (null (topic-maps.test-foundation:test-case-actual-outcome case)))) + (check "empty2:pinned-source-baseline-and-document-IRI" + (and (equal (truename (merge-pathnames id root)) + (truename (topic-maps.test-foundation:test-case-source-pathname case))) + (equal (truename (merge-pathnames "ctm/baseline/empty2.ctm.cxtm" root)) + (truename (topic-maps.test-foundation:test-case-expected-baseline case))) + (equal (concatenate 'string base id) + (topic-maps.test-foundation:test-case-document-iri case)))) + (check "empty2:original-thirteen-source-bytes" + (equalp (binary (topic-maps.test-foundation:test-case-source-pathname case)) + #(37 118 101 114 115 105 111 110 32 49 46 48 10))) + (check "empty2:original-twenty-three-baseline-bytes" + (equalp (binary (topic-maps.test-foundation:test-case-expected-baseline case)) + #(60 116 111 112 105 99 77 97 112 62 10 60 47 116 111 112 105 99 77 97 112 62 10))) + (multiple-value-bind (row result) (exercise-case case :comments) + (setf *empty2-row* row) + ;; EXERCISE-CASE performs real file deserialization, the semantic witness, + ;; raw object/handle preservation and exact octet comparison before PASS. + (check "empty2:actual-original-byte-comparison-passes" + (and result (getf result :match) (= 23 (getf result :bytes)) + (equal (format nil "~%~%") (getf result :actual)) + (equal (getf result :actual) (getf result :expected)) + (eq :pass (topic-maps.test-foundation:test-case-status case)) + (eq :cxtm-match (topic-maps.test-foundation:test-case-actual-outcome case)))) + (check "empty2:all-previous-case-records-and-observations-preserved" + (and (eq corpus topic-maps.ctm.tests::*cxtm-corpus*) + (equal cases (topic-maps.test-foundation:corpus-cases corpus)) + (equal old-results topic-maps.ctm.tests::*cxtm-results*) + (every (lambda (entry) + (if (eq case (car entry)) + (equal (first (cdr entry)) (identity-fields case)) + (equal (cdr entry) (case-state (car entry))))) previous))) + (setf topic-maps.ctm.tests::*cxtm-results* + (append topic-maps.ctm.tests::*cxtm-results* (list result)))) + (let ((after (getf (topic-maps.test-foundation:summarize-corpus corpus) :statuses))) + (check "empty2:only-one-NOT-RUN-to-PASS-transition" + (and (= (1+ (getf *empty2-entry-statuses* :pass)) (getf after :pass)) + (= (1- (getf *empty2-entry-statuses* :not-run)) (getf after :not-run)) + (= (getf *empty2-entry-statuses* :fail) (getf after :fail)) + (= (getf *empty2-entry-statuses* :unsupported) (getf after :unsupported))))) + (check "empty2:unique-check-names" + (= (length *checks*) (length (remove-duplicates *checks* :test #'equal)))) + (setf *empty2-checks* (nreverse *checks*)) + (format t "~&EMPTY2-ORIGINAL ~A: ~A; 23 byte-exact CXTM bytes~%" id + (topic-maps.test-foundation:test-case-status case))) + (format t "~&EMPTY2-PASS: ~D checks; one actual original contract~%" (length *empty2-checks*)) + t) + +(defun write-empty2-reports (prefix) + (with-open-file (out (concatenate 'string prefix ".registration.json") + :direction :output :if-exists :supersede :if-does-not-exist :create) + (topic-maps.test-foundation::emit-json-value + (fields "kind" "ctm-registered-original-execution" + "passed" (length *empty2-checks*) "failed" 0 + "entryStatuses" (topic-maps.test-foundation::counts-object *empty2-entry-statuses*) + "checks" (coerce *empty2-checks* 'vector) "cases" (vector *empty2-row*)) out) + (terpri out)) + (topic-maps.ctm.tests::write-cxtm-report + (concatenate 'string prefix ".validation.json") + (concatenate 'string prefix ".cxtm.json") + :additional-checks *empty2-checks* + :scope "Slice 20E: empty2.ctm executed using the Slice 20A original comparison harness; empty Map, exact source and CXTM bytes, stable Document IRI and non-mutating canonicalization. All earlier contract records and four known FAILs retained."))