source: trunk/source/tests/ansi-tests/loop13.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 9.1 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Nov 17 12:37:45 2002
4;;;; Contains: Tests of DO, DOING, RETURN in LOOP.  Tests of NAMED loops
5
6(in-package :cl-test)
7
8(deftest loop.13.1
9  (loop do (return 10))
10  10)
11
12(deftest loop.13.2
13  (loop doing (return 10))
14  10)
15
16(deftest loop.13.3
17  (loop for i from 0 below 100 by 7
18        when (> i 50) return i)
19  56)
20
21(deftest loop.13.4
22  (let ((x 0))
23    (loop do
24          (incf x)
25          (when (= x 10) (return x))))
26  10)
27
28(deftest loop.13.5
29  (loop return 'a)
30  a)
31
32(deftest loop.13.6
33  (loop return (values)))
34
35(deftest loop.13.7
36  (loop return (values 1 2))
37  1 2)
38
39(deftest loop.13.8
40  (let* ((limit (min 1000 (1- (min call-arguments-limit
41                                   multiple-values-limit))))
42         (vals (make-list limit :initial-element :a))
43         (vals2 (multiple-value-list (eval `(loop return (values ,@vals))))))
44    (equalt vals vals2))
45  t)
46
47(deftest loop.13.9
48  (loop named foo return 'a)
49  a)
50
51(deftest loop.13.10
52  (block nil
53    (return (loop named foo return :good))
54    :bad)
55  :good)
56
57(deftest loop.13.11
58  (block nil
59    (loop named foo do (return :good))
60    :bad)
61  :good)
62
63(deftest loop.13.12
64  (loop named foo with a = (return-from foo :good) return :bad)
65  :good)
66
67(deftest loop.13.13
68  (loop named foo
69        with b = 1
70        and a = (return-from foo :good) return :bad)
71  :good)
72
73(deftest loop.13.14
74  (loop named foo
75        for a = (return-from foo :good) return :bad)
76  :good)
77
78(deftest loop.13.15
79  (loop named foo for a in (return-from foo :good))
80  :good)
81
82(deftest loop.13.16
83  (loop named foo for a from (return-from foo :good) return :bad)
84  :good)
85
86(deftest loop.13.17
87  (loop named foo for a on (return-from foo :good) return :bad)
88  :good)
89
90(deftest loop.13.18
91  (loop named foo for a across (return-from foo :good) return :bad)
92  :good)
93
94(deftest loop.13.19
95  (loop named foo for a being the hash-keys of (return-from foo :good)
96        return :bad)
97  :good)
98
99(deftest loop.13.20
100  (loop named foo for a being the symbols of (return-from foo :good)
101        return :bad)
102  :good)
103
104(deftest loop.13.21
105  (loop named foo repeat (return-from foo :good) return :bad)
106  :good)
107
108(deftest loop.13.22
109  (loop named foo for i from 0 to (return-from foo :good) return :bad)
110  :good)
111
112(deftest loop.13.23
113  (loop named foo for i from 0 to 10 by (return-from foo :good) return :bad)
114  :good)
115
116(deftest loop.13.24
117  (loop named foo for i from 10 downto (return-from foo :good) return :bad)
118  :good)
119
120(deftest loop.13.25
121  (loop named foo for i from 10 above (return-from foo :good) return :bad)
122  :good)
123
124(deftest loop.13.26
125  (loop named foo for i from 10 below (return-from foo :good) return :bad)
126  :good)
127
128(deftest loop.13.27
129  (loop named foo for i in '(a b c) by (return-from foo :good) return :bad)
130  :good)
131
132(deftest loop.13.28
133  (loop named foo for i on '(a b c) by (return-from foo :good) return :bad)
134  :good)
135
136(deftest loop.13.29
137  (loop named foo for i = 1 then (return-from foo :good))
138  :good)
139
140(deftest loop.13.30
141  (loop named foo for x in '(a b c) collect (return-from foo :good))
142  :good)
143
144(deftest loop.13.31
145  (loop named foo for x in '(a b c) append (return-from foo :good))
146  :good)
147
148(deftest loop.13.32
149  (loop named foo for x in '(a b c) nconc (return-from foo :good))
150  :good)
151
152(deftest loop.13.33
153  (loop named foo for x in '(a b c) count (return-from foo :good))
154  :good)
155
156(deftest loop.13.34
157  (loop named foo for x in '(a b c) sum (return-from foo :good))
158  :good)
159
160(deftest loop.13.35
161  (loop named foo for x in '(a b c) maximize (return-from foo :good))
162  :good)
163
164(deftest loop.13.36
165  (loop named foo for x in '(a b c) minimize (return-from foo :good))
166  :good)
167
168(deftest loop.13.37
169  (loop named foo for x in '(a b c) thereis (return-from foo :good))
170  :good)
171
172(deftest loop.13.38
173  (loop named foo for x in '(a b c) always (return-from foo :good))
174  :good)
175
176(deftest loop.13.39
177  (loop named foo for x in '(a b c) never (return-from foo :good))
178  :good)
179
180(deftest loop.13.40
181  (loop named foo for x in '(a b c) until (return-from foo :good))
182  :good)
183
184(deftest loop.13.41
185  (loop named foo for x in '(a b c) while (return-from foo :good))
186  :good)
187
188(deftest loop.13.42
189  (loop named foo for x in '(a b c) when (return-from foo :good) return :bad)
190  :good)
191
192(deftest loop.13.43
193  (loop named foo for x in '(a b c) unless (return-from foo :good) return :bad)
194  :good)
195
196(deftest loop.13.44
197  (loop named foo for x in '(a b c) if (return-from foo :good) return :bad)
198  :good)
199
200(deftest loop.13.45
201  (loop named foo for x in '(a b c) return (return-from foo :good))
202  :good)
203
204(deftest loop.13.46
205  (loop named foo initially (return-from foo :good) return :bad)
206  :good)
207
208(deftest loop.13.47
209  (loop named foo do (loop-finish) finally (return-from foo :good))
210  :good)
211
212
213(deftest loop.13.52
214  (block nil
215    (loop named foo with a = (return :good) return :bad)
216    :bad)
217  :good)
218
219(deftest loop.13.53
220  (block nil
221    (loop named foo
222          with b = 1
223          and a = (return :good) return :bad)
224    :bad)
225  :good)
226
227(deftest loop.13.54
228  (block nil
229    (loop named foo
230          for a = (return :good) return :bad)
231    :bad)
232  :good)
233
234(deftest loop.13.55
235  (block nil
236    (loop named foo for a in (return :good))
237    :bad)
238  :good)
239
240(deftest loop.13.56
241  (block nil
242    (loop named foo for a from (return :good) return :bad)
243    :bad)
244  :good)
245
246(deftest loop.13.57
247  (block nil
248    (loop named foo for a on (return :good) return :bad)
249    :bad)
250  :good)
251
252(deftest loop.13.58
253  (block nil
254    (loop named foo for a across (return :good) return :bad)
255    :bad)
256  :good)
257
258(deftest loop.13.59
259  (block nil
260    (loop named foo for a being the hash-keys of (return :good)
261          return :bad)
262    :bad)
263  :good)
264
265(deftest loop.13.60
266  (block nil
267    (loop named foo for a being the symbols of (return :good)
268          return :bad)
269    :bad)
270  :good)
271
272(deftest loop.13.61
273  (block nil
274    (loop named foo repeat (return :good) return :bad)
275    :bad)
276  :good)
277
278(deftest loop.13.62
279  (block nil
280    (loop named foo for i from 0 to (return :good) return :bad)
281    :bad)
282  :good)
283
284(deftest loop.13.63
285  (block nil
286    (loop named foo for i from 0 to 10 by (return :good) return :bad)
287    :bad)
288  :good)
289
290(deftest loop.13.64
291  (block nil
292    (loop named foo for i from 10 downto (return :good) return :bad)
293    :bad)
294  :good)
295
296(deftest loop.13.65
297  (block nil
298    (loop named foo for i from 10 above (return :good) return :bad)
299    :bad)
300  :good)
301
302(deftest loop.13.66
303  (block nil
304    (loop named foo for i from 10 below (return :good) return :bad)
305    :bad)
306  :good)
307
308(deftest loop.13.67
309  (block nil
310    (loop named foo for i in '(a b c) by (return :good) return :bad)
311    :bad)
312  :good)
313
314(deftest loop.13.68
315  (block nil
316    (loop named foo for i on '(a b c) by (return :good) return :bad)
317    :bad)
318  :good)
319
320(deftest loop.13.69
321  (block nil
322    (loop named foo for i = 1 then (return :good))
323    :bad)
324  :good)
325
326(deftest loop.13.70
327  (block nil
328    (loop named foo for x in '(a b c) collect (return :good))
329    :bad)
330  :good)
331
332(deftest loop.13.71
333  (block nil
334    (loop named foo for x in '(a b c) append (return :good))
335    :bad)
336  :good)
337
338(deftest loop.13.72
339  (block nil
340    (loop named foo for x in '(a b c) nconc (return :good))
341    :bad)
342  :good)
343
344(deftest loop.13.73
345  (block nil
346    (loop named foo for x in '(a b c) count (return :good))
347    :bad)
348  :good)
349
350(deftest loop.13.74
351  (block nil
352    (loop named foo for x in '(a b c) sum (return :good))
353    :bad)
354  :good)
355
356(deftest loop.13.75
357  (block nil
358    (loop named foo for x in '(a b c) maximize (return :good))
359    :bad)
360  :good)
361
362(deftest loop.13.76
363  (block nil
364    (loop named foo for x in '(a b c) minimize (return :good))
365    :bad)
366  :good)
367
368(deftest loop.13.77
369  (block nil
370    (loop named foo for x in '(a b c) thereis (return :good))
371    :bad)
372  :good)
373
374(deftest loop.13.78
375  (block nil
376    (loop named foo for x in '(a b c) always (return :good))
377    :bad)
378  :good)
379
380(deftest loop.13.79
381  (block nil
382    (loop named foo for x in '(a b c) never (return :good))
383    :bad)
384  :good)
385
386(deftest loop.13.80
387  (block nil
388    (loop named foo for x in '(a b c) until (return :good))
389    :bad)
390  :good)
391
392(deftest loop.13.81
393  (block nil
394    (loop named foo for x in '(a b c) while (return :good))
395    :bad)
396  :good)
397
398(deftest loop.13.82
399  (block nil
400    (loop named foo for x in '(a b c) when (return :good) return :bad)
401    :bad)
402  :good)
403
404(deftest loop.13.83
405  (block nil
406    (loop named foo for x in '(a b c) unless (return :good) return :bad)
407    :bad)
408  :good)
409
410(deftest loop.13.84
411  (block nil
412    (loop named foo for x in '(a b c) if (return :good) return :bad)
413    :bad)
414  :good)
415
416(deftest loop.13.85
417  (block nil
418    (loop named foo for x in '(a b c) return (return :good))
419    :bad)
420  :good)
421
422(deftest loop.13.86
423  (block nil
424    (loop named foo initially (return :good) return :bad)
425    :bad)
426  :good)
427
428(deftest loop.13.87
429  (block nil
430    (loop named foo do (loop-finish) finally (return :good))
431    :bad)
432  :good)
433
434;;; Test that explicit calls to macroexpand in subforms
435;;; are done in the correct environment
436
437(deftest loop.13.88
438  (macrolet
439   ((%m (z) z))
440   (loop do (expand-in-current-env (%m (return 10)))))
441  10)
442
443(deftest loop.13.89
444  (macrolet
445   ((%m (z) z))
446   (loop for i from 0 below 100 by 7
447         when (> i 50) return (expand-in-current-env (%m i))))
448  56)
449
450(deftest loop.13.90
451  (macrolet
452   ((%m (z) z))
453   (loop return (expand-in-current-env (%m 'a))))
454  a)
Note: See TracBrowser for help on using the repository browser.