X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Floop.pure.lisp;h=febf5a79ca24ee8f0c436d4418dc05f6b411610e;hb=4ed3f0d08c3a57a6762018d9622f253ab9d0f2b6;hp=95933d4d5ac8cd99b7294d4a0a3b6fc5cc0d7f34;hpb=caf8bb05a82659e688c125b418783bc8a3bd2be8;p=sbcl.git diff --git a/tests/loop.pure.lisp b/tests/loop.pure.lisp index 95933d4..febf5a7 100644 --- a/tests/loop.pure.lisp +++ b/tests/loop.pure.lisp @@ -179,3 +179,38 @@ (assert (= (loop for v fixnum being each hash-value in ht sum v) 18)) (assert (raises-error? (loop for v float being each hash-value in ht sum v) type-error))) + +;; arithmetic indexes can be NIL or symbols. +(assert (equal (loop for nil from 0 to 2 collect nil) + '(nil nil nil))) +(assert (equal (loop for nil to 2 collect nil) + '(nil nil nil))) + +;; although allowed by the loop syntax definition in 6.2/LOOP, +;; 6.1.2.1.1 says: "The variable var is bound to the value of form1 in +;; the first iteration[...]"; since we can't bind (i j) to anything, +;; we give a program error. +(multiple-value-bind (function warnings-p failure-p) + (compile nil + `(lambda () + (loop for (i j) from 4 to 6 collect nil))) + (assert failure-p)) + +;; ...and another for indexes without FROM forms (these are treated +;; differently by the loop code right now +(multiple-value-bind (function warnings-p failure-p) + (compile nil + `(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)))