/[gcl]/gcl/ansi-tests/macrolet.lsp
ViewVC logotype

Diff of /gcl/ansi-tests/macrolet.lsp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by pfdietz, Sun Feb 23 12:19:43 2003 UTC revision 1.5 by pfdietz, Sat Apr 19 16:13:34 2003 UTC
# Line 144  Line 144 
144    a)    a)
145    
146  (deftest macrolet.16  (deftest macrolet.16
147     (loop for s in *cl-non-function-macro-special-operator-symbols*    (loop for s in *cl-non-function-macro-special-operator-symbols*
148          for form = `(classify-error (macrolet ((,s () ''a)) (,s)))          for form = `(classify-error (macrolet ((,s () ''a)) (,s)))
149          unless (eq (eval form) 'a)          unless (eq (eval form) 'a)
150          collect s)          collect s)
151    nil)    nil)
152    
153    (deftest macrolet.17
154      (macrolet ((%m (&key (a t)) `(quote ,a)))
155        (%m :a nil))
156      nil)
157    
158    (deftest macrolet.18
159      (macrolet ((%m (&key (a t a-p)) `(quote (,a ,(notnot a-p)))))
160        (%m :a nil))
161      (nil t))
162    
163    (deftest macrolet.19
164      (macrolet ((%m (x &optional y) `(quote (,x ,y))))
165        (values (%m 1) (%m 2 3)))
166      (1 nil)
167      (2 3))
168    
169    (deftest macrolet.20
170      (macrolet ((%m (x &optional (y 'a)) `(quote (,x ,y))))
171        (values (%m 1) (%m 2 3)))
172      (1 a)
173      (2 3))
174    
175    ;;; Note -- the supplied-p parameter in a macrolet &optional
176    ;;; is required to be T (not just true) if the parameter is present.
177    ;;; See section 3.4.4.1.2
178    (deftest macrolet.21
179      (macrolet ((%m (x &optional (y 'a y-p)) `(quote (,x ,y ,y-p))))
180        (values (%m 1) (%m 2 3)))
181      (1 a nil)
182      (2 3 t))
183    
184    (deftest macrolet.22
185      (macrolet ((%m (x &optional ((y z) '(2 3))) `(quote (,x ,y ,z))))
186        (values
187         (%m a)
188         (%m a (b c))))
189      (a 2 3)
190      (a b c))
191    
192    (deftest macrolet.22
193      (macrolet ((%m (x &optional ((y z) '(2 3) y-z-p))
194                     `(quote (,x ,y ,z ,y-z-p))))
195        (values
196         (%m a)
197         (%m a (b c))))
198      (a 2 3 nil)
199      (a b c t))
200    
201    (deftest macrolet.23
202      (macrolet ((%m (&rest y) `(quote ,y)))
203        (%m 1 2 3))
204      (1 2 3))
205    
206    ;;; According to 3.4.4.1.2, the entity following &rest is
207    ;;; 'a destructuring pattern that matches the rest of the list.'
208    
209    (deftest macrolet.24
210      (macrolet ((%m (&rest (x y z)) `(quote (,x ,y ,z))))
211        (%m 1 2 3))
212      (1 2 3))
213    
214    (deftest macrolet.25
215      (macrolet ((%m (&body (x y z)) `(quote (,x ,y ,z))))
216        (%m 1 2 3))
217      (1 2 3))
218    
219    ;;; More key parameters
220    
221    (deftest macrolet.26
222      (macrolet ((%m (&key ((:a b))) `(quote ,b)))
223        (values (%m)
224                (%m :a x)))
225      nil
226      x)
227    
228    (deftest macrolet.27
229      (macrolet ((%m (&key ((:a (b c)))) `(quote (,c ,b))))
230        (%m :a (1 2)))
231      (2 1))
232    
233    (deftest macrolet.28
234      (macrolet ((%m (&key ((:a (b c)) '(3 4))) `(quote (,c ,b))))
235        (values (%m :a (1 2))
236                (%m :a (1 2) :a (10 11))
237                (%m)))
238      (2 1)
239      (2 1)
240      (4 3))
241    
242    (deftest macrolet.29
243      (macrolet ((%m (&key a (b a)) `(quote (,a ,b))))
244        (values (%m)
245                (%m :a 1)
246                (%m :b 2)
247                (%m :a 3 :b 4)
248                (%m :b 5 :a 6)
249                (%m :a 7 :a 8)
250                (%m :a 9 :b nil)
251                (%m :a 10 :b nil :b 11)))
252      (nil nil)
253      (1 1)
254      (nil 2)
255      (3 4)
256      (6 5)
257      (7 7)
258      (9 nil)
259      (10 nil))
260    
261    (deftest macrolet.30
262      (macrolet ((%m ((&key a) &key (b a)) `(quote (,a ,b))))
263        (values (%m ())
264                (%m (:a 1))
265                (%m () :b 2)
266                (%m (:a 3) :b 4)
267                (%m (:a 7 :a 8))
268                (%m (:a 9) :b nil)
269                (%m (:a 10) :b nil :b 11)))
270      (nil nil)
271      (1 1)
272      (nil 2)
273      (3 4)
274      (7 7)
275      (9 nil)
276      (10 nil))
277    
278    (deftest macrolet.31
279      (macrolet ((%m (&key ((:a (b c)) '(3 4) a-p))
280                     `(quote (,(notnot a-p) ,c ,b))))
281        (values (%m :a (1 2))
282                (%m :a (1 2) :a (10 11))
283                (%m)))
284      (t 2 1)
285      (t 2 1)
286      (nil 4 3))
287    
288    ;;; Allow-other-keys tests
289    
290    (deftest macrolet.32
291      (macrolet ((%m (&key a b c) `(quote (,a ,b ,c))))
292        (values
293         (%m :allow-other-keys nil)
294         (%m :a 1 :allow-other-keys nil)
295         (%m :allow-other-keys t)
296         (%m :allow-other-keys t :allow-other-keys nil :foo t)
297         (%m :allow-other-keys t :c 1 :b 2 :a 3)
298         (%m :allow-other-keys nil :c 1 :b 2 :a 3)))
299      (nil nil nil)
300      (1 nil nil)
301      (nil nil nil)
302      (nil nil nil)
303      (3 2 1)
304      (3 2 1))
305    
306    (deftest macrolet.33
307      (macrolet ((%m (&key allow-other-keys) `(quote ,allow-other-keys)))
308        (values
309         (%m)
310         (%m :allow-other-keys nil)
311         (%m :allow-other-keys t :foo t)))
312      nil
313      nil
314      t)
315    
316    (deftest macrolet.34
317      (macrolet ((%m (&key &allow-other-keys) :good))
318        (values
319         (%m)
320         (%m :foo t)
321         (%m :allow-other-keys nil :foo t)))
322      :good
323      :good
324      :good)
325    
326    (deftest macrolet.35
327      (macrolet ((%m (&key a b &allow-other-keys) `(quote (,a ,b))))
328        (values
329         (%m :a 1)
330         (%m :foo t :b 2)
331         (%m :allow-other-keys nil :a 1 :foo t :b 2)))
332      (1 nil)
333      (nil 2)
334      (1 2))
335    
336  ;;; Symbol-macrolet tests  ;;; Symbol-macrolet tests
337    
338  (deftest symbol-macrolet.1  (deftest symbol-macrolet.1

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26