X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Farith.pure.lisp;h=3cc17fa8484806b0ddbb1129bae171d36c4aeed3;hb=5cc68148d1a5f9bacf4eb12e396b680d992fc2c2;hp=2b1266d70e4a64731c381f25321c0bbd0d3f853a;hpb=78fa16bf55be44cc16845be84d98023e83fb14bc;p=sbcl.git diff --git a/tests/arith.pure.lisp b/tests/arith.pure.lisp index 2b1266d..3cc17fa 100644 --- a/tests/arith.pure.lisp +++ b/tests/arith.pure.lisp @@ -224,3 +224,43 @@ (frob /) (frob floor) (frob ceiling)) + +;; Check that the logic in SB-KERNEL::BASIC-COMPARE for doing fixnum/float +;; comparisons without rationalizing the floats still gives the right anwers +;; in the edge cases (had a fencepost error). +(macrolet ((test (range type sign) + `(let (ints + floats + (start (- ,(find-symbol (format nil + "MOST-~A-EXACTLY-~A-FIXNUM" + sign type) + :sb-kernel) + ,range))) + (dotimes (i (1+ (* ,range 2))) + (let* ((x (+ start i)) + (y (coerce x ',type))) + (push x ints) + (push y floats))) + (dolist (i ints) + (dolist (f floats) + (dolist (op '(< <= = >= >)) + (unless (eq (funcall op i f) + (funcall op i (rationalize f))) + (error "(not (eq (~a ~a ~f) (~a ~a ~a)))~%" + op i f + op i (rationalize f))) + (unless (eq (funcall op f i) + (funcall op (rationalize f) i)) + (error "(not (eq (~a ~f ~a) (~a ~a ~a)))~%" + op f i + op (rationalize f) i)))))))) + (test 32 double-float negative) + (test 32 double-float positive) + (test 32 single-float negative) + (test 32 single-float positive)) + +;; x86-64 sign-extension bug found using pfdietz's random tester. +(assert (= 286142502 + (funcall (lambda () + (declare (notinline logxor)) + (min (logxor 0 0 0 286142502))))))