0.8.16.26:
[sbcl.git] / tests / print.impure.lisp
index 9a3a2c3..15feb43 100644 (file)
                  (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)