;;; This was a bug in SBCL until 0.6.12.40 (originally reported as a
;;; CMU CL bug by Erik Naggum on comp.lang.lisp).
-(loop for *print-base* from 2 to 36
+(loop for base from 2 to 36
with *print-radix* = t
- do
- (assert (string= "#*101" (format nil "~S" #*101))))
+ do (let ((*print-base* base))
+ (assert (string= "#*101" (format nil "~S" #*101)))))
;;; bug in sbcl-0.7.1.25, reported by DB sbcl-devel 2002-02-25
(assert (string= "0.5" (format nil "~2D" 0.5)))
(assert (raises-error? (format nil "~<~<~A~:>~>" '(foo))))
(assert (string= (format nil "~<~<~A~>~>" 'foo) "FOO"))
+;;; Check that arrays that we print while *PRINT-READABLY* is true are
+;;; in fact generating similar objects.
+(assert (equal (array-dimensions
+ (read-from-string
+ (with-output-to-string (s)
+ (let ((*print-readably* t))
+ (print (make-array '(1 2 0)) s)))))
+ '(1 2 0)))
+
+(assert (multiple-value-bind (result error)
+ (ignore-errors (read-from-string
+ (with-output-to-string (s)
+ (let ((*print-readably* t))
+ (print (make-array '(1 0 1)) s)))))
+ ;; it might not be readably-printable
+ (or (typep error 'print-not-readable)
+ ;; or else it had better have the same dimensions
+ (equal (array-dimensions result) '(1 0 1)))))
+
+;;; before 0.8.0.66 it signalled UNBOUND-VARIABLE
+(write #(1 2 3) :pretty nil :readably t)
+
+;;; another UNBOUND-VARIABLE, this time due to a bug in FORMATTER
+;;; expanders.
+(funcall (formatter "~@<~A~:*~A~:>") nil 3)
+
+;;; the PPC floating point backend was at one point sufficiently
+;;; broken that this looped infinitely or caused segmentation
+;;; violations through stack corruption.
+(print 0.0001)
+
+;;; In sbcl-0.8.7, the ~W format directive interpreter implemented the
+;;; sense of the colon and at-sign modifiers exactly backwards.
+;;;
+;;; (Yes, the test for this *is* substantially hairier than the fix;
+;;; wanna make something of it?)
+(cl:in-package :cl-user)
+(defstruct wexerciser-0-8-7)
+(defun wexercise-0-8-7-interpreted (wformat)
+ (format t wformat (make-wexerciser-0-8-7)))
+(defmacro define-compiled-wexercise-0-8-7 (wexercise wformat)
+ `(defun ,wexercise ()
+ (declare (optimize (speed 3) (space 1)))
+ (format t ,wformat (make-wexerciser-0-8-7))
+ (values)))
+(define-compiled-wexercise-0-8-7 wexercise-0-8-7-compiled-without-atsign "~W")
+(define-compiled-wexercise-0-8-7 wexercise-0-8-7-compiled-with-atsign "~@W")
+(defmethod print-object :before ((wexerciser-0-8-7 wexerciser-0-8-7) stream)
+ (unless (and *print-level* *print-length*)
+ (error "gotcha coming")))
+(let ((*print-level* 11)
+ (*print-length* 12))
+ (wexercise-0-8-7-interpreted "~W")
+ (wexercise-0-8-7-compiled-without-atsign))
+(remove-method #'print-object
+ (find-method #'print-object
+ '(:before)
+ (mapcar #'find-class '(wexerciser-0-8-7 t))))
+(defmethod print-object :before ((wexerciser-0-8-7 wexerciser-0-8-7) stream)
+ (when (or *print-level* *print-length*)
+ (error "gotcha going")))
+(let ((*print-level* 11)
+ (*print-length* 12))
+ (wexercise-0-8-7-interpreted "~@W")
+ (wexercise-0-8-7-compiled-with-atsign))
+
;;; success
(quit :unix-status 104)