X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcompiler.pure.lisp;h=4325bd26d1869bde571173f27df9e04bd24a7566;hb=4a4da2875171c4802af72defcb71d720e8fa8093;hp=cf08c46817e4e854d026feed39dded9ab365864d;hpb=d1858723258b286448f0c1584c096e6ea82451d6;p=sbcl.git diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index cf08c46..4325bd2 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -1678,19 +1678,24 @@ ;;; Bug reported by Timmy Douglas: overflow in bit vector setter with ;;; constant index and value. -(let* ((n (* 2 sb-vm::n-word-bits)) - (array1 (make-array n :element-type 'bit)) - (array2 (make-array n :element-type 'bit))) - (dotimes (i n) - (dotimes (v 2) - (let ((f (compile nil `(lambda (a) - (declare (type (simple-array bit (,n)) a)) - (setf (bit a ,i) ,v))))) - (fill array1 (- 1 v)) - (fill array2 (- 1 v)) - (funcall f array1) - (setf (aref array2 i) v) - (assert (equal array1 array2)))))) +(loop for n-bits = 1 then (* n-bits 2) + for type = `(unsigned-byte ,n-bits) + and v-max = (1- (ash 1 n-bits)) + while (<= n-bits sb-vm:n-word-bits) + do + (let* ((n (* 2 (1+ (- sb-vm::n-word-bits n-bits)))) + (array1 (make-array n :element-type type)) + (array2 (make-array n :element-type type))) + (dotimes (i n) + (dolist (v (list 0 v-max)) + (let ((f (compile nil `(lambda (a) + (declare (type (simple-array ,type (,n)) a)) + (setf (aref a ,i) ,v))))) + (fill array1 (- v-max v)) + (fill array2 (- v-max v)) + (funcall f array1) + (setf (aref array2 i) v) + (assert (every #'= array1 array2))))))) (let ((fn (compile nil '(lambda (x) (declare (type bit x)) @@ -1739,3 +1744,38 @@ (compile nil '(lambda (x y) (declare (type simple-bit-vector x y)) (equal x y)))) + +;;; MISC.550: CAST merging in IR1 finalization caused unexpected +;;; code transformations. +(assert (eql (funcall + (compile + nil + '(lambda (p1 p2) + (declare (optimize (speed 3) (safety 2) (debug 3) (space 3)) + (type atom p1) + (type symbol p2)) + (or p1 (the (eql t) p2)))) + nil t) + t)) + +;;; MISC.548: type check weakening converts required type into +;;; optional +(assert (eql t + (funcall + (compile + nil + '(lambda (p1) + (declare (optimize (speed 2) (safety 1) (debug 3) (space 2))) + (atom (the (member f assoc-if write-line t w) p1)))) + t))) + +;;; Free special bindings only apply to the body of the binding form, not +;;; the initialization forms. +(assert (eq :good + (funcall (compile 'nil + (lambda () + (let ((x :bad)) + (declare (special x)) + (let ((x :good)) + ((lambda (&optional (y x)) + (declare (special x)) y)))))))))