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

« back to all changes in this revision

Viewing changes to ansi-tests/find-if.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:  Wed Aug 28 18:37:52 2002
 
4
;;;; Contains: Tests for FIND-IF
 
5
 
 
6
(in-package :cl-test)
 
7
 
 
8
(deftest find-if-list.1
 
9
  (find-if #'identity ())
 
10
  nil)
 
11
 
 
12
(deftest find-if-list.2
 
13
  (find-if #'identity '(a))
 
14
  a)
 
15
 
 
16
(deftest find-if-list.2a
 
17
  (find-if 'identity '(a))
 
18
  a)
 
19
 
 
20
(deftest find-if-list.3
 
21
  (find-if #'evenp '(1 2 4 8 3 1 6 7))
 
22
  2)
 
23
 
 
24
(deftest find-if-list.4
 
25
  (find-if #'evenp '(1 2 4 8 3 1 6 7) :from-end t)
 
26
  6)
 
27
 
 
28
(deftest find-if-list.5
 
29
  (loop for i from 0 to 7 collect
 
30
        (find-if #'evenp '(1 2 4 8 3 1 6 7) :start i))
 
31
  (2 2 4 8 6 6 6 nil))
 
32
 
 
33
(deftest find-if-list.6
 
34
  (loop for i from 0 to 7 collect
 
35
        (find-if #'evenp '(1 2 4 8 3 1 6 7) :start i :end nil))
 
36
  (2 2 4 8 6 6 6 nil))
 
37
 
 
38
(deftest find-if-list.7
 
39
  (loop for i from 0 to 7 collect
 
40
        (find-if #'evenp '(1 2 4 8 3 1 6 7) :start i :from-end t))
 
41
  (6 6 6 6 6 6 6 nil))
 
42
 
 
43
(deftest find-if-list.8
 
44
  (loop for i from 0 to 7 collect
 
45
        (find-if #'evenp '(1 2 4 8 3 1 6 7) :start i :end nil :from-end t))
 
46
  (6 6 6 6 6 6 6 nil))
 
47
 
 
48
(deftest find-if-list.9
 
49
  (loop for i from 0 to 8 collect
 
50
        (find-if #'evenp '(1 2 4 8 3 1 6 7) :end i))
 
51
  (nil nil 2 2 2 2 2 2 2))
 
52
 
 
53
(deftest find-if-list.10
 
54
  (loop for i from 0 to 8 collect
 
55
        (find-if #'evenp '(1 2 4 8 3 1 6 7) :end i :from-end t))
 
56
  (nil nil 2 4 8 8 8 6 6))
 
57
 
 
58
(deftest find-if-list.11
 
59
  (loop for j from 0 to 7
 
60
        collect
 
61
        (loop for i from (1+ j) to 8 collect
 
62
              (find-if #'evenp '(1 2 4 8 3 1 6 7) :start j :end i)))
 
63
  ((nil 2 2 2 2 2 2 2)
 
64
   (2 2 2 2 2 2 2)
 
65
   (4 4 4 4 4 4)
 
66
   (8 8 8 8 8)
 
67
   (nil nil 6 6)
 
68
   (nil 6 6)
 
69
   (6 6)
 
70
   (nil)))
 
71
 
 
72
(deftest find-if-list.12
 
73
  (loop for j from 0 to 7
 
74
        collect
 
75
        (loop for i from (1+ j) to 8 collect
 
76
              (find-if #'evenp '(1 2 4 8 3 1 6 7) :start j :end i
 
77
                       :from-end t)))
 
78
  ((nil 2 4 8 8 8 6 6)
 
79
   (2 4 8 8 8 6 6)
 
80
   (4 8 8 8 6 6)
 
81
   (8 8 8 6 6)
 
82
   (nil nil 6 6)
 
83
   (nil 6 6)
 
84
   (6 6)
 
85
   (nil)))
 
86
 
 
87
(deftest find-if-list.13
 
88
  (loop for i from 0 to 6
 
89
        collect
 
90
        (find-if #'evenp '(1 6 11 32 45 71 100) :key #'1+ :start i))
 
91
  (1 11 11 45 45 71 nil))
 
92
 
 
93
(deftest find-if-list.14
 
94
  (loop for i from 0 to 6
 
95
        collect
 
96
        (find-if #'evenp '(1 6 11 32 45 71 100) :key '1+ :start i :from-end t))
 
97
  (71 71 71 71 71 71 nil))
 
98
 
 
99
(deftest find-if-list.15
 
100
  (loop for i from 0 to 7
 
101
        collect
 
102
        (find-if #'evenp '(1 6 11 32 45 71 100) :key #'1+ :end i))
 
103
  (nil 1 1 1 1 1 1 1))
 
104
 
 
105
(deftest find-if-list.16
 
106
  (loop for i from 0 to 7
 
107
        collect
 
108
        (find-if #'evenp '(1 6 11 32 45 71 100) :key '1+ :end i :from-end t))
 
109
  (nil 1 1 11 11 45 71 71))
 
110
 
 
111
(deftest find-if-list.17
 
112
  (loop for j from 0 to 7
 
113
        collect
 
114
        (loop for i from (1+ j) to 8 collect
 
115
              (find-if #'oddp '(1 2 4 8 3 1 6 7) :start j :end i :key #'1-)))
 
116
  ((nil 2 2 2 2 2 2 2)
 
117
   (2 2 2 2 2 2 2)
 
118
   (4 4 4 4 4 4)
 
119
   (8 8 8 8 8)
 
120
   (nil nil 6 6)
 
121
   (nil 6 6)
 
122
   (6 6)
 
123
   (nil)))
 
124
 
 
125
(deftest find-if-list.18
 
126
  (loop for j from 0 to 7
 
127
        collect
 
128
        (loop for i from (1+ j) to 8 collect
 
129
              (find-if #'oddp '(1 2 4 8 3 1 6 7) :start j :end i
 
130
                       :from-end t :key #'1+)))
 
131
  ((nil 2 4 8 8 8 6 6)
 
132
   (2 4 8 8 8 6 6)
 
133
   (4 8 8 8 6 6)
 
134
   (8 8 8 6 6)
 
135
   (nil nil 6 6)
 
136
   (nil 6 6)
 
137
   (6 6)
 
138
   (nil)))
 
139
 
 
140
;;; tests for vectors
 
141
 
 
142
(deftest find-if-vector.1
 
143
  (find-if #'identity #())
 
144
  nil)
 
145
 
 
146
(deftest find-if-vector.2
 
147
  (find-if #'identity #(a))
 
148
  a)
 
149
 
 
150
(deftest find-if-vector.2a
 
151
  (find-if 'identity #(a))
 
152
  a)
 
153
 
 
154
(deftest find-if-vector.3
 
155
  (find-if #'evenp #(1 2 4 8 3 1 6 7))
 
156
  2)
 
157
 
 
158
(deftest find-if-vector.4
 
159
  (find-if #'evenp #(1 2 4 8 3 1 6 7) :from-end t)
 
160
  6)
 
161
 
 
162
(deftest find-if-vector.5
 
163
  (loop for i from 0 to 7 collect
 
164
        (find-if #'evenp #(1 2 4 8 3 1 6 7) :start i))
 
165
  (2 2 4 8 6 6 6 nil))
 
166
 
 
167
(deftest find-if-vector.6
 
168
  (loop for i from 0 to 7 collect
 
169
        (find-if #'evenp #(1 2 4 8 3 1 6 7) :start i :end nil))
 
170
  (2 2 4 8 6 6 6 nil))
 
171
 
 
172
(deftest find-if-vector.7
 
173
  (loop for i from 0 to 7 collect
 
174
        (find-if #'evenp #(1 2 4 8 3 1 6 7) :start i :from-end t))
 
175
  (6 6 6 6 6 6 6 nil))
 
176
 
 
177
(deftest find-if-vector.8
 
178
  (loop for i from 0 to 7 collect
 
179
        (find-if #'evenp #(1 2 4 8 3 1 6 7) :start i :end nil :from-end t))
 
180
  (6 6 6 6 6 6 6 nil))
 
181
 
 
182
(deftest find-if-vector.9
 
183
  (loop for i from 0 to 8 collect
 
184
        (find-if #'evenp #(1 2 4 8 3 1 6 7) :end i))
 
185
  (nil nil 2 2 2 2 2 2 2))
 
186
 
 
187
(deftest find-if-vector.10
 
188
  (loop for i from 0 to 8 collect
 
189
        (find-if #'evenp #(1 2 4 8 3 1 6 7) :end i :from-end t))
 
190
  (nil nil 2 4 8 8 8 6 6))
 
191
 
 
192
(deftest find-if-vector.11
 
193
  (loop for j from 0 to 7
 
194
        collect
 
195
        (loop for i from (1+ j) to 8 collect
 
196
              (find-if #'evenp #(1 2 4 8 3 1 6 7) :start j :end i)))
 
197
  ((nil 2 2 2 2 2 2 2)
 
198
   (2 2 2 2 2 2 2)
 
199
   (4 4 4 4 4 4)
 
200
   (8 8 8 8 8)
 
201
   (nil nil 6 6)
 
202
   (nil 6 6)
 
203
   (6 6)
 
204
   (nil)))
 
205
 
 
206
(deftest find-if-vector.12
 
207
  (loop for j from 0 to 7
 
208
        collect
 
209
        (loop for i from (1+ j) to 8 collect
 
210
              (find-if #'evenp #(1 2 4 8 3 1 6 7) :start j :end i
 
211
                       :from-end t)))
 
212
  ((nil 2 4 8 8 8 6 6)
 
213
   (2 4 8 8 8 6 6)
 
214
   (4 8 8 8 6 6)
 
215
   (8 8 8 6 6)
 
216
   (nil nil 6 6)
 
217
   (nil 6 6)
 
218
   (6 6)
 
219
   (nil)))
 
220
 
 
221
(deftest find-if-vector.13
 
222
  (loop for i from 0 to 6
 
223
        collect
 
224
        (find-if #'evenp #(1 6 11 32 45 71 100) :key #'1+ :start i))
 
225
  (1 11 11 45 45 71 nil))
 
226
 
 
227
(deftest find-if-vector.14
 
228
  (loop for i from 0 to 6
 
229
        collect
 
230
        (find-if #'evenp #(1 6 11 32 45 71 100) :key '1+ :start i :from-end t))
 
231
  (71 71 71 71 71 71 nil))
 
232
 
 
233
(deftest find-if-vector.15
 
234
  (loop for i from 0 to 7
 
235
        collect
 
236
        (find-if #'evenp #(1 6 11 32 45 71 100) :key #'1+ :end i))
 
237
  (nil 1 1 1 1 1 1 1))
 
238
 
 
239
(deftest find-if-vector.16
 
240
  (loop for i from 0 to 7
 
241
        collect
 
242
        (find-if #'evenp #(1 6 11 32 45 71 100) :key '1+ :end i :from-end t))
 
243
  (nil 1 1 11 11 45 71 71))
 
244
 
 
245
(deftest find-if-vector.17
 
246
  (loop for j from 0 to 7
 
247
        collect
 
248
        (loop for i from (1+ j) to 8 collect
 
249
              (find-if #'oddp #(1 2 4 8 3 1 6 7) :start j :end i :key #'1-)))
 
250
  ((nil 2 2 2 2 2 2 2)
 
251
   (2 2 2 2 2 2 2)
 
252
   (4 4 4 4 4 4)
 
253
   (8 8 8 8 8)
 
254
   (nil nil 6 6)
 
255
   (nil 6 6)
 
256
   (6 6)
 
257
   (nil)))
 
258
 
 
259
(deftest find-if-vector.18
 
260
  (loop for j from 0 to 7
 
261
        collect
 
262
        (loop for i from (1+ j) to 8 collect
 
263
              (find-if #'oddp #(1 2 4 8 3 1 6 7) :start j :end i
 
264
                       :from-end t :key #'1+)))
 
265
  ((nil 2 4 8 8 8 6 6)
 
266
   (2 4 8 8 8 6 6)
 
267
   (4 8 8 8 6 6)
 
268
   (8 8 8 6 6)
 
269
   (nil nil 6 6)
 
270
   (nil 6 6)
 
271
   (6 6)
 
272
   (nil)))
 
273
 
 
274
(deftest find-if-vector.19
 
275
  (let ((a (make-array '(10) :initial-contents '(1 2 3 4 5 6 7 8 9 10)
 
276
                       :fill-pointer 5)))
 
277
    (values
 
278
     (find-if #'evenp a)
 
279
     (find-if #'evenp a :from-end t)
 
280
     (find-if #'oddp a)
 
281
     (find-if #'oddp a :from-end t)
 
282
     ))
 
283
  2 4 1 5)
 
284
 
 
285
;;; Tests for bit vectors
 
286
 
 
287
(deftest find-if-bit-vector.1
 
288
  (find-if #'identity #*)
 
289
  nil)
 
290
 
 
291
(deftest find-if-bit-vector.2
 
292
  (find-if #'identity #*1)
 
293
  1)
 
294
 
 
295
(deftest find-if-bit-vector.3
 
296
  (find-if #'identity #*0)
 
297
  0)
 
298
 
 
299
(deftest find-if-bit-vector.4
 
300
  (loop for i from 0 to 6
 
301
        collect (loop for j from i to 7
 
302
                      collect (find-if #'evenp #*0110110 :start i :end j)))
 
303
  ((nil 0 0 0 0 0 0 0)
 
304
   (nil nil nil 0 0 0 0)
 
305
   (nil nil 0 0 0 0)
 
306
   (nil 0 0 0 0)
 
307
   (nil nil nil 0)
 
308
   (nil nil 0)
 
309
   (nil 0)))
 
310
 
 
311
(deftest find-if-bit-vector.5
 
312
  (loop for i from 0 to 6
 
313
        collect (loop for j from i to 7
 
314
                      collect (find-if #'evenp #*0110110 :start i :end j
 
315
                                       :from-end t)))
 
316
  ((nil 0 0 0 0 0 0 0)
 
317
   (nil nil nil 0 0 0 0)
 
318
   (nil nil 0 0 0 0)
 
319
   (nil 0 0 0 0)
 
320
   (nil nil nil 0)
 
321
   (nil nil 0)
 
322
   (nil 0)))
 
323
 
 
324
(deftest find-if-bit-vector.6
 
325
  (loop for i from 0 to 6
 
326
        collect (loop for j from i to 7
 
327
                      collect (find-if #'oddp #*0110110 :start i :end j
 
328
                                       :from-end t :key #'1+)))
 
329
  ((nil 0 0 0 0 0 0 0)
 
330
   (nil nil nil 0 0 0 0)
 
331
   (nil nil 0 0 0 0)
 
332
   (nil 0 0 0 0)
 
333
   (nil nil nil 0)
 
334
   (nil nil 0)
 
335
   (nil 0)))
 
336
 
 
337
(deftest find-if-bit-vector.7
 
338
  (loop for i from 0 to 6
 
339
        collect (loop for j from i to 7
 
340
                      collect (find-if #'oddp #*0110110 :start i :end j
 
341
                                       :key '1-)))
 
342
  ((nil 0 0 0 0 0 0 0)
 
343
   (nil nil nil 0 0 0 0)
 
344
   (nil nil 0 0 0 0)
 
345
   (nil 0 0 0 0)
 
346
   (nil nil nil 0)
 
347
   (nil nil 0)
 
348
   (nil 0)))
 
349
 
 
350
;;; Tests for strings
 
351
 
 
352
(deftest find-if-string.1
 
353
  (find-if #'identity "")
 
354
  nil)
 
355
 
 
356
(deftest find-if-string.2
 
357
  (find-if #'identity "a")
 
358
  #\a)
 
359
 
 
360
(deftest find-if-string.2a
 
361
  (find-if 'identity "a")
 
362
  #\a)
 
363
 
 
364
(deftest find-if-string.3
 
365
  (find-if #'evendigitp "12483167")
 
366
  #\2)
 
367
  
 
368
(deftest find-if-string.3a
 
369
  (find-if #'evenp "12483167" :key #'(lambda (c) (read-from-string (string c))))
 
370
  #\2)
 
371
 
 
372
(deftest find-if-string.4
 
373
  (find-if #'evendigitp "12483167" :from-end t)
 
374
  #\6)
 
375
 
 
376
(deftest find-if-string.5
 
377
  (loop for i from 0 to 7 collect
 
378
        (find-if #'evendigitp "12483167" :start i))
 
379
  (#\2 #\2 #\4 #\8 #\6 #\6 #\6 nil))
 
380
 
 
381
(deftest find-if-string.6
 
382
  (loop for i from 0 to 7 collect
 
383
        (find-if #'evendigitp "12483167" :start i :end nil))
 
384
  (#\2 #\2 #\4 #\8 #\6 #\6 #\6 nil))
 
385
 
 
386
(deftest find-if-string.7
 
387
  (loop for i from 0 to 7 collect
 
388
        (find-if #'evendigitp "12483167" :start i :from-end t))
 
389
  (#\6 #\6 #\6 #\6 #\6 #\6 #\6 nil))
 
390
 
 
391
(deftest find-if-string.8
 
392
  (loop for i from 0 to 7 collect
 
393
        (find-if #'evendigitp "12483167" :start i :end nil :from-end t))
 
394
  (#\6 #\6 #\6 #\6 #\6 #\6 #\6 nil))
 
395
 
 
396
(deftest find-if-string.9
 
397
  (loop for i from 0 to 8 collect
 
398
        (find-if #'evendigitp "12483167" :end i))
 
399
  (nil nil #\2 #\2 #\2 #\2 #\2 #\2 #\2))
 
400
 
 
401
(deftest find-if-string.10
 
402
  (loop for i from 0 to 8 collect
 
403
        (find-if #'evendigitp "12483167" :end i :from-end t))
 
404
  (nil nil #\2 #\4 #\8 #\8 #\8 #\6 #\6))
 
405
 
 
406
(deftest find-if-string.11
 
407
  (loop for j from 0 to 7
 
408
        collect
 
409
        (loop for i from (1+ j) to 8 collect
 
410
              (find-if #'evendigitp "12483167" :start j :end i)))
 
411
  ((nil #\2 #\2 #\2 #\2 #\2 #\2 #\2)
 
412
   (#\2 #\2 #\2 #\2 #\2 #\2 #\2)
 
413
   (#\4 #\4 #\4 #\4 #\4 #\4)
 
414
   (#\8 #\8 #\8 #\8 #\8)
 
415
   (nil nil #\6 #\6)
 
416
   (nil #\6 #\6)
 
417
   (#\6 #\6)
 
418
   (nil)))
 
419
 
 
420
(deftest find-if-string.12
 
421
  (loop for j from 0 to 7
 
422
        collect
 
423
        (loop for i from (1+ j) to 8 collect
 
424
              (find-if #'evendigitp "12483167" :start j :end i
 
425
                       :from-end t)))
 
426
  ((nil #\2 #\4 #\8 #\8 #\8 #\6 #\6)
 
427
   (#\2 #\4 #\8 #\8 #\8 #\6 #\6)
 
428
   (#\4 #\8 #\8 #\8 #\6 #\6)
 
429
   (#\8 #\8 #\8 #\6 #\6)
 
430
   (nil nil #\6 #\6)
 
431
   (nil #\6 #\6)
 
432
   (#\6 #\6)
 
433
   (nil)))
 
434
 
 
435
(deftest find-if-string.13
 
436
  (loop for i from 0 to 6
 
437
        collect
 
438
        (find-if #'evenp "1473816"
 
439
                 :key (compose #'read-from-string #'string)
 
440
                 :start i))
 
441
  (#\4 #\4 #\8 #\8 #\8 #\6 #\6))
 
442
 
 
443
(deftest find-if-string.14
 
444
  (loop for i from 0 to 6
 
445
        collect
 
446
        (find-if #'evenp "1473816"
 
447
                 :key (compose #'read-from-string #'string)
 
448
                 :start i :from-end t))
 
449
  (#\6 #\6 #\6 #\6 #\6 #\6 #\6))
 
450
 
 
451
(deftest find-if-string.15
 
452
  (loop for i from 0 to 7
 
453
        collect
 
454
        (find-if #'evenp "1473816"
 
455
                 :key (compose #'read-from-string #'string)
 
456
                 :end i))
 
457
  (nil nil #\4 #\4 #\4 #\4 #\4 #\4))
 
458
 
 
459
(deftest find-if-string.16
 
460
  (loop for i from 0 to 7
 
461
        collect
 
462
        (find-if #'evenp "1473816"
 
463
                 :key (compose #'read-from-string #'string)
 
464
                 :end i :from-end t))
 
465
  (nil nil #\4 #\4 #\4 #\8 #\8 #\6))
 
466
 
 
467
(deftest find-if-string.17
 
468
  (loop for j from 0 to 6
 
469
        collect
 
470
        (loop for i from (1+ j) to 7 collect
 
471
              (find-if #'evenp "1473816"
 
472
                 :key (compose #'read-from-string #'string)
 
473
                 :start j :end i)))
 
474
  ((nil #\4 #\4 #\4 #\4 #\4 #\4)
 
475
   (#\4 #\4 #\4 #\4 #\4 #\4)
 
476
   (nil nil #\8 #\8 #\8)
 
477
   (nil #\8 #\8 #\8)
 
478
   (#\8 #\8 #\8)
 
479
   (nil #\6)
 
480
   (#\6)))  
 
481
 
 
482
(deftest find-if-string.18
 
483
  (loop for j from 0 to 6
 
484
        collect
 
485
        (loop for i from (1+ j) to 7 collect
 
486
              (find-if #'evenp "1473816"
 
487
                 :key (compose #'read-from-string #'string)
 
488
                 :start j :end i
 
489
                 :from-end t)))
 
490
  ((nil #\4 #\4 #\4 #\8 #\8 #\6)
 
491
   (#\4 #\4 #\4 #\8 #\8 #\6)
 
492
   (nil nil #\8 #\8 #\6)
 
493
   (nil #\8 #\8 #\6)
 
494
   (#\8 #\8 #\6)
 
495
   (nil #\6)
 
496
   (#\6)))
 
497
 
 
498
(deftest find-if-string.19
 
499
  (let ((a (make-array '(10) :initial-contents "123456789a"
 
500
                       :fill-pointer 5
 
501
                       :element-type 'character)))
 
502
    (values
 
503
     (find-if #'evendigitp a)
 
504
     (find-if #'evendigitp a :from-end t)
 
505
     (find-if #'odddigitp a)
 
506
     (find-if #'odddigitp a :from-end t)
 
507
     ))
 
508
  #\2 #\4 #\1 #\5)
 
509
 
 
510
;;; Keyword tests
 
511
 
 
512
(deftest find-if.allow-other-keys.1
 
513
  (find-if #'evenp '(1 2 3 4 5) :bad t :allow-other-keys t)
 
514
  2)
 
515
 
 
516
(deftest find-if.allow-other-keys.2
 
517
  (find-if #'evenp '(1 2 3 4 5) :allow-other-keys t :also-bad t)
 
518
  2)
 
519
 
 
520
;;; The leftmost of two :allow-other-keys arguments is the one that  matters.
 
521
(deftest find-if.allow-other-keys.3
 
522
  (find-if #'evenp '(1 2 3 4 5)
 
523
            :allow-other-keys t
 
524
            :allow-other-keys nil
 
525
            :bad t)
 
526
  2)
 
527
 
 
528
(deftest find-if.keywords.4
 
529
  (find-if #'evenp '(1 2 3 4 5) :key #'identity :key #'1+)
 
530
  2)
 
531
 
 
532
(deftest find-if.allow-other-keys.5
 
533
  (find-if #'identity '(nil a b c nil) :allow-other-keys nil)
 
534
  a)
 
535
 
 
536
 
 
537
;;; Error tests
 
538
 
 
539
(deftest find-if.error.1
 
540
  (signals-error (find-if #'null 'b) type-error)
 
541
  t)
 
542
 
 
543
(deftest find-if.error.2
 
544
  (signals-error (find-if #'identity 10) type-error)
 
545
  t)
 
546
 
 
547
(deftest find-if.error.3
 
548
  (signals-error (find-if '1+ 1.4) type-error)
 
549
  t)
 
550
 
 
551
(deftest find-if.error.4
 
552
  (signals-error (find-if 'null '(a b c . d)) type-error)
 
553
  t)
 
554
 
 
555
(deftest find-if.error.5
 
556
  (signals-error (find-if) program-error)
 
557
  t)
 
558
 
 
559
(deftest find-if.error.6
 
560
  (signals-error (find-if #'null) program-error)
 
561
  t)
 
562
 
 
563
(deftest find-if.error.7
 
564
  (signals-error (find-if #'null nil :bad t) program-error)
 
565
  t)
 
566
 
 
567
(deftest find-if.error.8
 
568
  (signals-error (find-if #'null nil :bad t :allow-other-keys nil)
 
569
                 program-error)
 
570
  t)
 
571
 
 
572
(deftest find-if.error.9
 
573
  (signals-error (find-if #'null nil 1 1) program-error)
 
574
  t)
 
575
 
 
576
(deftest find-if.error.10
 
577
  (signals-error (find-if #'null nil :key) program-error)
 
578
  t)
 
579
 
 
580
(deftest find-if.error.11
 
581
  (signals-error (locally (find-if #'null 'b) t) type-error)
 
582
  t)
 
583
 
 
584
(deftest find-if.error.12
 
585
  (signals-error (find-if #'cons '(a b c)) program-error)
 
586
  t)
 
587
 
 
588
(deftest find-if.error.13
 
589
  (signals-error (find-if #'car '(a b c)) type-error)
 
590
  t)
 
591
 
 
592
(deftest find-if.error.14
 
593
  (signals-error (find-if #'identity '(a b c) :key #'cons) program-error)
 
594
  t)
 
595
 
 
596
(deftest find-if.error.15
 
597
  (signals-error (find-if #'identity '(a b c) :key #'car)
 
598
                 type-error)
 
599
  t)
 
600
 
 
601
;;; Order of evaluation tests
 
602
 
 
603
(deftest find-if.order.1
 
604
  (let ((i 0) x y)
 
605
    (values
 
606
     (find-if (progn (setf x (incf i)) #'identity)
 
607
              (progn (setf y (incf i)) '(nil nil nil a nil nil)))
 
608
     i x y))
 
609
  a 2 1 2)
 
610
 
 
611
(deftest find-if.order.2
 
612
  (let ((i 0) a b c d e f g)
 
613
    (values
 
614
     (find-if (progn (setf a (incf i)) #'null)
 
615
              (progn (setf b (incf i)) '(nil nil nil a nil nil))
 
616
              :start (progn (setf c (incf i)) 1)
 
617
              :end   (progn (setf d (incf i)) 4)
 
618
              :from-end (setf e (incf i))
 
619
              :key   (progn (setf f (incf i)) #'null)
 
620
              )
 
621
     i a b c d e f))
 
622
  a 6 1 2 3 4 5 6)
 
623
 
 
624
 
 
625
(deftest find-if.order.3
 
626
  (let ((i 0) a b c d e f g)
 
627
    (values
 
628
     (find-if (progn (setf a (incf i)) #'null)
 
629
              (progn (setf b (incf i)) '(nil nil nil a nil nil))
 
630
              :key   (progn (setf c (incf i)) #'null)
 
631
              :from-end (setf d (incf i))
 
632
              :end   (progn (setf e (incf i)) 4)
 
633
              :start (progn (setf f (incf i)) 1)
 
634
              )
 
635
     i a b c d e f))
 
636
  a 6 1 2 3 4 5 6)