0.7.9.59:
[sbcl.git] / tests / loop.pure.lisp
index 23f6691..307129b 100644 (file)
                            (funcall (lambda ()
                                       (loop for (a . a) in '((1 . 2) (3 . 4))
                                             return a)))))
-              'program-error))
\ No newline at end of file
+              'program-error))
+
+;;; similar to gcl/ansi-test LOOP.1.27, and fixed at the same time:
+(assert (equal (loop for x downto 7 by 2 from 13 collect x) '(13 11 9 7)))
+
+;;; some more from gcl/ansi-test:
+(let ((table (make-hash-table)))
+  (setf (gethash 'foo table) '(bar baz))
+  (assert (= (loop for nil being the hash-keys of table count t) 1))
+  (assert (equal (loop for nil being the hash-keys of table
+                              using (hash-value (v1 . v2))
+                      when v1
+                        return v2)
+                '(baz))))
+
+(assert (= (loop for nil being the external-symbols of :cl count t) 978))
+(assert (= (loop for x being the external-symbols of :cl count x) 977))
+
+(let ((*package* (find-package :cl)))
+  (assert (= (loop for x being each external-symbol count t) 978)))
+
+(assert (eq (loop for a = (return t) return nil) t))
+
+(multiple-value-bind (result error)
+    (ignore-errors
+      (loop for nil being the external-symbols of :nonexistent-package
+           count t))
+  (assert (null result))
+  (assert (typep error 'package-error)))
+
+(assert (equal (loop for i from 1 repeat (the (integer 7 7) 7) collect i)
+               '(1 2 3 4 5 6 7)))
+
+(multiple-value-bind (result error)
+    (ignore-errors
+      (eval '(loop for i from 1 repeat 7 of-type fixnum collect i)))
+  (assert (null result))
+  (assert (typep error 'program-error)))
+
+(assert (equal
+        (ignore-errors (loop for i from 1 repeat 6.5 collect i))
+        (ignore-errors (loop for i from 1 repeat (eval '6.5) collect i))))
+
+(assert (eq (block nil
+             (loop named foo do (loop-finish) finally (return :good))
+             :bad)
+           :good))