X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Floop.pure.lisp;h=307129b5103e106ee0fddcd1eb9aa46856d1655b;hb=89925c1f87e50d52862bf26bfa07962925ddb403;hp=4aa64abecca428faf2487ff5ff1396c9d9ff18ae;hpb=f4f18b9dcdaf1948947b1747f5bfa766a1a0ee4c;p=sbcl.git diff --git a/tests/loop.pure.lisp b/tests/loop.pure.lisp index 4aa64ab..307129b 100644 --- a/tests/loop.pure.lisp +++ b/tests/loop.pure.lisp @@ -22,3 +22,91 @@ collect key) #'string<)) '(key1 key2))) + +;;; Bug 81, reported by Wolfhard Buss on cmucl-help 2001-02-14, was +;;; fixed by Alexey Dejneka's patch on sbcl-devel 2001-09-30. +(assert (equal '(0.0 1.0 2.0 3.0) + (loop with (a . b) of-type float = '(0.0 . 1.0) + and (c . d) of-type float = '(2.0 . 3.0) + return (list a b c d)))) + +;;; a bug reported and fixed by Alexey Dejneka sbcl-devel 2001-10-05: +;;; The type declarations should apply, hence under Python's +;;; declarations-are-assertions rule, the code should signal a type +;;; error. +(assert (typep (nth-value 1 + (ignore-errors + (funcall (lambda () + (loop with (a . b) + of-type float = '(5 . 5) + return (list a b)))))) + 'type-error)) + +;;; bug 103, reported by Arthur Lemmens sbcl-devel 2001-05-05, +;;; fixed by Alexey Dejneka patch sbcl-devel 2001-10-05: +;;; LOOP syntax requires that forms after INITIALLY, FINALLY, and DO +;;; must be compound forms. +(multiple-value-bind (function warnings-p failure-p) + (compile nil + '(lambda () + (loop while t do + *print-level* + (print t)))) + (declare (ignore function warnings-p)) + (assert failure-p)) + +;;; a bug reported by Paul F. Dietz (in his ANSI test suite): +;;; duplicate bindings in LOOP must signal errors of type +;;; PROGRAM-ERROR. +(assert (typep (nth-value 1 + (ignore-errors + (funcall (lambda () + (loop for (a . a) in '((1 . 2) (3 . 4)) + return a))))) + '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))