2
;;;; Author: Paul Dietz
3
;;;; Created: Sat Mar 28 07:33:20 1998
4
;;;; Contains: Tests of ADJOIN
8
(compile-and-load "cons-aux.lsp")
22
;; Check that a NIL :key argument is the same as no key argument at all
24
(adjoin 'a '(a) :key nil)
28
(adjoin 'a '(a) :key #'identity)
32
(adjoin 'a '(a) :key 'identity)
36
(adjoin (1+ 11) '(4 3 12 2 1))
39
;; Check that the test is EQL, not EQ (by adjoining a bignum)
41
(adjoin (1+ 999999999999) '(4 1 1000000000000 3816734 a "aa"))
42
(4 1 1000000000000 3816734 a "aa"))
45
(adjoin (copy-seq "aaa") '(aaa "AAA" "aaa" #\a))
46
("aaa" aaa "AAA" "aaa" #\a))
49
(adjoin (copy-seq "aaa") '(aaa "AAA" "aaa" #\a) :test #'equal)
50
(aaa "AAA" "aaa" #\a))
53
(adjoin (copy-seq "aaa") '(aaa "AAA" "aaa" #\a) :test 'equal)
54
(aaa "AAA" "aaa" #\a))
57
(adjoin (copy-seq "aaa") '(aaa "AAA" "aaa" #\a)
58
:test-not (complement #'equal))
59
(aaa "AAA" "aaa" #\a))
62
(adjoin (copy-seq "aaa") '(aaa "AAA" "aaa" #\a)
63
:test #'equal :key #'identity)
64
(aaa "AAA" "aaa" #\a))
67
(adjoin (copy-seq "aaa") '(aaa "AAA" "aaa" #\a)
68
:test 'equal :key #'identity)
69
(aaa "AAA" "aaa" #\a))
71
;; Test that a :key of NIL is the same as no key at all
73
(adjoin (copy-seq "aaa") '(aaa "AAA" "aaa" #\a)
74
:test #'equal :key nil)
75
(aaa "AAA" "aaa" #\a))
77
;; Test that a :key of NIL is the same as no key at all
79
(adjoin (copy-seq "aaa") '(aaa "AAA" "aaa" #\a)
80
:test 'equal :key nil)
81
(aaa "AAA" "aaa" #\a))
83
;; Test that a :key of NIL is the same as no key at all
85
(adjoin (copy-seq "aaa") '(aaa "AAA" "aaa" #\a)
86
:test-not (complement #'equal) :key nil)
87
(aaa "AAA" "aaa" #\a))
89
;;; Ordering in comparison function
92
(adjoin 10 '(1 2 3) :test #'<)
96
(adjoin 10 '(1 2 3) :test #'>)
100
(adjoin 10 '(1 2 3) :test-not #'>)
104
(adjoin 10 '(1 2 3) :test-not #'<)
107
(defharmless adjoin.test-and-test-not.1
108
(adjoin 'a '(b c) :test #'eql :test-not #'eql))
110
(defharmless adjoin.test-and-test-not.2
111
(adjoin 'a '(b c) :test-not #'eql :test #'eql))
113
(deftest adjoin.order.1
116
(adjoin (progn (setf w (incf i)) 'a)
117
(progn (setf x (incf i)) '(b c d a e))
118
:key (progn (setf y (incf i)) #'identity)
119
:test (progn (setf z (incf i)) #'eql))
124
(deftest adjoin.order.2
125
(let ((i 0) w x y z p)
127
(adjoin (progn (setf w (incf i)) 'a)
128
(progn (setf x (incf i)) '(b c d e))
129
:test-not (progn (setf y (incf i)) (complement #'eql))
130
:key (progn (setf z (incf i)) #'identity)
131
:key (progn (setf p (incf i)) nil))
136
(deftest adjoin.allow-other-keys.1
137
(adjoin 'a '(b c) :bad t :allow-other-keys t)
140
(deftest adjoin.allow-other-keys.2
141
(adjoin 'a '(b c) :allow-other-keys t :foo t)
144
(deftest adjoin.allow-other-keys.3
145
(adjoin 'a '(b c) :allow-other-keys t)
148
(deftest adjoin.allow-other-keys.4
149
(adjoin 'a '(b c) :allow-other-keys nil)
152
(deftest adjoin.allow-other-keys.5
153
(adjoin 'a '(b c) :allow-other-keys t :allow-other-keys nil 'bad t)
156
(deftest adjoin.repeat-key
157
(adjoin 'a '(b c) :test #'eq :test (complement #'eq))
160
(deftest adjoin.error.1
161
(signals-error (adjoin) program-error)
164
(deftest adjoin.error.2
165
(signals-error (adjoin 'a) program-error)
168
(deftest adjoin.error.3
169
(signals-error (adjoin 'a '(b c) :bad t) program-error)
172
(deftest adjoin.error.4
173
(signals-error (adjoin 'a '(b c) :allow-other-keys nil :bad t) program-error)
176
(deftest adjoin.error.5
177
(signals-error (adjoin 'a '(b c) 1 2) program-error)
180
(deftest adjoin.error.6
181
(signals-error (adjoin 'a '(b c) :test) program-error)
184
(deftest adjoin.error.7
185
(signals-error (adjoin 'a '(b c) :test #'identity) program-error)
188
(deftest adjoin.error.8
189
(signals-error (adjoin 'a '(b c) :test-not #'identity) program-error)
192
(deftest adjoin.error.9
193
(signals-error (adjoin 'a '(b c) :key #'cons) program-error)
196
(deftest adjoin.error.10
197
(signals-error (adjoin 'a (list* 'b 'c 'd)) type-error)