X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcharacter.pure.lisp;h=95c583362053d863b5075c2cb3c8fb23c3cd9057;hb=27a88f9d3a898640b8bc03bc6699cdee7e058732;hp=e26fed4828080ff77881025721ab1e63ca1be832;hpb=dd1122b8a0577c7004d2b41c993cad1faaa8d333;p=sbcl.git diff --git a/tests/character.pure.lisp b/tests/character.pure.lisp index e26fed4..95c5833 100644 --- a/tests/character.pure.lisp +++ b/tests/character.pure.lisp @@ -85,3 +85,44 @@ c8 c9 ca cb cc cd ce cf)) (char< c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf)))) + +;;; Characters could be coerced to subtypes of CHARACTER to which they +;;; don't belong. Also, character designators that are not characters +;;; could be coerced to proper subtypes of CHARACTER. +(with-test (:name :bug-841312) + ;; First let's make sure that the conditions hold that make the test + ;; valid: #\Nak is a BASE-CHAR, which at the same time ensures that + ;; STANDARD-CHAR is a proper subtype of BASE-CHAR, and under + ;; #+SB-UNICODE the character with code 955 exists and is not a + ;; BASE-CHAR. + (assert (typep #\Nak 'base-char)) + #+sb-unicode + (assert (let ((c (code-char 955))) + (and c (not (typep c 'base-char))))) + ;; Test the formerly buggy coercions: + (macrolet ((assert-coerce-type-error (object type) + `(assert (raises-error? (coerce ,object ',type) + type-error)))) + (assert-coerce-type-error #\Nak standard-char) + (assert-coerce-type-error #\a extended-char) + #+sb-unicode + (assert-coerce-type-error (code-char 955) base-char) + (assert-coerce-type-error 'a standard-char) + (assert-coerce-type-error "a" standard-char)) + ;; The following coercions still need to be possible: + (macrolet ((assert-coercion (object type) + `(assert (typep (coerce ,object ',type) ',type)))) + (assert-coercion #\a standard-char) + (assert-coercion #\Nak base-char) + #+sb-unicode + (assert-coercion (code-char 955) character) + (assert-coercion 'a character) + (assert-coercion "a" character))) + +(with-test (:name :bug-994487) + (let ((f (compile nil `(lambda (char) + (code-char (1+ (char-code char))))))) + (assert (equal `(function (t) (values (sb-kernel:character-set + ((1 . ,(1- char-code-limit)))) + &optional)) + (sb-impl::%fun-type f)))))