0.8.3.39:
[sbcl.git] / tests / arith.impure.lisp
index e45ab9f..27948bd 100644 (file)
 (assert (= (compiled-logxor -6) -6))
 
 (assert (raises-error? (coerce (expt 10 1000) 'single-float) type-error))
+\f
+(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))
+
+(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))
+\f
 (sb-ext:quit :unix-status 104)