X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Farith.impure.lisp;h=e4c7e7d6b46b331554bbefddc8ad9c018ec4ca2d;hb=32d188868633a7c7db73da03f20ee5a107ed6f31;hp=11b1009a19394546f5a5d1cc052eae11d2c7d674;hpb=0957d59ccfaf3db9aaf79a7f4909a40ea0ca0dcd;p=sbcl.git diff --git a/tests/arith.impure.lisp b/tests/arith.impure.lisp index 11b1009..e4c7e7d 100644 --- a/tests/arith.impure.lisp +++ b/tests/arith.impure.lisp @@ -67,5 +67,35 @@ (assert (= (compiled-logxor -6) -6)) (assert (raises-error? (coerce (expt 10 1000) 'single-float) type-error)) + +(defun are-we-getting-ash-right (x y) + (declare (optimize speed) + (type (unsigned-byte 32) x) + (type (integer -40 0) y)) + (ash x y)) +(defun what-about-with-constants (x) + (declare (optimize speed) (type (unsigned-byte 32) x)) + (ash x -32)) -(sb-ext:quit :unix-status 104) \ No newline at end of file +(dotimes (i 41) + (assert (= (are-we-getting-ash-right (1- (ash 1 32)) (- i)) + (if (< i 32) + (1- (ash 1 (- 32 i))) + 0)))) +(assert (= (what-about-with-constants (1- (ash 1 32))) 0)) + +(defun one-more-test-case-to-catch-sparc (x y) + (declare (optimize speed (safety 0)) + (type (unsigned-byte 32) x) (type (integer -40 2) y)) + (the (unsigned-byte 32) (ash x y))) +(assert (= (one-more-test-case-to-catch-sparc (1- (ash 1 32)) -40) 0)) + +(defun 64-bit-logcount (x) + (declare (optimize speed) (type (unsigned-byte 54) x)) + (logcount x)) +(assert (= (64-bit-logcount (1- (ash 1 24))) 24)) +(assert (= (64-bit-logcount (1- (ash 1 32))) 32)) +(assert (= (64-bit-logcount (1- (ash 1 48))) 48)) +(assert (= (64-bit-logcount (1- (ash 1 54))) 54)) + +(sb-ext:quit :unix-status 104)