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

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

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

File size: 19.6 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Fri Aug 23 07:49:49 2002
4;;;; Contains: Tests for POSITION
5
6(in-package :cl-test)
7
8(deftest position-list.1
9  (position 'c '(a b c d e c a))
10  2)
11
12(deftest position-list.2
13  (position 'c '(a b c d e c a) :from-end t)
14  5)
15
16(deftest position-list.3
17  (loop for i from 0 to 7 collect
18        (position 'c '(a b c d e c a) :start i))
19  (2 2 2 5 5 5 nil nil))
20
21(deftest position-list.4
22  (loop for i from 0 to 7 collect
23        (position 'c '(a b c d e c a) :start i :end nil))
24  (2 2 2 5 5 5 nil nil))
25
26(deftest position-list.5
27  (loop for i from 7 downto 0 collect
28        (position 'c '(a b c d e c a) :end i))
29  (2 2 2 2 2 nil nil nil))
30
31(deftest position-list.6
32  (loop for i from 0 to 7 collect
33        (position 'c '(a b c d e c a) :start i :from-end t))
34  (5 5 5 5 5 5 nil nil))
35
36(deftest position-list.7
37  (loop for i from 0 to 7 collect
38        (position 'c '(a b c d e c a) :start i :end nil :from-end t))
39  (5 5 5 5 5 5 nil nil))
40
41(deftest position-list.8
42  (loop for i from 7 downto 0 collect
43        (position 'c '(a b c d e c a) :end i :from-end t))
44  (5 5 2 2 2 nil nil nil))
45
46(deftest position-list.9
47  (loop for i from 0 to 6 collect
48        (loop for j from (1+ i) to 7
49              collect
50              (position 'c '(a b c d e c a) :start i :end j)))
51  ((nil nil 2 2 2 2 2)
52   (nil 2 2 2 2 2)
53   (2 2 2 2 2)
54   (nil nil 5 5)
55   (nil 5 5)
56   (5 5)
57   (nil)))
58
59(deftest position-list.10
60  (loop for i from 0 to 6 collect
61        (loop for j from (1+ i) to 7
62              collect
63              (position 'c '(a b c d e c a) :start i :end j :from-end t)))
64  ((nil nil 2 2 2 5 5)
65   (nil 2 2 2 5 5)
66   (2 2 2 5 5)
67   (nil nil 5 5)
68   (nil 5 5)
69   (5 5)
70   (nil)))
71
72(deftest position-list.11
73  (position 5 '(1 2 3 4 5 6 4 8) :key #'1+)
74  3)
75
76(deftest position-list.12
77  (position 5 '(1 2 3 4 5 6 4 8) :key '1+)
78  3)
79
80(deftest position-list.13
81  (position 5 '(1 2 3 4 5 6 4 8) :key #'1+ :from-end t)
82  6)
83
84(deftest position-list.14
85  (position 'a '(a a b a c e d a f a) :test (complement #'eql))
86  2)
87
88(deftest position-list.15
89  (position 'a '(a a b a c e d a f a) :test (complement #'eql)
90            :from-end t)
91  8)
92
93(deftest position-list.16
94  (position 'a '(a a b a c e d a f a) :test-not #'eql)
95  2)
96
97(deftest position-list.17
98  (position 'a '(a a b a c e d a f a) :test-not 'eql
99            :from-end t)
100  8)
101
102(deftest position-list.18
103  (position 'a '(a a b a c e d a f a) :test-not 'eql)
104  2)
105
106(deftest position-list.19
107  (position 'a '(a a b a c e d a f a) :test-not #'eql
108            :from-end t)
109  8)
110
111(deftest position-list.20
112  (position 'a '(a a b a c e d a f a) :test-not #'eql)
113  2)
114
115(deftest position-list.21
116  (position 'a '(a a b a c e d a f a) :test #'eql
117            :start 2)
118  3)
119
120(deftest position-list.22
121  (position 'a '(a a b a c e d a f a) :test #'eql
122            :start 2 :end nil)
123  3)
124
125(deftest position-list.23
126  (position 'a '(a a b a c e d a f a) :test-not #'eql
127            :start 0 :end 5)
128  2)
129
130(deftest position-list.24
131  (position 'a '(a a b a c e d a f a) :test-not #'eql
132            :start 0 :end 5 :from-end t)
133  4)
134
135(deftest position-list.25
136  (position '(a b) '(a (b a) (a b c) (a b) (d e) f) :test #'equal)
137  3)
138
139(deftest position-list.26
140  (position 'a '((c) (b a) (a b c) (a b) (d e) f) :key #'car)
141  2)
142
143(deftest position-list.27
144  (position 'a '((c) (b a) (a b c) (z) (a b) (d e) f) :key #'car
145            :start 3)
146  4)
147
148(deftest position-list.28
149  (position 'a '((c) (b a) (a b c) (z) (a b) (d e) (f)) :key #'car
150            :start 2 :from-end t)
151  4)
152
153(deftest position-list.29
154  (position 10 '(1 4 8 10 15 20) :test #'<)
155  4)
156
157(deftest position-list.30
158  (position 10 '(1 4 8 10 15 20) :test-not #'>=)
159  4)
160
161;;; Tests on vectors
162
163(deftest position-vector.1
164  (position 'c #(a b c d e c a))
165  2)
166
167(deftest position-vector.2
168  (position 'c #(a b c d e c a) :from-end t)
169  5)
170
171(deftest position-vector.3
172  (loop for i from 0 to 7 collect
173        (position 'c #(a b c d e c a) :start i))
174  (2 2 2 5 5 5 nil nil))
175
176(deftest position-vector.4
177  (loop for i from 0 to 7 collect
178        (position 'c #(a b c d e c a) :start i :end nil))
179  (2 2 2 5 5 5 nil nil))
180
181(deftest position-vector.5
182  (loop for i from 7 downto 0 collect
183        (position 'c #(a b c d e c a) :end i))
184  (2 2 2 2 2 nil nil nil))
185
186(deftest position-vector.6
187  (loop for i from 0 to 7 collect
188        (position 'c #(a b c d e c a) :start i :from-end t))
189  (5 5 5 5 5 5 nil nil))
190
191(deftest position-vector.7
192  (loop for i from 0 to 7 collect
193        (position 'c #(a b c d e c a) :start i :end nil :from-end t))
194  (5 5 5 5 5 5 nil nil))
195
196(deftest position-vector.8
197  (loop for i from 7 downto 0 collect
198        (position 'c #(a b c d e c a) :end i :from-end t))
199  (5 5 2 2 2 nil nil nil))
200
201(deftest position-vector.9
202  (loop for i from 0 to 6 collect
203        (loop for j from (1+ i) to 7
204              collect
205              (position 'c #(a b c d e c a) :start i :end j)))
206  ((nil nil 2 2 2 2 2)
207   (nil 2 2 2 2 2)
208   (2 2 2 2 2)
209   (nil nil 5 5)
210   (nil 5 5)
211   (5 5)
212   (nil)))
213
214(deftest position-vector.10
215  (loop for i from 0 to 6 collect
216        (loop for j from (1+ i) to 7
217              collect
218              (position 'c #(a b c d e c a) :start i :end j :from-end t)))
219  ((nil nil 2 2 2 5 5)
220   (nil 2 2 2 5 5)
221   (2 2 2 5 5)
222   (nil nil 5 5)
223   (nil 5 5)
224   (5 5)
225   (nil)))
226
227(deftest position-vector.11
228  (position 5 #(1 2 3 4 5 6 4 8) :key #'1+)
229  3)
230
231(deftest position-vector.12
232  (position 5 #(1 2 3 4 5 6 4 8) :key '1+)
233  3)
234
235(deftest position-vector.13
236  (position 5 #(1 2 3 4 5 6 4 8) :key #'1+ :from-end t)
237  6)
238
239(deftest position-vector.14
240  (position 'a #(a a b a c e d a f a) :test (complement #'eql))
241  2)
242
243(deftest position-vector.15
244  (position 'a #(a a b a c e d a f a) :test (complement #'eql)
245            :from-end t)
246  8)
247
248(deftest position-vector.16
249  (position 'a #(a a b a c e d a f a) :test-not #'eql)
250  2)
251
252(deftest position-vector.17
253  (position 'a #(a a b a c e d a f a) :test-not 'eql
254            :from-end t)
255  8)
256
257(deftest position-vector.18
258  (position 'a #(a a b a c e d a f a) :test-not 'eql)
259  2)
260
261(deftest position-vector.19
262  (position 'a #(a a b a c e d a f a) :test-not #'eql
263            :from-end t)
264  8)
265
266(deftest position-vector.20
267  (position 'a #(a a b a c e d a f a) :test-not #'eql)
268  2)
269
270(deftest position-vector.21
271  (position 'a #(a a b a c e d a f a) :test #'eql
272            :start 2)
273  3)
274
275(deftest position-vector.22
276  (position 'a #(a a b a c e d a f a) :test #'eql
277            :start 2 :end nil)
278  3)
279
280(deftest position-vector.23
281  (position 'a #(a a b a c e d a f a) :test-not #'eql
282            :start 0 :end 5)
283  2)
284
285(deftest position-vector.24
286  (position 'a #(a a b a c e d a f a) :test-not #'eql
287            :start 0 :end 5 :from-end t)
288  4)
289
290(deftest position-vector.25
291  (position '(a b) #(a (b a) (a b c) (a b) (d e) f) :test #'equal)
292  3)
293
294(deftest position-vector.26
295  (position 'a #((c) (b a) (a b c) (a b) (d e) f) :key #'car)
296  2)
297
298(deftest position-vector.27
299  (position 'a #((c) (b a) (a b c) (z) (a b) (d e) f) :key #'car
300            :start 3)
301  4)
302
303(deftest position-vector.28
304  (position 'a #((c) (b a) (a b c) (z) (a b) (d e) (f)) :key #'car
305            :start 2 :from-end t)
306  4)
307
308(deftest position-vector.29
309  (position 'a (make-array '(10) :initial-contents '(b b b b b a a a a a)
310                           :fill-pointer 5))
311  nil)
312
313(deftest position-vector.30
314  (position 'a (make-array '(10) :initial-contents '(b b b b a a a a a a)
315                           :fill-pointer 5))
316  4)
317
318(deftest position-vector.31
319  (position 'a (make-array '(10) :initial-contents '(b a b b a a a a a a)
320                           :fill-pointer 5)
321            :from-end t)
322  4)
323
324(deftest position-vector.32
325  (position 10 #(1 4 8 10 15 20) :test #'<)
326  4)
327
328(deftest position-vector.33
329  (position 10 #(1 4 8 10 15 20) :test-not #'>=)
330  4)
331
332(deftest position-vector.34
333  (let* ((v1 #(x x x a b c d a b c d y y y y y))
334         (v2 (make-array '(8) :displaced-to v1
335                         :displaced-index-offset 3)))
336    (values (position 'c v2)
337            (position 'c v2 :from-end t)))
338  2 6)                   
339
340;;; tests on bit vectors
341
342(deftest position-bit-vector.1
343  (position 1 #*001001010100)
344  2)
345
346(deftest position-bit-vector.2
347  (position 1 #*001001010100 :from-end t)
348  9)
349
350(deftest position-bit-vector.3
351  (loop for i from 0 to 7 collect
352        (position 1 #*0010010 :start i))
353  (2 2 2 5 5 5 nil nil))
354
355(deftest position-bit-vector.4
356  (loop for i from 0 to 7 collect
357        (position 1 #*0010010 :start i :end nil))
358  (2 2 2 5 5 5 nil nil))
359
360(deftest position-bit-vector.5
361  (loop for i from 7 downto 0 collect
362        (position 1 #*0010010 :end i))
363  (2 2 2 2 2 nil nil nil))
364
365(deftest position-bit-vector.6
366  (loop for i from 0 to 7 collect
367        (position 1 #*0010010 :start i :from-end t))
368  (5 5 5 5 5 5 nil nil))
369
370(deftest position-bit-vector.7
371  (loop for i from 0 to 7 collect
372        (position 0 #*1101101 :start i :end nil :from-end t))
373  (5 5 5 5 5 5 nil nil))
374
375(deftest position-bit-vector.8
376  (loop for i from 7 downto 0 collect
377        (position 0 #*1101101 :end i :from-end t))
378  (5 5 2 2 2 nil nil nil))
379
380(deftest position-bit-vector.9
381  (loop for i from 0 to 6 collect
382        (loop for j from (1+ i) to 7
383              collect
384              (position 1 #*0010010 :start i :end j)))
385  ((nil nil 2 2 2 2 2)
386   (nil 2 2 2 2 2)
387   (2 2 2 2 2)
388   (nil nil 5 5)
389   (nil 5 5)
390   (5 5)
391   (nil)))
392
393(deftest position-bit-vector.10
394  (loop for i from 0 to 6 collect
395        (loop for j from (1+ i) to 7
396              collect
397              (position 1 #*0010010 :start i :end j :from-end t)))
398  ((nil nil 2 2 2 5 5)
399   (nil 2 2 2 5 5)
400   (2 2 2 5 5)
401   (nil nil 5 5)
402   (nil 5 5)
403   (5 5)
404   (nil)))
405
406(deftest position-bit-vector.11
407  (position 2 #*00010001010 :key #'1+)
408  3)
409
410(deftest position-bit-vector.12
411  (position 2 #*00010001010 :key '1+)
412  3)
413
414(deftest position-bit-vector.13
415  (position 2 #*0010001000 :key #'1+ :from-end t)
416  6)
417
418(deftest position-bit-vector.14
419  (position 0 #*0010111010 :test (complement #'eql))
420  2)
421
422(deftest position-bit-vector.15
423  (position 0 #*0010111010 :test (complement #'eql)
424            :from-end t)
425  8)
426
427(deftest position-bit-vector.16
428  (position 0 #*0010111010 :test-not #'eql)
429  2)
430
431(deftest position-bit-vector.17
432  (position 0 #*001011101 :test-not 'eql
433            :from-end t)
434  8)
435
436(deftest position-bit-vector.18
437  (position 0 #*00101110 :test-not 'eql)
438  2)
439
440(deftest position-bit-vector.19
441  (position 0 #*00101110 :test-not #'eql
442            :from-end t)
443  6)
444
445(deftest position-bit-vector.20
446  (position 0 #*00101110 :test-not #'eql)
447  2)
448
449(deftest position-bit-vector.21
450  (position 0 #*00101110 :test #'eql
451            :start 2)
452  3)
453
454(deftest position-bit-vector.22
455  (position 0 #*00101110 :test #'eql
456            :start 2 :end nil)
457  3)
458
459(deftest position-bit-vector.23
460  (position 0 #*00101110 :test-not #'eql
461            :start 0 :end 5)
462  2)
463
464(deftest position-bit-vector.24
465  (position 0 #*00101110 :test-not #'eql
466            :start 0 :end 5 :from-end t)
467  4)
468
469(deftest position-bit-vector.25
470  (position 2 #*1100001010 :key #'1+
471            :start 3)
472  6)
473
474(deftest position-bit-vector.27
475  (position 2 #*1100001010 :key #'1+
476            :start 2 :from-end t)
477  8)
478
479(deftest position-bit-vector.28
480  (position 0 (make-array '(10) :initial-contents '(1 1 1 1 1 0 0 0 0 0)
481                          :element-type 'bit
482                          :fill-pointer 5))
483  nil)
484
485(deftest position-bit-vector.29
486  (position 0 (make-array '(10) :initial-contents '(1 1 1 1 1 0 0 0 0 0)
487                          :element-type 'bit
488                          :fill-pointer 5)
489            :from-end t)
490  nil)
491
492(deftest position-bit-vector.30
493  (position 0 (make-array '(10) :initial-contents '(1 1 1 1 0 0 0 0 0 0)
494                          :element-type 'bit
495                          :fill-pointer 5))
496  4)
497
498(deftest position-bit-vector.31
499  (position 0 (make-array '(10) :initial-contents '(0 1 0 1 0 0 0 0 0 0)
500                          :element-type 'bit
501                          :fill-pointer 5)
502            :from-end t)
503  4)
504
505(deftest position-bit-vector.32
506  (position 0 (make-array '(10) :initial-contents '(1 0 1 1 0 0 0 0 0 0)
507                          :element-type 'bit
508                          :fill-pointer 5))
509  1)
510
511(deftest position-bit-vector.33
512  (position 0 #*1111000 :test #'>=)
513  4)
514
515(deftest position-bit-vector.34
516  (position 0 #*1111000 :test-not #'<)
517  4)
518
519;;; strings
520
521(deftest position-string.1
522  (position #\c "abcdeca")
523  2)
524
525(deftest position-string.2
526  (position #\c "abcdeca" :from-end t)
527  5)
528
529(deftest position-string.3
530  (loop for i from 0 to 7 collect
531        (position #\c "abcdeca" :start i))
532  (2 2 2 5 5 5 nil nil))
533
534(deftest position-string.4
535  (loop for i from 0 to 7 collect
536        (position #\c "abcdeca" :start i :end nil))
537  (2 2 2 5 5 5 nil nil))
538
539(deftest position-string.5
540  (loop for i from 7 downto 0 collect
541        (position #\c "abcdeca" :end i))
542  (2 2 2 2 2 nil nil nil))
543
544(deftest position-string.6
545  (loop for i from 0 to 7 collect
546        (position #\c "abcdeca" :start i :from-end t))
547  (5 5 5 5 5 5 nil nil))
548
549(deftest position-string.7
550  (loop for i from 0 to 7 collect
551        (position #\c "abcdeca" :start i :end nil :from-end t))
552  (5 5 5 5 5 5 nil nil))
553
554(deftest position-string.8
555  (loop for i from 7 downto 0 collect
556        (position #\c "abcdeca" :end i :from-end t))
557  (5 5 2 2 2 nil nil nil))
558
559(deftest position-string.9
560  (loop for i from 0 to 6 collect
561        (loop for j from (1+ i) to 7
562              collect
563              (position #\c "abcdeca" :start i :end j)))
564  ((nil nil 2 2 2 2 2)
565   (nil 2 2 2 2 2)
566   (2 2 2 2 2)
567   (nil nil 5 5)
568   (nil 5 5)
569   (5 5)
570   (nil)))
571
572(deftest position-string.10
573  (loop for i from 0 to 6 collect
574        (loop for j from (1+ i) to 7
575              collect
576              (position #\c "abcdeca" :start i :end j :from-end t)))
577  ((nil nil 2 2 2 5 5)
578   (nil 2 2 2 5 5)
579   (2 2 2 5 5)
580   (nil nil 5 5)
581   (nil 5 5)
582   (5 5)
583   (nil)))
584
585(deftest position-string.11
586  (position 5 "12345648" :key #'(lambda (c)
587                                  (1+ (read-from-string (string c)))))
588  3)
589
590(deftest position-string.13
591  (position 5 "12345648" :key #'(lambda (c)
592                                  (1+ (read-from-string (string c))))
593            :from-end t)
594  6)
595
596(deftest position-string.14
597  (position #\a "aabacedafa" :test (complement #'eql))
598  2)
599
600(deftest position-string.15
601  (position #\a "aabacedafa" :test (complement #'eql)
602            :from-end t)
603  8)
604
605(deftest position-string.16
606  (position #\a "aabacedafa" :test-not #'eql)
607  2)
608
609(deftest position-string.17
610  (position #\a "aabacedafa" :test-not 'eql
611            :from-end t)
612  8)
613
614(deftest position-string.18
615  (position #\a "aabacedafa" :test-not 'eql)
616  2)
617
618(deftest position-string.19
619  (position #\a "aabacedafa" :test-not #'eql
620            :from-end t)
621  8)
622
623(deftest position-string.20
624  (position #\a "aabacedafa" :test-not #'eql)
625  2)
626
627(deftest position-string.21
628  (position #\a "aabacedafa" :test #'eql
629            :start 2)
630  3)
631
632(deftest position-string.22
633  (position #\a "aabacedafa" :test #'eql
634            :start 2 :end nil)
635  3)
636
637(deftest position-string.23
638  (position #\a "aabacedafa" :test-not #'eql
639            :start 0 :end 5)
640  2)
641
642(deftest position-string.24
643  (position #\a "aabacedafa" :test-not #'eql
644            :start 0 :end 5 :from-end t)
645  4)
646
647(deftest position-string.25
648  (position #\a (make-array '(10) :initial-contents "bbbbbaaaaa"
649                            :element-type 'character
650                            :fill-pointer 5))
651  nil)
652
653(deftest position-string.26
654  (position #\a (make-array '(10) :initial-contents "bbbbbaaaaa"
655                            :element-type 'character
656                            :fill-pointer 5)
657            :from-end t)
658  nil)
659
660(deftest position-string.27
661  (position #\a (make-array '(10) :initial-contents "bbbbaaaaaa"
662                            :element-type 'character
663                            :fill-pointer 5))
664  4)
665
666(deftest position-string.28
667  (position #\a (make-array '(10) :initial-contents "babbaaaaaa"
668                            :element-type 'character
669                            :fill-pointer 5)
670            :from-end t)
671  4)
672
673(deftest position-string.29
674  (position #\m "adfmpz" :test #'char<)
675  4)
676
677(deftest position-string.30
678  (position #\m "adfmpz" :test-not #'char>=)
679  4)
680
681(deftest position-string.31
682  (let* ((s1 (copy-seq "xxxabcdyyyyy"))
683         (s2 (make-array '(4) :displaced-to s1
684                         :displaced-index-offset 3
685                         :element-type (array-element-type s1))))
686    (position #\c s2))
687  2)
688
689(deftest position-string.32
690  (let* ((s1 (copy-seq "xxxabcdabcdyyyyyyyy"))
691         (s2 (make-array '(8) :displaced-to s1
692                         :displaced-index-offset 3
693                         :element-type (array-element-type s1))))
694    (position #\c s2 :from-end t))
695  6)
696
697(deftest position-string.33
698  (do-special-strings
699   (s "abcdabcdabcd" nil)
700   (let* ((c #\c)
701          (pos (position c s)))
702     (assert (eql pos 2) () "First position of ~A in ~A is ~A" c s pos)))
703  nil)
704
705(deftest position-string.34
706  (do-special-strings
707   (s "abcdabcdabcd" nil)
708   (let* ((c #\c)
709          (pos (position c s :from-end t)))
710     (assert (eql pos 10) () "Last position of ~A in ~A is ~A" c s pos)))
711  nil)
712
713(defharmless position.test-and-test-not.1
714  (position 'b '(a b c d) :test #'eql :test-not #'eql))
715
716(defharmless position.test-and-test-not.2
717  (position 'b '(a b c d) :test-not #'eql :test #'eql))
718
719(defharmless position.test-and-test-not.3
720  (position 'b #(a b c d) :test #'eql :test-not #'eql))
721
722(defharmless position.test-and-test-not.4
723  (position 'b #(a b c d) :test-not #'eql :test #'eql))
724
725(defharmless position.test-and-test-not.5
726  (position #\b "abcd" :test #'eql :test-not #'eql))
727
728(defharmless position.test-and-test-not.6
729  (position #\b "abcd" :test-not #'eql :test #'eql))
730
731(defharmless position.test-and-test-not.7
732  (position 1 #*001010010 :test #'eql :test-not #'eql))
733
734(defharmless position.test-and-test-not.8
735  (position 0 #*1110010110111 :test-not #'eql :test #'eql))
736
737(deftest position.order.1
738  (let ((i 0) a b c d e f g)
739    (values
740     (position
741      (progn (setf a (incf i)) 0)
742      (progn (setf b (incf i)) '(3 1 8 2 1 2 3 4))
743      :from-end (setf c (incf i))
744      :start (progn (setf d (incf i)) 1)
745      :end (progn (setf e (incf i)) 6)
746      :key (progn (setf f (incf i)) #'1-)
747      :test (progn (setf g (incf i)) #'=)
748      )
749     i a b c d e f g))
750  4 7 1 2 3 4 5 6 7)
751
752(deftest position.order.2
753  (let ((i 0) a b c d e f g)
754    (values
755     (position
756      (progn (setf a (incf i)) 0)
757      (progn (setf b (incf i)) '(3 1 8 2 1 2 3 4))
758      :test-not (progn (setf c (incf i)) #'/=)
759      :key (progn (setf d (incf i)) #'1-)
760      :end (progn (setf e (incf i)) 6)
761      :start (progn (setf f (incf i)) 1)
762      :from-end (setf g (incf i))
763      )
764     i a b c d e f g))
765  4 7 1 2 3 4 5 6 7)
766
767;;; Keyword tests
768
769(deftest position.allow-other-keys.1
770  (position 0 '(1 2 0 3 2 1) :allow-other-keys t)
771  2)
772
773(deftest position.allow-other-keys.2
774  (position 0 '(1 2 0 3 2 1) :allow-other-keys nil)
775  2)
776
777(deftest position.allow-other-keys.3
778  (position 0 '(1 2 0 3 2 1) :allow-other-keys t :bad t)
779  2)
780
781(deftest position.allow-other-keys.4
782  (position 0 '(1 2 0 3 2 1) :bad t :allow-other-keys t)
783  2)
784
785(deftest position.allow-other-keys.5
786  (position 0 '(1 2 0 3 2 1) :bad t :allow-other-keys t :key #'1-)
787  0)
788
789(deftest position.keywords.6
790  (position 0 '(1 2 0 3 2 1) :key #'1- :key #'identity)
791  0)
792
793(deftest position.allow-other-keys.7
794  (position 0 '(1 2 0 3 2 1) :bad t :allow-other-keys t
795               :allow-other-keys nil)
796  2)
797
798(deftest position.allow-other-keys.8
799  (position 0 '(1 2 0 3 2 1) :allow-other-keys t :bad t
800               :allow-other-keys nil)
801  2)
802
803(deftest position.allow-other-keys.9
804  (position 0 '(1 2 0 3 2 1) :allow-other-keys t
805               :allow-other-keys nil :bad t)
806  2)
807
808;;; Error tests
809
810(deftest position.error.1
811  (check-type-error #'(lambda (x) (position 'a x)) #'sequencep)
812  nil)
813
814(deftest position.error.4
815  (signals-error (position 'e '(a b c . d)) type-error)
816  t)
817
818(deftest position.error.5
819  (signals-error (position) program-error)
820  t)
821
822(deftest position.error.6
823  (signals-error (position 'a) program-error)
824  t)
825
826(deftest position.error.7
827  (signals-error (position 'a nil :key) program-error)
828  t)
829
830(deftest position.error.8
831  (signals-error (position 'a nil 'bad t) program-error)
832  t)
833
834(deftest position.error.9
835  (signals-error (position 'a nil 'bad t :allow-other-keys nil) program-error)
836  t)
837
838(deftest position.error.10
839  (signals-error (position 'a nil 1 2) program-error)
840  t)
841
842(deftest position.error.11
843  (signals-error (locally (position 'a 'b) t) type-error)
844  t)
845
846(deftest position.error.12
847  (signals-error (position 'b '(a b c d) :test #'identity) program-error)
848  t)
849
850(deftest position.error.13
851  (signals-error (position 'b '(a b c d) :test-not #'not) program-error)
852  t)
853
854(deftest position.error.14
855  (signals-error (position 'b '(a b c d) :key #'cdr) type-error)
856  t)
857
858(deftest position.error.15
859  (signals-error (position 'b '(a b c d) :key #'cons) program-error)
860  t)
Note: See TracBrowser for help on using the repository browser.