Make dump-fop not hold on to a string designator for SB-FASL
[sbcl.git] / validate-float.lisp
blob4a42da6b690ec9244f7e19745166fce23e8de66e
1 (defun check-float-file (name)
2 (with-open-file (stream name :if-does-not-exist nil)
3 (when stream
4 (format t "; Checking ~S~%" (pathname stream))
5 ;; Ensure that we're reading the correct variant of the file
6 ;; in case there is more than one set of floating-point formats.
7 (assert (eq (read stream) :default))
8 (sb-kernel::with-float-traps-masked (:overflow :divide-by-zero)
9 (let ((*readtable* (copy-readtable)))
10 ;; No need to do a full-blown read-time-eval.
11 (set-dispatch-macro-character
12 #\# #\. (lambda (stream subchar arg)
13 (declare (ignore subchar arg))
14 (let ((expr (read stream t nil t)))
15 (ecase (car expr)
16 (make-single-float
17 (sb-kernel:make-single-float (second expr)))
18 (make-double-float
19 (sb-kernel:make-double-float (second expr) (third expr)))))))
20 (dolist (expr (read stream))
21 (destructuring-bind (fun args . result) expr
22 (let ((actual (if (eql fun 'read-from-string)
23 (let ((*read-default-float-format* (car args)))
24 (multiple-value-list (apply fun (sb-int:ensure-list (cdr args)))))
25 (multiple-value-list (apply fun (sb-int:ensure-list args))))))
26 (labels ((eqal (x y) ; non-ideal name, but other names are also non-ideal
27 (etypecase x
28 (cons (and (consp y) (eqal (car x) (car y)) (eqal (cdr x) (cdr y))))
29 (symbol (eql x y))
30 (rational (eql x y))
31 (float (eql x y))
32 (string (string= x y)))))
33 (unless (eqal actual result)
34 (cerror "Continue"
35 "FLOAT CACHE LINE ~S vs COMPUTED ~S~%"
36 expr actual)))))))))))
38 (compile 'check-float-file)