X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fprint.impure.lisp;h=6d8072f0d91539a34a5f4fd89bdb11c36e4e974a;hb=d8659f1e656234e8f0f47d5295b503dd6cff4aba;hp=c6b23e9b91a3014353c5949bbf579176daeae4cb;hpb=d6d76c98535bddabd73c6338f8393b6e698f297f;p=sbcl.git diff --git a/tests/print.impure.lisp b/tests/print.impure.lisp index c6b23e9..6d8072f 100644 --- a/tests/print.impure.lisp +++ b/tests/print.impure.lisp @@ -382,4 +382,38 @@ (prin1 table)))) print-not-readable))) +;; Test that we can print characters readably regardless of the external format +;; of the stream. + +(defun test-readable-character (character external-format) + (let ((file "print.impure.tmp")) + (unwind-protect + (progn + (with-open-file (stream file + :direction :output + :external-format external-format + :if-exists :supersede) + (write character :stream stream :readably t)) + (with-open-file (stream file + :direction :input + :external-format external-format + :if-does-not-exist :error) + (assert (char= (read stream) character)))) + (ignore-errors + (delete-file file))))) + +#+sb-unicode +(with-test (:name (:print-readable :character :utf-8)) + (test-readable-character (code-char #xfffe) :utf-8)) + +#+sb-unicode +(with-test (:name (:print-readable :character :iso-8859-1)) + (test-readable-character (code-char #xfffe) :iso-8859-1)) + +(assert (string= (eval '(format nil "~:C" #\a)) "a")) +(assert (string= (format nil (formatter "~:C") #\a) "a")) + +;;; This used to trigger an AVER instead. +(assert (raises-error? (format t "~>") sb-format:format-error)) + ;;; success