X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Floop.pure.lisp;h=6d5f3e4739207891390b594a0e1ffa49d92a6f4b;hb=7c7e6276719b8d40fddec2070cad81064a25c8ed;hp=8d4146e6226550d3dc03c2e32d6458bd0d2467fb;hpb=4b57a4917b61299ac074fa385e9a0c62a716655b;p=sbcl.git diff --git a/tests/loop.pure.lisp b/tests/loop.pure.lisp index 8d4146e..6d5f3e4 100644 --- a/tests/loop.pure.lisp +++ b/tests/loop.pure.lisp @@ -203,3 +203,36 @@ `(lambda () (loop for (i j) to 6 collect nil))) (assert failure-p)) + +(assert + (equal + (let ((x 2d0)) + (loop for d of-type double-float from 0d0 to 10d0 by x collect d)) + '(0d0 2d0 4d0 6d0 8d0 10d0))) +(assert + (equal + (let ((x 2d0)) + (loop for d of-type double-float downfrom 10d0 to 0d0 by x collect d)) + '(10d0 8d0 6d0 4d0 2d0 0d0))) + +(let ((fn (handler-case + (compile nil '(lambda () + (declare (special x y)) + (loop thereis (pop x) thereis (pop y)))) + (warning (c) (error "Warned: ~S" c))))) + (let ((x (list nil nil 1)) + (y (list nil 2 nil))) + (declare (special x y)) + (assert (= (funcall fn) 2)))) + +;;; Incorrect LIST type declaration, reported and patched by Teemu +;;; Kalvas: end testing is done "as if by atom" so this is supposed +;;; to work. +(assert (equal '(1 2) (loop for (a . b) on '(1 2 . 3) collect a))) + +;;; Detection of duplicate bindings, reported by Bruno Haible for CMUCL. +(multiple-value-bind (_ condition) + (ignore-errors + (macroexpand '(LOOP WITH A = 0 FOR A DOWNFROM 10 TO 0 DO (PRINT A)))) + (declare (ignore _)) + (assert (typep condition 'program-error)))