X-Git-Url: https://dreyeck.freedombox.rocks/gitweb/topic-maps.git/blobdiff_plain/17dd58775e25ab495e3c83deb4b5a36f5e5a124b..6162ed68:/tests/ctm-integers.lisp?ds=inline diff --git a/tests/ctm-integers.lisp b/tests/ctm-integers.lisp index 342be80..4d0f7c9 100644 --- a/tests/ctm-integers.lisp +++ b/tests/ctm-integers.lisp @@ -125,10 +125,21 @@ (and (typep condition 'ctm-rejection) (= 2 (error-line condition)) (= 6 (error-column condition)) (equal "independent-fixture" (topic-maps.ctm:error-source condition)) (eq :character (topic-maps.ctm:error-position-unit condition))))) - (dolist (value '("1.5" ".5" "-.5" "+.5" "2000-12-31" "2000-12-31T12:00:00Z" "*")) + (dolist (value '("1.5" ".5" "-.5" "+.5")) + (check (concatenate 'string "integer-slice-now-allows-decimal:" value) + (string= (topic-maps.tmdm:decimal-datatype) + (topic-maps.tmdm:occurrence-datatype (first (all-occurrences (read-text (format nil "a t: ~A." value)))))))) + (dolist (value '("2000-12-31T12:00:60+01:00" "2000-12-31T12:00:60-01:00" "*")) (let ((condition (ctm-condition (format nil "a t: ~A." value)))) - (check (concatenate 'string "excluded-numeric-sugar:" value) - (and (typep condition 'ctm-unsupported) (eq :occurrence-literal-datatype (error-code condition)) (= 5 (error-position condition)))))) + (check (if (string= value "*") "integer-slice-now-allows-ctm-integer" + (concatenate 'string "excluded-numeric-sugar:" value)) + (if (string= value "*") + (let ((item (first (all-occurrences (read-text "a t: *."))))) + (and (null condition) (equal "*" (topic-maps.tmdm:occurrence-value item)) + (equal "http://psi.topicmaps.org/iso13250/ctm-integer" + (topic-maps.tmdm:occurrence-datatype item)))) + (and (typep condition 'ctm-unsupported) (eq :datetime-leap-second-context (error-code condition)) + (= 5 (error-position condition))))))) (let* ((map (read-text "a. t.")) (owner (local-topic map "a")) (typ (local-topic map "t")) (state (map-state map))) (let ((condition (occurrence-condition (lambda () (topic-maps.tmdm:add-occurrence owner typ "1.0" :datatype (topic-maps.tmdm:integer-datatype)))))) (check "invalid-integer-api-rejected-atomically" (and (eq :invalid-integer-value (topic-maps.tmdm:occurrence-error-code condition)) (equal state (map-state map))))) @@ -138,10 +149,13 @@ (check "invalid-private-integer-cxtm-error-not-unsupported" (and (typep condition 'topic-maps.cxtm:cxtm-error) (not (typep condition 'topic-maps.cxtm:cxtm-unsupported)) (eq :invalid-integer-value (topic-maps.cxtm:error-code condition)) (equal state (map-state map)))))) - (dolist (name '("decimal" "date" "dateTime")) - (check (concatenate 'string "integer-slice-keeps-other-cxtm-exclusions:" name) - (typep (cxtm-condition (lambda () (cxtm (read-text (format nil "a t:\"42\"^^." name))))) - 'topic-maps.cxtm:cxtm-unsupported)))) + (check "integer-slice-now-supports-decimal-cxtm" + (equal '("42.0") (serialized-values (cxtm (read-text "a t:\"42\"^^."))))) + (check "integer-slice-now-supports-date-cxtm" + (equal '("2000-12-31") (serialized-values (cxtm (read-text "a t: 2000-12-31."))))) + (check "integer-slice-rejects-invalid-dateTime-value" + (typep (ctm-condition "a t:\"42\"^^.") + 'ctm-rejection))) (defun integer-equality-and-merge-tests () (let ((map (read-text "%prefix xsd a t: 001; t: +1; t: 1; t:\"1\"^^xsd:integer; t:\"001\"^^xsd:integer; t:\"1\".")))