2
;;;; Author: Paul Dietz
3
;;;; Created: Tue Nov 12 06:30:14 2002
4
;;;; Contains: Tests of LOOP local variable initialization
9
(loop with x = 1 do (return x))
14
with y = (1+ x) do (return (list x y)))
20
with y = (1+ x) do (return (list x y))))
35
(loop with a t = 1 return a)
39
(loop with a fixnum = 2 return a)
43
(loop with a float = 3.0 return a)
47
(loop with a of-type string = "abc" return a)
51
(loop with (a b) = '(1 2) return (list b a))
55
(loop with (a b) of-type (fixnum fixnum) = '(3 4) return (+ a b))
59
(loop with a of-type fixnum return a)
63
(loop with a of-type float return a)
67
(loop with a of-type t return a)
71
(loop with a t return a)
75
(loop with a t and b t return (list a b))
79
(loop with (a b c) of-type (fixnum float t) return (list a b c))
83
(loop with nil = nil return nil)
86
;;; The NIL block of a loop encloses the entire loop.
89
(loop with nil = (return t) return nil)
93
(loop with (nil a) = '(1 2) return a)
97
(loop with (a nil) = '(1 2) return a)
102
and (a nil) = '(1 2) return (list a b))
107
and (nil a) = '(1 2) return (list a b))
110
;;; The NIL block of a loop encloses the entire loop.
121
;;; The spec says (in section 6.1.1.7) that:
122
;;; "An error of type program-error is signaled (at macro expansion time)
123
;;; if the same variable is bound twice in any variable-binding clause
124
;;; of a single loop expression. Such variables include local variables,
125
;;; iteration control variables, and variables found by destructuring."
127
;;; This is somewhat ambiguous. Test loop.8.error.1 binds A twice in
128
;;; the same clause, but loop.8.error.2 binds A in two different clauses.
129
;;; I am interpreting the spec as ruling out the latter as well.
131
(deftest loop.8.error.1
138
(deftest loop.8.error.2