X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Farith.pure.lisp;h=777b370a65487c2ab7b231c510a0925a1a3d005f;hb=91ab8b634b86ea43a985d35c7fa58e7432f1a28a;hp=e6543e7f2fecd5a542199ba52d39b930d6b66c6c;hpb=bf69a011740c082566642b2335a9968b441cadec;p=sbcl.git diff --git a/tests/arith.pure.lisp b/tests/arith.pure.lisp index e6543e7..777b370 100644 --- a/tests/arith.pure.lisp +++ b/tests/arith.pure.lisp @@ -371,8 +371,12 @@ ;; GCD used to sometimes return negative values. The following did, on 32 bit ;; builds. (with-test (:name :gcd) + ;; from lp#413680 (assert (plusp (gcd 20286123923750474264166990598656 - 680564733841876926926749214863536422912)))) + 680564733841876926926749214863536422912))) + ;; from lp#516750 + (assert (plusp (gcd 2596102012663483082521318626691873 + 2596148429267413814265248164610048)))) (with-test (:name :expt-zero-zero) ;; Check that (expt 0.0 0.0) and (expt 0 0.0) signal error, but (expt 0.0 0) @@ -555,3 +559,28 @@ (declare (type (integer -3 57216651) a)) (ldb (byte 9 27) a))))) (assert (= 0 (- (funcall one 10) (funcall two 10)))))) + +;; The ISQRT implementation is sufficiently complicated that it should +;; be tested. +(with-test (:name :isqrt) + (labels ((test (x) + (let* ((r (isqrt x)) + (r2 (expt r 2)) + (s2 (expt (1+ r) 2))) + (unless (and (<= r2 x) + (> s2 x)) + (error "isqrt failure for ~a" x)))) + (tests (x) + (test x) + (let ((x2 (expt x 2))) + (test x2) + (test (1+ x2)) + (test (1- x2))))) + (loop for i from 1 to 200 + for pow = (expt 2 (1- i)) + for j = (+ pow (random pow)) + do + (tests i) + (tests j)) + (dotimes (i 10) + (tests (random (expt 2 (+ 1000 (random 10000))))))))