~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to ansi-tests/loop16.lsp

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;-*- Mode:     Lisp -*-
 
2
;;;; Author:   Paul Dietz
 
3
;;;; Created:  Thu Nov 21 09:46:27 2002
 
4
;;;; Contains: Tests that uninterned symbols can be loop keywords
 
5
 
 
6
(in-package :cl-test)
 
7
 
 
8
 
 
9
(deftest loop.16.30
 
10
  (loop #:for i #:from 1 #:to 10 #:collect i)
 
11
  (1 2 3 4 5 6 7 8 9 10))
 
12
 
 
13
(deftest loop.16.31
 
14
  (loop #:for i #:upfrom 1 #:below 10 #:by 2 #:collect i)
 
15
  (1 3 5 7 9))
 
16
 
 
17
(deftest loop.16.32
 
18
  (loop #:with x = 1 #:and y = 2 #:return (values x y))
 
19
  1 2)
 
20
 
 
21
(deftest loop.16.33
 
22
  (loop #:named foo #:doing (return-from foo 1))
 
23
  1)
 
24
 
 
25
(deftest loop.16.34
 
26
  (let ((x 0))
 
27
    (loop
 
28
     #:initially (setq x 2)
 
29
     #:until t
 
30
     #:finally (return x)))
 
31
  2)
 
32
 
 
33
(deftest loop.16.35
 
34
  (loop #:for x #:in '(a b c) #:collecting x)
 
35
  (a b c))
 
36
 
 
37
(deftest loop.16.36
 
38
  (loop #:for x #:in '(a b c) #:append (list x))
 
39
  (a b c))
 
40
 
 
41
(deftest loop.16.37
 
42
  (loop #:for x #:in '(a b c) #:appending (list x))
 
43
  (a b c))
 
44
 
 
45
(deftest loop.16.38
 
46
  (loop #:for x #:in '(a b c) #:nconc (list x))
 
47
  (a b c))
 
48
 
 
49
(deftest loop.16.39
 
50
  (loop #:for x #:in '(a b c) #:nconcing (list x))
 
51
  (a b c))
 
52
 
 
53
(deftest loop.16.40
 
54
  (loop #:for x #:in '(1 2 3) #:count x)
 
55
  3)
 
56
 
 
57
(deftest loop.16.41
 
58
  (loop #:for x #:in '(1 2 3) #:counting x)
 
59
  3)
 
60
 
 
61
(deftest loop.16.42
 
62
  (loop #:for x #:in '(1 2 3) #:sum x)
 
63
  6)
 
64
 
 
65
(deftest loop.16.43
 
66
  (loop #:for x #:in '(1 2 3) #:summing x)
 
67
  6)
 
68
 
 
69
(deftest loop.16.44
 
70
  (loop #:for x #:in '(10 20 30) #:maximize x)
 
71
  30)
 
72
 
 
73
(deftest loop.16.45
 
74
  (loop #:for x #:in '(10 20 30) #:maximizing x)
 
75
  30)
 
76
 
 
77
(deftest loop.16.46
 
78
  (loop #:for x #:in '(10 20 30) #:minimize x)
 
79
  10)
 
80
 
 
81
(deftest loop.16.47
 
82
  (loop #:for x #:in '(10 20 30) #:minimizing x)
 
83
  10)
 
84
 
 
85
(deftest loop.16.48
 
86
  (loop #:for x #:in '(1 2 3 4) #:sum x #:into foo #:of-type fixnum
 
87
        #:finally (return foo))
 
88
  10)
 
89
 
 
90
(deftest loop.16.49
 
91
  (loop #:for x #:upfrom 1 #:to 10
 
92
        #:if (evenp x) #:sum x #:into foo
 
93
        #:else #:sum x #:into bar
 
94
        #:end
 
95
        #:finally (return (values foo bar)))
 
96
  30 25)
 
97
 
 
98
(deftest loop.16.50
 
99
  (loop #:for x #:downfrom 10 #:above 0
 
100
        #:when (evenp x) #:sum x #:into foo
 
101
        #:else #:sum x #:into bar
 
102
        #:end
 
103
        #:finally (return (values foo bar)))
 
104
  30 25)
 
105
 
 
106
(deftest loop.16.51
 
107
  (loop #:for x #:in '(a b nil c d nil)
 
108
        #:unless x #:count t)
 
109
  2)
 
110
 
 
111
(deftest loop.16.52
 
112
  (loop #:for x #:in '(a b nil c d nil)
 
113
        #:unless x #:collect x #:into bar #:and #:count t #:into foo
 
114
        #:end
 
115
        finally (return (values bar foo)))
 
116
  (nil nil)
 
117
  2)
 
118
 
 
119
(deftest loop.16.53
 
120
  (loop #:for x #:in '(nil nil a b nil c nil)
 
121
        #:collect x
 
122
        #:until x)
 
123
  (nil nil a))
 
124
 
 
125
(deftest loop.16.54
 
126
  (loop #:for x #:in '(a b nil c nil)
 
127
        #:while x #:collect x)
 
128
  (a b))
 
129
 
 
130
(deftest loop.16.55
 
131
  (loop #:for x #:in '(nil nil a b nil c nil)
 
132
        #:thereis x)
 
133
  a)
 
134
 
 
135
(deftest loop.16.56
 
136
  (loop #:for x #:in '(nil nil a b nil c nil)
 
137
        #:never x)
 
138
  nil)
 
139
 
 
140
(deftest loop.16.57
 
141
  (loop #:for x #:in '(a b c d e)
 
142
        #:always x)
 
143
  t)
 
144
 
 
145
(deftest loop.16.58
 
146
  (loop #:as x #:in '(a b c) #:count t)
 
147
  3)
 
148
 
 
149
(deftest loop.16.59
 
150
  (loop #:for i #:from 10 #:downto 5 #:collect i)
 
151
  (10 9 8 7 6 5))
 
152
 
 
153
(deftest loop.16.60
 
154
  (loop #:for i #:from 0 #:upto 5 #:collect i)
 
155
  (0 1 2 3 4 5))
 
156
 
 
157
(deftest loop.16.61
 
158
  (loop #:for x #:on '(a b c) #:collecting (car x))
 
159
  (a b c))
 
160
 
 
161
(deftest loop.16.62
 
162
  (loop #:for x = '(a b c) #:then (cdr x)
 
163
        #:while x
 
164
        #:collect (car x))
 
165
  (a b c))
 
166
 
 
167
(deftest loop.16.63
 
168
  (loop #:for x #:across #(a b c) #:collect x)
 
169
  (a b c))
 
170
 
 
171
(deftest loop.16.64
 
172
  (loop #:for x #:being #:the #:hash-keys #:of (make-hash-table)
 
173
        #:count t)
 
174
  0)
 
175
 
 
176
(deftest loop.16.65
 
177
  (loop #:for x #:being #:each #:hash-key #:in (make-hash-table)
 
178
        #:count t)
 
179
  0)
 
180
 
 
181
(deftest loop.16.66
 
182
  (loop #:for x #:being #:each #:hash-value #:of (make-hash-table)
 
183
        #:count t)
 
184
  0)
 
185
 
 
186
(deftest loop.16.67
 
187
  (loop #:for x #:being #:the #:hash-values #:in (make-hash-table)
 
188
        #:count t)
 
189
  0)
 
190
 
 
191
(deftest loop.16.68
 
192
  (loop #:for x #:being #:the #:hash-values #:in (make-hash-table)
 
193
        #:using (#:hash-key k)
 
194
        #:count t)
 
195
  0)
 
196
 
 
197
(deftest loop.16.69
 
198
  (loop #:for x #:being #:the #:hash-keys #:in (make-hash-table)
 
199
        #:using (#:hash-value v)
 
200
        #:count t)
 
201
  0)
 
202
 
 
203
(deftest loop.16.70
 
204
  (let ()
 
205
    (ignore-errors (delete-package "LOOP.16.PACKAGE"))
 
206
    (let ((p (make-package "LOOP.16.PACKAGE" :use nil)))
 
207
      (loop #:for x #:being #:the #:symbols #:of p #:count t)))
 
208
  0)
 
209
 
 
210
(deftest loop.16.71
 
211
  (let ()
 
212
    (ignore-errors (delete-package "LOOP.16.PACKAGE"))
 
213
    (let ((p (make-package "LOOP.16.PACKAGE" :use nil)))
 
214
      (loop #:for x #:being #:each #:symbol #:of p #:count t)))
 
215
  0)
 
216
 
 
217
(deftest loop.16.72
 
218
  (let ()
 
219
    (ignore-errors (delete-package "LOOP.16.PACKAGE"))
 
220
    (let ((p (make-package "LOOP.16.PACKAGE" :use nil)))
 
221
      (loop #:for x #:being #:the #:external-symbols #:of p #:count t)))
 
222
  0)
 
223
 
 
224
(deftest loop.16.73
 
225
  (let ()
 
226
    (ignore-errors (delete-package "LOOP.16.PACKAGE"))
 
227
    (let ((p (make-package "LOOP.16.PACKAGE" :use nil)))
 
228
      (loop #:for x #:being #:each #:external-symbol #:of p #:count t)))
 
229
  0)
 
230
 
 
231
(deftest loop.16.74
 
232
  (let ()
 
233
    (ignore-errors (delete-package "LOOP.16.PACKAGE"))
 
234
    (let ((p (make-package "LOOP.16.PACKAGE" :use nil)))
 
235
      (loop #:for x #:being #:the #:present-symbols #:of p #:count t)))
 
236
  0)
 
237
 
 
238
(deftest loop.16.75
 
239
  (let ()
 
240
    (ignore-errors (delete-package "LOOP.16.PACKAGE"))
 
241
    (let ((p (make-package "LOOP.16.PACKAGE" :use nil)))
 
242
      (loop #:for x #:being #:each #:present-symbol #:of p #:count t)))
 
243
  0)