X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcompiler.pure.lisp;h=fbadfe9e11814f2a9a60d693cf7863e087d6dada;hb=a4ea3949e051d8c9248b231f175d54a20618743e;hp=c74f9b4ee1248a6d2702a961295b5d05b823789a;hpb=7619132f587e6d30935a38cd19da7d0d80dbc7a3;p=sbcl.git diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index c74f9b4..fbadfe9 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -2684,6 +2684,27 @@ (assert (eq 'list type)) (assert derivedp))) +(with-test (:name :rest-list-type-derivation3) + (multiple-value-bind (type derivedp) + (funcall (funcall (compile nil `(lambda () + (lambda (&optional x &rest args) + (unless x (error "oops")) + (ctu:compiler-derived-type args))))) + t) + (assert (eq 'list type)) + (assert derivedp))) + +(with-test (:name :rest-list-type-derivation4) + (multiple-value-bind (type derivedp) + (funcall (funcall (compile nil `(lambda () + (lambda (&optional x &rest args) + (declare (type (or null integer) x)) + (when x (setf args x)) + (ctu:compiler-derived-type args))))) + 42) + (assert (equal '(or cons null integer) type)) + (assert derivedp))) + (with-test (:name :base-char-typep-elimination) (assert (eq (funcall (lambda (ch) (declare (type base-char ch) (optimize (speed 3) (safety 0))) @@ -3620,3 +3641,43 @@ (assert (equal '(integer 0 (3)) (type-error-expected-type e))) :caught)))))) +(with-test (:name :bug-655203-regression) + (let ((fun (compile nil + `(LAMBDA (VARIABLE) + (LET ((CONTINUATION + (LAMBDA + (&OPTIONAL DUMMY &REST OTHER) + (DECLARE (IGNORE OTHER)) + (PRIN1 DUMMY) + (PRIN1 VARIABLE)))) + (FUNCALL CONTINUATION (LIST 1 2))))))) + ;; This used to signal a bogus type-error. + (assert (equal (with-output-to-string (*standard-output*) + (funcall fun t)) + "(1 2)T")))) + +(with-test (:name :constant-concatenate-compile-time) + (flet ((make-lambda (n) + `(lambda (x) + (declare (optimize (speed 3) (space 0))) + (concatenate 'string x ,(make-string n))))) + (let* ((l0 (make-lambda 1)) + (l1 (make-lambda 10)) + (l2 (make-lambda 100)) + (l3 (make-lambda 1000)) + (t0 (get-internal-run-time)) + (f0 (compile nil l0)) + (t1 (get-internal-run-time)) + (f1 (compile nil l1)) + (t2 (get-internal-run-time)) + (f2 (compile nil l2)) + (t3 (get-internal-run-time)) + (f3 (compile nil l3)) + (t4 (get-internal-run-time)) + (d0 (- t1 t0)) + (d1 (- t2 t1)) + (d2 (- t3 t2)) + (d3 (- t4 t3)) + (short-avg (/ (+ d0 d1 d2) 3))) + (assert (and f1 f2 f3)) + (assert (< d3 (* 10 short-avg))))))