2
;;;; Author: Paul Dietz
3
;;;; Created: Sat Aug 24 07:10:05 2002
4
;;;; Contains: Tests for POSITION-IF-NOT-NOT
8
(deftest position-if-not-list.1
9
(position-if-not #'oddp '(1 3 1 4 3 2 1 8 9))
12
(deftest position-if-not-list.2
13
(position-if-not 'oddp '(1 3 1 4 3 2 1 8 9))
16
(deftest position-if-not-list.3
17
(position-if-not #'oddp '(1 3 1 4 3 2 1 8 9) :start 4)
20
(deftest position-if-not-list.4
21
(position-if-not #'oddp '(1 3 1 4 3 2 1 8 9) :from-end t)
24
(deftest position-if-not-list.5
25
(position-if-not #'oddp '(1 3 1 4 3 2 1 8 9) :from-end nil)
28
(deftest position-if-not-list.6
29
(position-if-not #'oddp '(1 3 1 4 3 2 1 8 9) :start 4
33
(deftest position-if-not-list.7
34
(position-if-not #'oddp '(1 3 1 4 3 2 1 8 9) :end nil)
37
(deftest position-if-not-list.8
38
(position-if-not #'oddp '(1 3 1 4 3 2 1 8 9) :end 3)
41
(deftest position-if-not-list.9
42
(loop for i from 0 to 8
44
(loop for j from (1+ i) to 9
46
(position-if-not #'oddp '(1 3 1 4 3 2 1 8 9) :start i :end j)))
47
((nil nil nil 3 3 3 3 3 3)
57
(deftest position-if-not-list.10
58
(loop for i from 0 to 8
60
(loop for j from (1+ i) to 9
62
(position-if-not #'oddp '(1 3 1 4 3 2 1 8 9) :start i :end j
64
((nil nil nil 3 3 5 5 7 7)
74
(deftest position-if-not-list.11
75
(loop for i from 0 to 8
77
(loop for j from (1+ i) to 9
79
(position-if-not #'evenp '(1 3 1 4 3 2 1 8 9) :start i :end j
81
((nil nil nil 3 3 3 3 3 3)
91
(deftest position-if-not-list.12
92
(loop for i from 0 to 8
94
(loop for j from (1+ i) to 9
96
(position-if-not #'evenp '(1 3 1 4 3 2 1 8 9) :start i :end j
97
:key #'1+ :from-end t)))
98
((nil nil nil 3 3 5 5 7 7)
110
(deftest position-if-not-vector.1
111
(position-if-not #'oddp #(1 3 1 4 3 2 1 8 9))
114
(deftest position-if-not-vector.2
115
(position-if-not 'oddp #(1 3 1 4 3 2 1 8 9))
118
(deftest position-if-not-vector.3
119
(position-if-not #'oddp #(1 3 1 4 3 2 1 8 9) :start 4)
122
(deftest position-if-not-vector.4
123
(position-if-not #'oddp #(1 3 1 4 3 2 1 8 9) :from-end t)
126
(deftest position-if-not-vector.5
127
(position-if-not #'oddp #(1 3 1 4 3 2 1 8 9) :from-end nil)
130
(deftest position-if-not-vector.6
131
(position-if-not #'oddp #(1 3 1 4 3 2 1 8 9) :start 4
135
(deftest position-if-not-vector.7
136
(position-if-not #'oddp #(1 3 1 4 3 2 1 8 9) :end nil)
139
(deftest position-if-not-vector.8
140
(position-if-not #'oddp #(1 3 1 4 3 2 1 8 9) :end 3)
143
(deftest position-if-not-vector.9
144
(loop for i from 0 to 8
146
(loop for j from (1+ i) to 9
148
(position-if-not #'oddp #(1 3 1 4 3 2 1 8 9) :start i :end j)))
149
((nil nil nil 3 3 3 3 3 3)
150
(nil nil 3 3 3 3 3 3)
159
(deftest position-if-not-vector.10
160
(loop for i from 0 to 8
162
(loop for j from (1+ i) to 9
164
(position-if-not #'oddp #(1 3 1 4 3 2 1 8 9) :start i :end j
166
((nil nil nil 3 3 5 5 7 7)
167
(nil nil 3 3 5 5 7 7)
176
(deftest position-if-not-vector.11
177
(loop for i from 0 to 8
179
(loop for j from (1+ i) to 9
181
(position-if-not #'evenp #(1 3 1 4 3 2 1 8 9) :start i :end j
183
((nil nil nil 3 3 3 3 3 3)
184
(nil nil 3 3 3 3 3 3)
193
(deftest position-if-not-vector.12
194
(loop for i from 0 to 8
196
(loop for j from (1+ i) to 9
198
(position-if-not #'evenp #(1 3 1 4 3 2 1 8 9) :start i :end j
199
:key #'1+ :from-end t)))
200
((nil nil nil 3 3 5 5 7 7)
201
(nil nil 3 3 5 5 7 7)
210
(deftest position-if-not-vector.13
211
(let ((a (make-array '(10) :initial-contents '(1 2 3 4 5 a b c d e)
214
(position-if-not #'numberp a)
215
(position-if-not #'symbolp a)
216
(position-if-not #'numberp a :from-end t)
217
(position-if-not #'symbolp a :from-end t)))
222
(deftest position-if-not-bit-vector.1
223
(position-if-not #'oddp #*111010101)
226
(deftest position-if-not-bit-vector.2
227
(position-if-not 'oddp #*111010101)
230
(deftest position-if-not-bit-vector.3
231
(position-if-not #'oddp #*111010101 :start 4)
234
(deftest position-if-not-bit-vector.4
235
(position-if-not #'oddp #*111010101 :from-end t)
238
(deftest position-if-not-bit-vector.5
239
(position-if-not #'oddp #*111010101 :from-end nil)
242
(deftest position-if-not-bit-vector.6
243
(position-if-not #'oddp #*111010101 :start 4
247
(deftest position-if-not-bit-vector.7
248
(position-if-not #'oddp #*111010101 :end nil)
251
(deftest position-if-not-bit-vector.8
252
(position-if-not #'oddp #*111010101 :end 3)
255
(deftest position-if-not-bit-vector.9
256
(loop for i from 0 to 8
258
(loop for j from (1+ i) to 9
260
(position-if-not #'oddp #*111010101 :start i :end j)))
261
((nil nil nil 3 3 3 3 3 3)
262
(nil nil 3 3 3 3 3 3)
271
(deftest position-if-not-bit-vector.10
272
(loop for i from 0 to 8
274
(loop for j from (1+ i) to 9
276
(position-if-not #'oddp #*111010101 :start i :end j
278
((nil nil nil 3 3 5 5 7 7)
279
(nil nil 3 3 5 5 7 7)
288
(deftest position-if-not-bit-vector.11
289
(loop for i from 0 to 8
291
(loop for j from (1+ i) to 9
293
(position-if-not #'evenp #*111010101 :start i :end j
295
((nil nil nil 3 3 3 3 3 3)
296
(nil nil 3 3 3 3 3 3)
305
(deftest position-if-not-bit-vector.12
306
(loop for i from 0 to 8
308
(loop for j from (1+ i) to 9
310
(position-if-not #'evenp #*111010101 :start i :end j
311
:key '1+ :from-end t)))
312
((nil nil nil 3 3 5 5 7 7)
313
(nil nil 3 3 5 5 7 7)
322
(deftest position-if-not-bit-vector.13
323
(let ((a (make-array '(10) :initial-contents '(1 1 1 1 1 0 0 0 0 0)
325
:element-type 'bit)))
327
(position-if-not #'zerop a)
328
(position-if-not (complement #'zerop) a)
329
(position-if-not #'zerop a :from-end t)
330
(position-if-not (complement #'zerop) a :from-end t)))
335
(deftest position-if-not-string.1
336
(position-if-not #'odddigitp "131432189")
339
(deftest position-if-not-string.2
340
(position-if-not 'odddigitp "131432189")
343
(deftest position-if-not-string.3
344
(position-if-not #'odddigitp "131432189" :start 4)
347
(deftest position-if-not-string.4
348
(position-if-not #'odddigitp "131432189" :from-end t)
351
(deftest position-if-not-string.5
352
(position-if-not #'odddigitp "131432189" :from-end nil)
355
(deftest position-if-not-string.6
356
(position-if-not #'odddigitp "131432189" :start 4
360
(deftest position-if-not-string.7
361
(position-if-not #'odddigitp "131432189" :end nil)
364
(deftest position-if-not-string.8
365
(position-if-not #'odddigitp "131432189" :end 3)
368
(deftest position-if-not-string.9
369
(loop for i from 0 to 8
371
(loop for j from (1+ i) to 9
373
(position-if-not #'odddigitp "131432189" :start i :end j)))
374
((nil nil nil 3 3 3 3 3 3)
375
(nil nil 3 3 3 3 3 3)
384
(deftest position-if-not-string.10
385
(loop for i from 0 to 8
387
(loop for j from (1+ i) to 9
389
(position-if-not #'odddigitp "131432189" :start i :end j
391
((nil nil nil 3 3 5 5 7 7)
392
(nil nil 3 3 5 5 7 7)
401
(deftest position-if-not-string.11
402
(loop for i from 0 to 8
404
(loop for j from (1+ i) to 9
406
(position-if-not #'evendigitp "131432183" :start i :end j
408
((nil nil nil 3 3 3 3 3 3)
409
(nil nil 3 3 3 3 3 3)
418
(deftest position-if-not-string.12
419
(loop for i from 0 to 8
421
(loop for j from (1+ i) to 9
423
(position-if-not #'evendigitp "131432183" :start i :end j
424
:key 'nextdigit :from-end t)))
425
((nil nil nil 3 3 5 5 7 7)
426
(nil nil 3 3 5 5 7 7)
435
(deftest position-if-not-string.13
436
(let ((a (make-array '(10) :initial-contents "55555aaaaa"
438
:element-type 'character)))
441
(position-if-not #'digit-char-p a)
442
(position-if-not (complement #'digit-char-p) a)
443
(position-if-not #'digit-char-p a :from-end t)
444
(position-if-not (complement #'digit-char-p) a :from-end t))))
447
(deftest position-if-not.order.1
448
(let ((i 0) a b c d e f)
451
(progn (setf a (incf i)) (complement #'zerop))
452
(progn (setf b (incf i)) '(3 1 8 2 1 2 3 4))
453
:from-end (setf c (incf i))
454
:start (progn (setf d (incf i)) 1)
455
:end (progn (setf e (incf i)) 6)
456
:key (progn (setf f (incf i)) #'1-))
460
(deftest position-if-not.order.2
461
(let ((i 0) a b c d e f)
464
(progn (setf a (incf i)) (complement #'zerop))
465
(progn (setf b (incf i)) '(3 1 8 2 1 2 3 4))
466
:key (progn (setf c (incf i)) #'1-)
467
:end (progn (setf d (incf i)) 6)
468
:start (progn (setf e (incf i)) 1)
469
:from-end (setf f (incf i)))
475
(deftest position-if-not.allow-other-keys.1
476
(position-if-not #'zerop '(0 0 3 2 0 1) :allow-other-keys t)
479
(deftest position-if-not.allow-other-keys.2
480
(position-if-not #'zerop '(0 0 3 2 0 1) :allow-other-keys nil)
483
(deftest position-if-not.allow-other-keys.3
484
(position-if-not #'zerop '(0 0 1 2 3 0) :allow-other-keys t :bad t)
487
(deftest position-if-not.allow-other-keys.4
488
(position-if-not #'zerop '(0 0 1 2 3 0) :bad t :allow-other-keys t)
491
(deftest position-if-not.allow-other-keys.5
492
(position-if-not #'zerop '(0 0 1 2 3 0) :bad t :allow-other-keys t :key #'1-)
495
(deftest position-if-not.keywords.6
496
(position-if-not #'zerop '(0 0 1 2 3 0) :key #'1- :key #'identity)
499
(deftest position-if-not.allow-other-keys.7
500
(position-if-not #'zerop '(0 0 1 2 3 0) :bad t :allow-other-keys t
501
:allow-other-keys nil)
504
(deftest position-if-not.allow-other-keys.8
505
(position-if-not #'zerop '(0 0 1 2 3 0) :allow-other-keys t :bad t
506
:allow-other-keys nil)
509
(deftest position-if-not.allow-other-keys.9
510
(position-if-not #'zerop '(0 0 1 2 3 0) :allow-other-keys t
511
:allow-other-keys nil :bad t)
517
(deftest position-if-not.error.1
518
(signals-error (position-if-not #'identity 'b) type-error)
521
(deftest position-if-not.error.2
522
(signals-error (position-if-not #'identity 10) type-error)
525
(deftest position-if-not.error.3
526
(signals-error (position-if-not 'null 1.4) type-error)
529
(deftest position-if-not.error.4
530
(signals-error (position-if-not 'identity '(a b c . d)) type-error)
533
(deftest position-if-not.error.5
534
(signals-error (position-if-not) program-error)
537
(deftest position-if-not.error.6
538
(signals-error (position-if-not #'null) program-error)
541
(deftest position-if-not.error.7
542
(signals-error (position-if-not #'null nil :key) program-error)
545
(deftest position-if-not.error.8
546
(signals-error (position-if-not #'null nil 'bad t) program-error)
549
(deftest position-if-not.error.9
550
(signals-error (position-if-not #'null nil 'bad t :allow-other-keys nil) program-error)
553
(deftest position-if-not.error.10
554
(signals-error (position-if-not #'null nil 1 2) program-error)
557
(deftest position-if-not.error.11
558
(signals-error (locally (position-if-not #'identity 'b) t) type-error)
561
(deftest position-if-not.error.12
562
(signals-error (position-if-not #'cons '(a b c d)) program-error)
565
(deftest position-if-not.error.13
566
(signals-error (position-if-not #'car '(a b c d)) type-error)
569
(deftest position-if-not.error.14
570
(signals-error (position-if-not #'identity '(a b c d) :key #'cdr) type-error)
573
(deftest position-if-not.error.15
574
(signals-error (position-if-not #'identity '(a b c d) :key #'cons) program-error)