X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Farith.pure.lisp;h=d257edca253595c0aae4d9bfa346af9e0ccaa52c;hb=a189a69454ef7635149319ae213b337f17c50d20;hp=c78b328b5ae4fdba258e8a5f97c5e86607a0c6b1;hpb=dabb26b93be9bbf2718951ea2200fca874d3d587;p=sbcl.git diff --git a/tests/arith.pure.lisp b/tests/arith.pure.lisp index c78b328..d257edc 100644 --- a/tests/arith.pure.lisp +++ b/tests/arith.pure.lisp @@ -586,3 +586,71 @@ (tests j)) (dotimes (i 10) (tests (random (expt 2 (+ 1000 (random 10000)))))))) + +;; bug 1026634 (reported by Eric Marsden on sbcl-devel) +(with-test (:name :recursive-cut-to-width) + (assert (eql (funcall + (compile nil + `(lambda (x) + (declare (optimize (space 3)) + (type (integer 12417236377505266230 + 12417274239874990070) x)) + (logand 8459622733968096971 x))) + 12417237222845306758) + 2612793697039849090))) + +;; Also reported by Eric Marsden on sbcl-devel (2013-06-06) +(with-test (:name :more-recursive-cut-to-width) + (assert (eql (funcall + (compile nil `(lambda (a b) + (declare (optimize (speed 2) (safety 0))) + (logand (the (eql 16779072918521075607) a) + (the (integer 21371810342718833225 21371810343571293860) b)))) + 16779072918521075607 21371810342718833263) + 2923729245085762055))) + +(with-test (:name :complicated-logand-identity) + (loop for k from -8 upto 8 do + (loop for min from -16 upto 16 do + (loop for max from min upto 16 do + (let ((f (compile nil `(lambda (x) + (declare (type (integer ,min ,max) x)) + (logand x ,k))))) + (loop for x from min upto max do + (assert (eql (logand x k) (funcall f x))))))))) + +(with-test (:name :complicated-logior-identity) + (loop for k from -8 upto 8 do + (loop for min from -16 upto 16 do + (loop for max from min upto 16 do + (let ((f (compile nil `(lambda (x) + (declare (type (integer ,min ,max) x)) + (logior x ,k))))) + (loop for x from min upto max do + (assert (eql (logior x k) (funcall f x))))))))) + +(with-test (:name :ldb-negative-index-no-error) + (assert + (raises-error? + (funcall (compile nil + `(lambda (x y) + (ldb (byte x y) 100))) + -1 -2))) + (assert + (raises-error? + (funcall (compile nil + `(lambda (x y) + (mask-field (byte x y) 100))) + -1 -2))) + (assert + (raises-error? + (funcall (compile nil + `(lambda (x y) + (dpb 0 (byte x y) 100))) + -1 -2))) + (assert + (raises-error? + (funcall (compile nil + `(lambda (x y) + (deposit-field 0 (byte x y) 100))) + -1 -2))))