(assert (eql 0.0d0 (funcall f 123.0d0 0.0d0)))
(assert (eql 0.0d0 (funcall f 123.0 0.0d0)))))
-;; 1.0.29.44 introduces a ton of changes for complex floats
-;; on x86-64. Huge test of doom to help catch weird corner
-;; cases.
-(with-test (:name :complex-floats)
- (labels ((equal-enough (x y)
- (cond ((eql x y))
- ((or (complexp x)
- (complexp y))
- (or (eql (coerce x '(complex double-float))
- (coerce y '(complex double-float)))
- (and (equal-enough (realpart x) (realpart y))
- (equal-enough (imagpart x) (imagpart y)))))
- ((numberp x)
- (or (eql (coerce x 'double-float) (coerce y 'double-float))
- (< (abs (- x y)) 1d-5)))))
- (reflections (x)
- (values x
- (conjugate x)
- (complex (- (realpart x)) (imagpart x))
- (- x)))
- (compute (x y r)
- (list (+ x y) (+ r x) (+ x r)
- (- x y) (- r x) (- x r)
- (* x y) (* x r) (* r x)
- (unless (zerop y)
- (/ x y))
- (unless (zerop r)
- (/ x r))
- (unless (zerop x)
- (/ r x))
- (conjugate x) (conjugate r)
- (- x)
- (complex r) (complex r r) (complex 0 r)
- (= x y) (= r x) (= y r) (= x (complex 0 r))
- (eql x y) (eql x (complex r)) (eql y (complex r))
- (eql x (complex r r)) (eql y (complex 0 r))))
- (compute-all (x y r)
- (multiple-value-bind (x1 x2 x3 x4) (reflections x)
- (multiple-value-bind (y1 y2 y3 y4) (reflections y)
- #.(let ((form '(list)))
- (dolist (x '(x1 x2 x3 x4) (reverse form))
- (dolist (y '(y1 y2 y3 y4))
- (push `(list ,x ,y r
- (append (compute ,x ,y r)
- (compute ,x ,y (- r))))
- form))))))))
- (declare (inline reflections compute compute-all))
- (let* ((reals '(0 1 2))
- (complexes '#.(let ((reals '(0 1 2))
- (cpx '()))
- (dolist (x reals (nreverse cpx))
- (dolist (y reals)
- (push (complex x y) cpx)))))
- (val ()))
- (declare (notinline every))
- (dolist (r reals (nreverse val))
- (dolist (x complexes)
- (dolist (y complexes)
- (let ((value (compute-all x y r))
- (single (compute-all (coerce x '(complex single-float))
- (coerce y '(complex single-float))
- (coerce r 'single-float)))
- (double (compute-all (coerce x '(complex double-float))
- (coerce y '(complex double-float))
- (coerce r 'double-float))))
- (assert (every (lambda (pos ref single double)
- (every (lambda (ref single double)
- (or (and (equal-enough ref single)
- (equal-enough ref double))
- (and (not (numberp single)) ;; -ve 0s
- (equal-enough single double))))
- (fourth ref) (fourth single) (fourth double)))
- '((0 0) (0 1) (0 2) (0 3)
- (1 0) (1 1) (1 2) (1 3)
- (2 0) (2 1) (2 2) (2 3)
- (3 0) (3 1) (3 2) (3 3))
- value single double)))))))))
+;; Bug reported by Eric Marsden on July 15 2009. The compiler
+;; used not to constant fold calls with arguments of type
+;; (EQL foo).
+(with-test (:name :eql-type-constant-fold)
+ (assert (equal '(FUNCTION (T) (VALUES (MEMBER T) &OPTIONAL))
+ (sb-kernel:%simple-fun-type
+ (compile nil `(lambda (x)
+ (eql #c(1.0 2.0)
+ (the (eql #c(1.0 2.0))
+ x))))))))