X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fprint.impure.lisp;h=15feb43d054a27736b3dc16edc93e26af0685fda;hb=095564c28a259002c7e34fd1d861f5bbd0a959b6;hp=9a3a2c3132c8f8ed0ed776a8bb2f3fc2d3758892;hpb=cf3e11a77e89bc729595a08fc52ece7bc6b4430e;p=sbcl.git diff --git a/tests/print.impure.lisp b/tests/print.impure.lisp index 9a3a2c3..15feb43 100644 --- a/tests/print.impure.lisp +++ b/tests/print.impure.lisp @@ -239,5 +239,32 @@ (write #2a((t t) (nil nil)) :stream s)))) (assert (equalp (read-from-string output) #2a((t t) (nil nil)))))) +;;; NIL parameters to "interpreted" FORMAT directives +(assert (string= (format nil "~v%" nil) (string #\Newline))) + +;;; PRINC-TO-STRING should bind print-readably +(let ((*print-readably* t)) + (assert (string= (princ-to-string #\7) + (write-to-string #\7 :escape nil :readably nil)))) + +;;; in FORMAT, ~^ inside ~:{ should go to the next case, not break +;;; iteration, even if one argument is just a one-element list. +(assert (string= (format nil "~:{~A~^~}" '((A) (C D))) "AC")) + +;;; errors should be raised if pprint and justification are mixed +;;; injudiciously... +(dolist (x (list "~<~:;~>~_" "~<~:;~>~I" "~<~:;~>~W" + "~<~:;~>~:T" "~<~:;~>~<~:>" "~_~<~:;~>" + "~I~<~:;~>" "~W~<~:;~>" "~:T~<~:;~>" "~<~:>~<~:;~>")) + (assert (raises-error? (format nil x nil))) + (assert (raises-error? (format nil (eval `(formatter ,x)) nil)))) +;;; ...but not in judicious cases. +(dolist (x (list "~<~;~>~_" "~<~;~>~I" "~<~;~>~W" + "~<~;~>~:T" "~<~;~>~<~>" "~_~<~;~>" + "~I~<~;~>" "~W~<~;~>" "~:T~<~;~>" "~<~>~<~;~>" + "~<~:;~>~T" "~T~<~:;~>")) + (assert (format nil x nil)) + (assert (format nil (eval `(formatter ,x)) nil))) + ;;; success (quit :unix-status 104)