16 |
(acons (cdar x) (caar x) (rev-assoc-list (cdr x)))))) |
(acons (cdar x) (caar x) (rev-assoc-list (cdr x)))))) |
17 |
|
|
18 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
19 |
;;; assoc |
;;; rassoc |
20 |
|
|
21 |
(deftest rassoc-1 |
(deftest rassoc-1 |
22 |
(rassoc nil nil) |
(rassoc nil nil) |
191 |
(eqt x y)))) |
(eqt x y)))) |
192 |
(3 . A)) |
(3 . A)) |
193 |
|
|
194 |
(deftest rassoc-26 |
;;; Keyword tests |
195 |
|
|
196 |
|
(deftest rassoc.allow-other-keys.1 |
197 |
(rassoc 'b '((1 . a) (2 . b) (3 . c)) :bad t :allow-other-keys t) |
(rassoc 'b '((1 . a) (2 . b) (3 . c)) :bad t :allow-other-keys t) |
198 |
(2 . b)) |
(2 . b)) |
199 |
|
|
200 |
(deftest rassoc-27 |
(deftest rassoc.allow-other-keys.2 |
201 |
(rassoc 'b '((1 . a) (2 . b) (3 . c)) :allow-other-keys t :bad t) |
(rassoc 'b '((1 . a) (2 . b) (3 . c)) :allow-other-keys t :bad t) |
202 |
(2 . b)) |
(2 . b)) |
203 |
|
|
204 |
(deftest rassoc-28 |
(deftest rassoc.allow-other-keys.3 |
205 |
(rassoc 'a '((1 . a) (2 . b) (3 . c)) :allow-other-keys t :bad t |
(rassoc 'a '((1 . a) (2 . b) (3 . c)) :allow-other-keys t :bad t |
206 |
:test-not #'eql) |
:test-not #'eql) |
207 |
(2 . b)) |
(2 . b)) |
208 |
|
|
209 |
|
(deftest rassoc.allow-other-keys.4 |
210 |
|
(rassoc 'b '((1 . a) (2 . b) (3 . c)) :allow-other-keys t) |
211 |
|
(2 . b)) |
212 |
|
|
213 |
|
(deftest rassoc.allow-other-keys.5 |
214 |
|
(rassoc 'b '((1 . a) (2 . b) (3 . c)) :allow-other-keys nil) |
215 |
|
(2 . b)) |
216 |
|
|
217 |
|
(deftest rassoc.keywords.6 |
218 |
|
(rassoc 'b '((1 . a) (2 . b) (3 . c)) |
219 |
|
:test #'eql :test (complement #'eql)) |
220 |
|
(2 . b)) |
221 |
|
|
222 |
|
;;; Error tests |
223 |
|
|
224 |
(deftest rassoc.error.1 |
(deftest rassoc.error.1 |
225 |
(classify-error (rassoc)) |
(classify-error (rassoc)) |
226 |
program-error) |
program-error) |
284 |
(rev-assoc-list '((a . b) nil (c . d) (nil . e) (f . g)))) |
(rev-assoc-list '((a . b) nil (c . d) (nil . e) (f . g)))) |
285 |
(e)) |
(e)) |
286 |
|
|
287 |
(deftest rassoc-if-26 |
;;; Keyword tests |
288 |
|
|
289 |
|
(deftest rassoc-if.allow-other-keys.1 |
290 |
(rassoc-if #'null '((1 . a) (2) (3 . c)) :bad t :allow-other-keys t) |
(rassoc-if #'null '((1 . a) (2) (3 . c)) :bad t :allow-other-keys t) |
291 |
(2)) |
(2)) |
292 |
|
|
293 |
(deftest rassoc-if-27 |
(deftest rassoc-if.allow-other-keys.2 |
294 |
(rassoc-if #'null '((1 . a) (2) (3 . c)) :allow-other-keys t :bad t) |
(rassoc-if #'null '((1 . a) (2) (3 . c)) :allow-other-keys t :bad t) |
295 |
(2)) |
(2)) |
296 |
|
|
297 |
(deftest rassoc-if-28 |
(deftest rassoc-if.allow-other-keys.3 |
298 |
(rassoc-if #'identity '((1 . a) (2) (3 . c)) :allow-other-keys t :bad t |
(rassoc-if #'identity '((1 . a) (2) (3 . c)) :allow-other-keys t :bad t |
299 |
:key 'not) |
:key 'not) |
300 |
(2)) |
(2)) |
301 |
|
|
302 |
|
(deftest rassoc-if.allow-other-keys.4 |
303 |
|
(rassoc-if #'null '((1 . a) (2) (3 . c)) :allow-other-keys t) |
304 |
|
(2)) |
305 |
|
|
306 |
|
(deftest rassoc-if.allow-other-keys.5 |
307 |
|
(rassoc-if #'null '((1 . a) (2) (3 . c)) :allow-other-keys nil) |
308 |
|
(2)) |
309 |
|
|
310 |
|
(deftest rassoc-if.keywords.6 |
311 |
|
(rassoc-if #'identity '((1 . a) (2) (3 . c)) :key #'not :key #'identity) |
312 |
|
(2)) |
313 |
|
|
314 |
|
;;; Error tests |
315 |
|
|
316 |
(deftest rassoc-if.error.1 |
(deftest rassoc-if.error.1 |
317 |
(classify-error (rassoc-if)) |
(classify-error (rassoc-if)) |
318 |
program-error) |
program-error) |
375 |
(rev-assoc-list '((a . b) nil (c . d) (nil . e) (f . g)))) |
(rev-assoc-list '((a . b) nil (c . d) (nil . e) (f . g)))) |
376 |
(e)) |
(e)) |
377 |
|
|
378 |
(deftest rassoc-if-not-26 |
;;; Keyword tests |
379 |
|
|
380 |
|
(deftest rassoc-if-not.allow-other-keys.1 |
381 |
(rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :bad t :allow-other-keys t) |
(rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :bad t :allow-other-keys t) |
382 |
(2)) |
(2)) |
383 |
|
|
384 |
(deftest rassoc-if-not-27 |
(deftest rassoc-if-not.allow-other-keys.2 |
385 |
(rassoc-if-not #'values '((1 . a) (2) (3 . c)) :allow-other-keys t :bad t) |
(rassoc-if-not #'values '((1 . a) (2) (3 . c)) :allow-other-keys t :bad t) |
386 |
(2)) |
(2)) |
387 |
|
|
388 |
(deftest rassoc-if-not-28 |
(deftest rassoc-if-not.allow-other-keys.3 |
389 |
(rassoc-if-not #'not '((1 . a) (2) (3 . c)) :allow-other-keys t :bad t |
(rassoc-if-not #'not '((1 . a) (2) (3 . c)) :allow-other-keys t :bad t |
390 |
:key 'not) |
:key 'not) |
391 |
(2)) |
(2)) |
392 |
|
|
393 |
|
(deftest rassoc-if-not.allow-other-keys.4 |
394 |
|
(rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :allow-other-keys t) |
395 |
|
(2)) |
396 |
|
|
397 |
|
(deftest rassoc-if-not.allow-other-keys.5 |
398 |
|
(rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :allow-other-keys nil) |
399 |
|
(2)) |
400 |
|
|
401 |
|
(deftest rassoc-if-not.allow-other-keys.6 |
402 |
|
(rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :allow-other-keys t |
403 |
|
:allow-other-keys nil :bad t) |
404 |
|
(2)) |
405 |
|
|
406 |
|
(deftest rassoc-if-not.keywords.7 |
407 |
|
(rassoc-if-not #'identity '((1 . a) (2) (3 . c)) :key #'not :key nil) |
408 |
|
(1 . a)) |
409 |
|
|
410 |
|
;;; Error tests |
411 |
|
|
412 |
(deftest rassoc-if-not.error.1 |
(deftest rassoc-if-not.error.1 |
413 |
(classify-error (rassoc-if-not)) |
(classify-error (rassoc-if-not)) |
414 |
program-error) |
program-error) |