0.8.17.17:
[sbcl.git] / tests / compiler.pure.lisp
index e9ca625..3bfaf65 100644 (file)
          '(lambda (s ei x y)
            (declare (type (simple-array function (2)) s) (type ei ei))
            (funcall (aref s ei) x y))))
+
+;;; MISC.320: ir1-transform can create an intercomponent reference to
+;;; a DEFINED-FUN.
+(assert (eql 102 (funcall
+  (compile
+   nil
+   '(lambda ()
+     (declare (optimize (speed 3) (space 0) (safety 2)
+               (debug 2) (compilation-speed 0)))
+     (catch 'ct2
+       (elt '(102)
+            (flet ((%f12 () (rem 0 -43)))
+              (multiple-value-call #'%f12 (values))))))))))
+
+;;; MISC.437: lost reoptimization after FLUSH-DEST
+(assert (zerop (funcall
+  (compile
+   nil
+   '(lambda (a b c d e)
+     (declare (notinline values complex eql))
+     (declare
+      (optimize (compilation-speed 3)
+       (speed 3)
+       (debug 1)
+       (safety 1)
+       (space 0)))
+     (flet ((%f10
+                (f10-1 f10-2 f10-3
+                       &optional (f10-4 (ignore-errors 0)) (f10-5 0)
+                       &key &allow-other-keys)
+              (if (or (eql 0 0) t) 0 (if f10-1 0 0))))
+       (complex (multiple-value-call #'%f10 (values a c b 0 0)) 0))))
+   80043 74953652306 33658947 -63099937105 -27842393)))
+
+;;; bug #351 -- program-error for malformed LET and LET*, including those
+;;; resulting from SETF of LET.
+(dolist (fun (list (compile nil '(lambda () (let :bogus-let :oops)))
+                   (compile nil '(lambda () (let* :bogus-let* :oops)))
+                   (compile nil '(lambda (x) (push x (let ((y 0)) y))))))
+  (assert (functionp fun))
+  (multiple-value-bind (res err) (ignore-errors (funcall fun))
+    (assert (not res))
+    (assert (typep err 'program-error))))
+
+(let ((fun (compile nil '(lambda (x) (random (if x 10 20))))))
+  (dotimes (i 100 (error "bad RANDOM distribution"))
+    (when (> (funcall fun nil) 9)
+      (return t)))
+  (dotimes (i 100)
+    (when (> (funcall fun t) 9)
+      (error "bad RANDOM event"))))