;;; a spot of random-testing for rational printing
(defvar *seed-state* (make-random-state))
-(prin1 *seed-state*) ; so that we can reproduce errors
+(print *seed-state*) ; so that we can reproduce errors
(let ((seed (make-random-state *seed-state*)))
(loop repeat 42
do (let ((n (random (ash 1 1000) seed))
(funcall (eval `(formatter ,format)) s arg))
result)))
+;;; NIL first parameter for ~R is equivalent to no parameter.
+(assert (string= (format nil "~VR" nil 5) "five"))
+(assert (string= (format nil (formatter "~VR") nil 6) "six"))
+
+;;; CSR inserted a bug into Burger & Dybvig's float printer. Caught
+;;; by Raymond Toy
+(assert (string= (format nil "~E" 1d23) "1.0d+23"))
+
+;;; Fixed-format bugs from CLISP's test suite (reported by Bruno
+;;; Haible, bug 317)
+(assert (string= (format nil "~1F" 10) "10."))
+(assert (string= (format nil "~0F" 10) "10."))
+(assert (string= (format nil "~2F" 1234567.1) "1234567."))
+
+;;; here's one that seems to fail most places. I think this is right,
+;;; and most of the other answers I've seen are definitely wrong.
+(assert (string= (format nil "~G" 1d23) "100000000000000000000000. "))
+
+;;; Adam Warner's test case
+(assert (string= (format nil "~@F" 1.23) "+1.23"))
+
;;; success
(quit :unix-status 104)