aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPaul Eggert2017-02-10 11:52:41 +0200
committerEli Zaretskii2017-02-10 11:52:41 +0200
commit65298ff4d5861cbc8d88162d58c18fa972b81acf (patch)
tree2fae2cfcb08c48749d72c5e151f00ded4b0ae44c /test
parentc48f8fa51b51746ffd39f7b973c471cd60994c8e (diff)
downloademacs-65298ff4d5861cbc8d88162d58c18fa972b81acf.tar.gz
emacs-65298ff4d5861cbc8d88162d58c18fa972b81acf.zip
Move cyclic tests to fns-tests.el
* test/src/fns-tests.el (cyc1, cyc2, dot1, dot2): New functions. (test-cycle-length, test-cycle-safe-length, test-cycle-member) (test-cycle-memq, test-cycle-memql, test-cycle-assq) (test-cycle-assoc, test-cycle-rassq, test-cycle-rassoc) (test-cycle-delq, test-cycle-delete, test-cycle-reverse) (test-cycle-plist-get, test-cycle-lax-plist-get) (test-cycle-plist-member, test-cycle-plist-put) (test-cycle-lax-plist-put, test-cycle-equal, test-cycle-nconc): New tests. * test/manual/cyclic-tests.el: File deleted.
Diffstat (limited to 'test')
-rw-r--r--test/manual/cycle-tests.el314
-rw-r--r--test/src/fns-tests.el298
2 files changed, 298 insertions, 314 deletions
diff --git a/test/manual/cycle-tests.el b/test/manual/cycle-tests.el
deleted file mode 100644
index 2632b2d7b54..00000000000
--- a/test/manual/cycle-tests.el
+++ /dev/null
@@ -1,314 +0,0 @@
1;;; Test handling of cyclic and dotted lists -*- lexical-binding: t; -*-
2
3;; Copyright 2017 Free Software Foundation, Inc.
4
5;; Written by Paul Eggert
6
7;; This program is free software; you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; This program is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20(require 'ert)
21
22(defun cyc1 (a)
23 (let ((ls (make-list 10 a)))
24 (nconc ls ls)
25 ls))
26(defun cyc2 (a b)
27 (let ((ls1 (make-list 10 a))
28 (ls2 (make-list 1000 b)))
29 (nconc ls2 ls2)
30 (nconc ls1 ls2)
31 ls1))
32
33(defun dot1 (a)
34 (let ((ls (make-list 10 a)))
35 (nconc ls 'tail)
36 ls))
37(defun dot2 (a b)
38 (let ((ls1 (make-list 10 a))
39 (ls2 (make-list 10 b)))
40 (nconc ls1 ls2)
41 (nconc ls2 'tail)
42 ls1))
43
44(ert-deftest test-cycle-length ()
45 (should-error (length (cyc1 1)) :type 'circular-list)
46 (should-error (length (cyc2 1 2)) :type 'circular-list)
47 (should-error (length (dot1 1)) :type 'wrong-type-argument)
48 (should-error (length (dot2 1 2)) :type 'wrong-type-argument))
49
50(ert-deftest test-cycle-safe-length ()
51 (should (<= 10 (safe-length (cyc1 1))))
52 (should (<= 1010 (safe-length (cyc2 1 2))))
53 (should (= 10 (safe-length (dot1 1))))
54 (should (= 20 (safe-length (dot2 1 2)))))
55
56(ert-deftest test-cycle-member ()
57 (let ((c1 (cyc1 1))
58 (c2 (cyc2 1 2))
59 (d1 (dot1 1))
60 (d2 (dot2 1 2)))
61 (should (member 1 c1))
62 (should (member 1 c2))
63 (should (member 1 d1))
64 (should (member 1 d2))
65 (should-error (member 2 c1) :type 'circular-list)
66 (should (member 2 c2))
67 (should-error (member 2 d1) :type 'wrong-type-argument)
68 (should (member 2 d2))
69 (should-error (member 3 c1) :type 'circular-list)
70 (should-error (member 3 c2) :type 'circular-list)
71 (should-error (member 3 d1) :type 'wrong-type-argument)
72 (should-error (member 3 d2) :type 'wrong-type-argument)))
73
74(ert-deftest test-cycle-memq ()
75 (let ((c1 (cyc1 1))
76 (c2 (cyc2 1 2))
77 (d1 (dot1 1))
78 (d2 (dot2 1 2)))
79 (should (memq 1 c1))
80 (should (memq 1 c2))
81 (should (memq 1 d1))
82 (should (memq 1 d2))
83 (should-error (memq 2 c1) :type 'circular-list)
84 (should (memq 2 c2))
85 (should-error (memq 2 d1) :type 'wrong-type-argument)
86 (should (memq 2 d2))
87 (should-error (memq 3 c1) :type 'circular-list)
88 (should-error (memq 3 c2) :type 'circular-list)
89 (should-error (memq 3 d1) :type 'wrong-type-argument)
90 (should-error (memq 3 d2) :type 'wrong-type-argument)))
91
92(ert-deftest test-cycle-memql ()
93 (let ((c1 (cyc1 1))
94 (c2 (cyc2 1 2))
95 (d1 (dot1 1))
96 (d2 (dot2 1 2)))
97 (should (memql 1 c1))
98 (should (memql 1 c2))
99 (should (memql 1 d1))
100 (should (memql 1 d2))
101 (should-error (memql 2 c1) :type 'circular-list)
102 (should (memql 2 c2))
103 (should-error (memql 2 d1) :type 'wrong-type-argument)
104 (should (memql 2 d2))
105 (should-error (memql 3 c1) :type 'circular-list)
106 (should-error (memql 3 c2) :type 'circular-list)
107 (should-error (memql 3 d1) :type 'wrong-type-argument)
108 (should-error (memql 3 d2) :type 'wrong-type-argument)))
109
110(ert-deftest test-cycle-assq ()
111 (let ((c1 (cyc1 '(1)))
112 (c2 (cyc2 '(1) '(2)))
113 (d1 (dot1 '(1)))
114 (d2 (dot2 '(1) '(2))))
115 (should (assq 1 c1))
116 (should (assq 1 c2))
117 (should (assq 1 d1))
118 (should (assq 1 d2))
119 (should-error (assq 2 c1) :type 'circular-list)
120 (should (assq 2 c2))
121 (should-error (assq 2 d1) :type 'wrong-type-argument)
122 (should (assq 2 d2))
123 (should-error (assq 3 c1) :type 'circular-list)
124 (should-error (assq 3 c2) :type 'circular-list)
125 (should-error (assq 3 d1) :type 'wrong-type-argument)
126 (should-error (assq 3 d2) :type 'wrong-type-argument)))
127
128(ert-deftest test-cycle-assoc ()
129 (let ((c1 (cyc1 '(1)))
130 (c2 (cyc2 '(1) '(2)))
131 (d1 (dot1 '(1)))
132 (d2 (dot2 '(1) '(2))))
133 (should (assoc 1 c1))
134 (should (assoc 1 c2))
135 (should (assoc 1 d1))
136 (should (assoc 1 d2))
137 (should-error (assoc 2 c1) :type 'circular-list)
138 (should (assoc 2 c2))
139 (should-error (assoc 2 d1) :type 'wrong-type-argument)
140 (should (assoc 2 d2))
141 (should-error (assoc 3 c1) :type 'circular-list)
142 (should-error (assoc 3 c2) :type 'circular-list)
143 (should-error (assoc 3 d1) :type 'wrong-type-argument)
144 (should-error (assoc 3 d2) :type 'wrong-type-argument)))
145
146(ert-deftest test-cycle-rassq ()
147 (let ((c1 (cyc1 '(0 . 1)))
148 (c2 (cyc2 '(0 . 1) '(0 . 2)))
149 (d1 (dot1 '(0 . 1)))
150 (d2 (dot2 '(0 . 1) '(0 . 2))))
151 (should (rassq 1 c1))
152 (should (rassq 1 c2))
153 (should (rassq 1 d1))
154 (should (rassq 1 d2))
155 (should-error (rassq 2 c1) :type 'circular-list)
156 (should (rassq 2 c2))
157 (should-error (rassq 2 d1) :type 'wrong-type-argument)
158 (should (rassq 2 d2))
159 (should-error (rassq 3 c1) :type 'circular-list)
160 (should-error (rassq 3 c2) :type 'circular-list)
161 (should-error (rassq 3 d1) :type 'wrong-type-argument)
162 (should-error (rassq 3 d2) :type 'wrong-type-argument)))
163
164(ert-deftest test-cycle-rassoc ()
165 (let ((c1 (cyc1 '(0 . 1)))
166 (c2 (cyc2 '(0 . 1) '(0 . 2)))
167 (d1 (dot1 '(0 . 1)))
168 (d2 (dot2 '(0 . 1) '(0 . 2))))
169 (should (rassoc 1 c1))
170 (should (rassoc 1 c2))
171 (should (rassoc 1 d1))
172 (should (rassoc 1 d2))
173 (should-error (rassoc 2 c1) :type 'circular-list)
174 (should (rassoc 2 c2))
175 (should-error (rassoc 2 d1) :type 'wrong-type-argument)
176 (should (rassoc 2 d2))
177 (should-error (rassoc 3 c1) :type 'circular-list)
178 (should-error (rassoc 3 c2) :type 'circular-list)
179 (should-error (rassoc 3 d1) :type 'wrong-type-argument)
180 (should-error (rassoc 3 d2) :type 'wrong-type-argument)))
181
182(ert-deftest test-cycle-delq ()
183 (should-error (delq 1 (cyc1 1)) :type 'circular-list)
184 (should-error (delq 1 (cyc2 1 2)) :type 'circular-list)
185 (should-error (delq 1 (dot1 1)) :type 'wrong-type-argument)
186 (should-error (delq 1 (dot2 1 2)) :type 'wrong-type-argument)
187 (should-error (delq 2 (cyc1 1)) :type 'circular-list)
188 (should-error (delq 2 (cyc2 1 2)) :type 'circular-list)
189 (should-error (delq 2 (dot1 1)) :type 'wrong-type-argument)
190 (should-error (delq 2 (dot2 1 2)) :type 'wrong-type-argument)
191 (should-error (delq 3 (cyc1 1)) :type 'circular-list)
192 (should-error (delq 3 (cyc2 1 2)) :type 'circular-list)
193 (should-error (delq 3 (dot1 1)) :type 'wrong-type-argument)
194 (should-error (delq 3 (dot2 1 2)) :type 'wrong-type-argument))
195
196(ert-deftest test-cycle-delete ()
197 (should-error (delete 1 (cyc1 1)) :type 'circular-list)
198 (should-error (delete 1 (cyc2 1 2)) :type 'circular-list)
199 (should-error (delete 1 (dot1 1)) :type 'wrong-type-argument)
200 (should-error (delete 1 (dot2 1 2)) :type 'wrong-type-argument)
201 (should-error (delete 2 (cyc1 1)) :type 'circular-list)
202 (should-error (delete 2 (cyc2 1 2)) :type 'circular-list)
203 (should-error (delete 2 (dot1 1)) :type 'wrong-type-argument)
204 (should-error (delete 2 (dot2 1 2)) :type 'wrong-type-argument)
205 (should-error (delete 3 (cyc1 1)) :type 'circular-list)
206 (should-error (delete 3 (cyc2 1 2)) :type 'circular-list)
207 (should-error (delete 3 (dot1 1)) :type 'wrong-type-argument)
208 (should-error (delete 3 (dot2 1 2)) :type 'wrong-type-argument))
209
210(ert-deftest test-cycle-reverse ()
211 (should-error (reverse (cyc1 1)) :type 'circular-list)
212 (should-error (reverse (cyc2 1 2)) :type 'circular-list)
213 (should-error (reverse (dot1 1)) :type 'wrong-type-argument)
214 (should-error (reverse (dot2 1 2)) :type 'wrong-type-argument))
215
216(ert-deftest test-cycle-plist-get ()
217 (let ((c1 (cyc1 1))
218 (c2 (cyc2 1 2))
219 (d1 (dot1 1))
220 (d2 (dot2 1 2)))
221 (should (plist-get c1 1))
222 (should (plist-get c2 1))
223 (should (plist-get d1 1))
224 (should (plist-get d2 1))
225 (should-not (plist-get c1 2))
226 (should (plist-get c2 2))
227 (should-not (plist-get d1 2))
228 (should (plist-get d2 2))
229 (should-not (plist-get c1 3))
230 (should-not (plist-get c2 3))
231 (should-not (plist-get d1 3))
232 (should-not (plist-get d2 3))))
233
234(ert-deftest test-cycle-lax-plist-get ()
235 (let ((c1 (cyc1 1))
236 (c2 (cyc2 1 2))
237 (d1 (dot1 1))
238 (d2 (dot2 1 2)))
239 (should (lax-plist-get c1 1))
240 (should (lax-plist-get c2 1))
241 (should (lax-plist-get d1 1))
242 (should (lax-plist-get d2 1))
243 (should-error (lax-plist-get c1 2) :type 'circular-list)
244 (should (lax-plist-get c2 2))
245 (should-not (lax-plist-get d1 2))
246 (should (lax-plist-get d2 2))
247 (should-error (lax-plist-get c1 3) :type 'circular-list)
248 (should-error (lax-plist-get c2 3) :type 'circular-list)
249 (should-not (lax-plist-get d1 3))
250 (should-not (lax-plist-get d2 3))))
251
252(ert-deftest test-cycle-plist-member ()
253 (let ((c1 (cyc1 1))
254 (c2 (cyc2 1 2))
255 (d1 (dot1 1))
256 (d2 (dot2 1 2)))
257 (should (plist-member c1 1))
258 (should (plist-member c2 1))
259 (should (plist-member d1 1))
260 (should (plist-member d2 1))
261 (should-error (plist-member c1 2) :type 'circular-list)
262 (should (plist-member c2 2))
263 (should-error (plist-member d1 2) :type 'wrong-type-argument)
264 (should (plist-member d2 2))
265 (should-error (plist-member c1 3) :type 'circular-list)
266 (should-error (plist-member c2 3) :type 'circular-list)
267 (should-error (plist-member d1 3) :type 'wrong-type-argument)
268 (should-error (plist-member d2 3) :type 'wrong-type-argument)))
269
270(ert-deftest test-cycle-plist-put ()
271 (let ((c1 (cyc1 1))
272 (c2 (cyc2 1 2))
273 (d1 (dot1 1))
274 (d2 (dot2 1 2)))
275 (should (plist-put c1 1 1))
276 (should (plist-put c2 1 1))
277 (should (plist-put d1 1 1))
278 (should (plist-put d2 1 1))
279 (should-error (plist-put c1 2 2) :type 'circular-list)
280 (should (plist-put c2 2 2))
281 (should (plist-put d1 2 2))
282 (should (plist-put d2 2 2))
283 (should-error (plist-put c1 3 3) :type 'circular-list)
284 (should-error (plist-put c2 3 3) :type 'circular-list)
285 (should (plist-put d1 3 3))
286 (should (plist-put d2 3 3))))
287
288(ert-deftest test-cycle-lax-plist-put ()
289 (let ((c1 (cyc1 1))
290 (c2 (cyc2 1 2))
291 (d1 (dot1 1))
292 (d2 (dot2 1 2)))
293 (should (lax-plist-put c1 1 1))
294 (should (lax-plist-put c2 1 1))
295 (should (lax-plist-put d1 1 1))
296 (should (lax-plist-put d2 1 1))
297 (should-error (lax-plist-put c1 2 2) :type 'circular-list)
298 (should (lax-plist-put c2 2 2))
299 (should (lax-plist-put d1 2 2))
300 (should (lax-plist-put d2 2 2))
301 (should-error (lax-plist-put c1 3 3) :type 'circular-list)
302 (should-error (lax-plist-put c2 3 3) :type 'circular-list)
303 (should (lax-plist-put d1 3 3))
304 (should (lax-plist-put d2 3 3))))
305
306(ert-deftest test-cycle-equal ()
307 (should-error (equal (cyc1 1) (cyc1 1)))
308 (should-error (equal (cyc2 1 2) (cyc2 1 2))))
309
310(ert-deftest test-cycle-nconc ()
311 (should-error (nconc (cyc1 1) 'tail) :type 'circular-list)
312 (should-error (nconc (cyc2 1 2) 'tail) :type 'circular-list))
313
314(provide 'cycle-tests)
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index ee3c5dc77e4..160d0f106e9 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -245,3 +245,301 @@
245 (let ((data '((foo) (bar)))) 245 (let ((data '((foo) (bar))))
246 (should (equal (mapcan #'identity data) '(foo bar))) 246 (should (equal (mapcan #'identity data) '(foo bar)))
247 (should (equal data '((foo bar) (bar)))))) 247 (should (equal data '((foo bar) (bar))))))
248
249;; Test handling of cyclic and dotted lists.
250
251(defun cyc1 (a)
252 (let ((ls (make-list 10 a)))
253 (nconc ls ls)
254 ls))
255
256(defun cyc2 (a b)
257 (let ((ls1 (make-list 10 a))
258 (ls2 (make-list 1000 b)))
259 (nconc ls2 ls2)
260 (nconc ls1 ls2)
261 ls1))
262
263(defun dot1 (a)
264 (let ((ls (make-list 10 a)))
265 (nconc ls 'tail)
266 ls))
267
268(defun dot2 (a b)
269 (let ((ls1 (make-list 10 a))
270 (ls2 (make-list 10 b)))
271 (nconc ls1 ls2)
272 (nconc ls2 'tail)
273 ls1))
274
275(ert-deftest test-cycle-length ()
276 (should-error (length (cyc1 1)) :type 'circular-list)
277 (should-error (length (cyc2 1 2)) :type 'circular-list)
278 (should-error (length (dot1 1)) :type 'wrong-type-argument)
279 (should-error (length (dot2 1 2)) :type 'wrong-type-argument))
280
281(ert-deftest test-cycle-safe-length ()
282 (should (<= 10 (safe-length (cyc1 1))))
283 (should (<= 1010 (safe-length (cyc2 1 2))))
284 (should (= 10 (safe-length (dot1 1))))
285 (should (= 20 (safe-length (dot2 1 2)))))
286
287(ert-deftest test-cycle-member ()
288 (let ((c1 (cyc1 1))
289 (c2 (cyc2 1 2))
290 (d1 (dot1 1))
291 (d2 (dot2 1 2)))
292 (should (member 1 c1))
293 (should (member 1 c2))
294 (should (member 1 d1))
295 (should (member 1 d2))
296 (should-error (member 2 c1) :type 'circular-list)
297 (should (member 2 c2))
298 (should-error (member 2 d1) :type 'wrong-type-argument)
299 (should (member 2 d2))
300 (should-error (member 3 c1) :type 'circular-list)
301 (should-error (member 3 c2) :type 'circular-list)
302 (should-error (member 3 d1) :type 'wrong-type-argument)
303 (should-error (member 3 d2) :type 'wrong-type-argument)))
304
305(ert-deftest test-cycle-memq ()
306 (let ((c1 (cyc1 1))
307 (c2 (cyc2 1 2))
308 (d1 (dot1 1))
309 (d2 (dot2 1 2)))
310 (should (memq 1 c1))
311 (should (memq 1 c2))
312 (should (memq 1 d1))
313 (should (memq 1 d2))
314 (should-error (memq 2 c1) :type 'circular-list)
315 (should (memq 2 c2))
316 (should-error (memq 2 d1) :type 'wrong-type-argument)
317 (should (memq 2 d2))
318 (should-error (memq 3 c1) :type 'circular-list)
319 (should-error (memq 3 c2) :type 'circular-list)
320 (should-error (memq 3 d1) :type 'wrong-type-argument)
321 (should-error (memq 3 d2) :type 'wrong-type-argument)))
322
323(ert-deftest test-cycle-memql ()
324 (let ((c1 (cyc1 1))
325 (c2 (cyc2 1 2))
326 (d1 (dot1 1))
327 (d2 (dot2 1 2)))
328 (should (memql 1 c1))
329 (should (memql 1 c2))
330 (should (memql 1 d1))
331 (should (memql 1 d2))
332 (should-error (memql 2 c1) :type 'circular-list)
333 (should (memql 2 c2))
334 (should-error (memql 2 d1) :type 'wrong-type-argument)
335 (should (memql 2 d2))
336 (should-error (memql 3 c1) :type 'circular-list)
337 (should-error (memql 3 c2) :type 'circular-list)
338 (should-error (memql 3 d1) :type 'wrong-type-argument)
339 (should-error (memql 3 d2) :type 'wrong-type-argument)))
340
341(ert-deftest test-cycle-assq ()
342 (let ((c1 (cyc1 '(1)))
343 (c2 (cyc2 '(1) '(2)))
344 (d1 (dot1 '(1)))
345 (d2 (dot2 '(1) '(2))))
346 (should (assq 1 c1))
347 (should (assq 1 c2))
348 (should (assq 1 d1))
349 (should (assq 1 d2))
350 (should-error (assq 2 c1) :type 'circular-list)
351 (should (assq 2 c2))
352 (should-error (assq 2 d1) :type 'wrong-type-argument)
353 (should (assq 2 d2))
354 (should-error (assq 3 c1) :type 'circular-list)
355 (should-error (assq 3 c2) :type 'circular-list)
356 (should-error (assq 3 d1) :type 'wrong-type-argument)
357 (should-error (assq 3 d2) :type 'wrong-type-argument)))
358
359(ert-deftest test-cycle-assoc ()
360 (let ((c1 (cyc1 '(1)))
361 (c2 (cyc2 '(1) '(2)))
362 (d1 (dot1 '(1)))
363 (d2 (dot2 '(1) '(2))))
364 (should (assoc 1 c1))
365 (should (assoc 1 c2))
366 (should (assoc 1 d1))
367 (should (assoc 1 d2))
368 (should-error (assoc 2 c1) :type 'circular-list)
369 (should (assoc 2 c2))
370 (should-error (assoc 2 d1) :type 'wrong-type-argument)
371 (should (assoc 2 d2))
372 (should-error (assoc 3 c1) :type 'circular-list)
373 (should-error (assoc 3 c2) :type 'circular-list)
374 (should-error (assoc 3 d1) :type 'wrong-type-argument)
375 (should-error (assoc 3 d2) :type 'wrong-type-argument)))
376
377(ert-deftest test-cycle-rassq ()
378 (let ((c1 (cyc1 '(0 . 1)))
379 (c2 (cyc2 '(0 . 1) '(0 . 2)))
380 (d1 (dot1 '(0 . 1)))
381 (d2 (dot2 '(0 . 1) '(0 . 2))))
382 (should (rassq 1 c1))
383 (should (rassq 1 c2))
384 (should (rassq 1 d1))
385 (should (rassq 1 d2))
386 (should-error (rassq 2 c1) :type 'circular-list)
387 (should (rassq 2 c2))
388 (should-error (rassq 2 d1) :type 'wrong-type-argument)
389 (should (rassq 2 d2))
390 (should-error (rassq 3 c1) :type 'circular-list)
391 (should-error (rassq 3 c2) :type 'circular-list)
392 (should-error (rassq 3 d1) :type 'wrong-type-argument)
393 (should-error (rassq 3 d2) :type 'wrong-type-argument)))
394
395(ert-deftest test-cycle-rassoc ()
396 (let ((c1 (cyc1 '(0 . 1)))
397 (c2 (cyc2 '(0 . 1) '(0 . 2)))
398 (d1 (dot1 '(0 . 1)))
399 (d2 (dot2 '(0 . 1) '(0 . 2))))
400 (should (rassoc 1 c1))
401 (should (rassoc 1 c2))
402 (should (rassoc 1 d1))
403 (should (rassoc 1 d2))
404 (should-error (rassoc 2 c1) :type 'circular-list)
405 (should (rassoc 2 c2))
406 (should-error (rassoc 2 d1) :type 'wrong-type-argument)
407 (should (rassoc 2 d2))
408 (should-error (rassoc 3 c1) :type 'circular-list)
409 (should-error (rassoc 3 c2) :type 'circular-list)
410 (should-error (rassoc 3 d1) :type 'wrong-type-argument)
411 (should-error (rassoc 3 d2) :type 'wrong-type-argument)))
412
413(ert-deftest test-cycle-delq ()
414 (should-error (delq 1 (cyc1 1)) :type 'circular-list)
415 (should-error (delq 1 (cyc2 1 2)) :type 'circular-list)
416 (should-error (delq 1 (dot1 1)) :type 'wrong-type-argument)
417 (should-error (delq 1 (dot2 1 2)) :type 'wrong-type-argument)
418 (should-error (delq 2 (cyc1 1)) :type 'circular-list)
419 (should-error (delq 2 (cyc2 1 2)) :type 'circular-list)
420 (should-error (delq 2 (dot1 1)) :type 'wrong-type-argument)
421 (should-error (delq 2 (dot2 1 2)) :type 'wrong-type-argument)
422 (should-error (delq 3 (cyc1 1)) :type 'circular-list)
423 (should-error (delq 3 (cyc2 1 2)) :type 'circular-list)
424 (should-error (delq 3 (dot1 1)) :type 'wrong-type-argument)
425 (should-error (delq 3 (dot2 1 2)) :type 'wrong-type-argument))
426
427(ert-deftest test-cycle-delete ()
428 (should-error (delete 1 (cyc1 1)) :type 'circular-list)
429 (should-error (delete 1 (cyc2 1 2)) :type 'circular-list)
430 (should-error (delete 1 (dot1 1)) :type 'wrong-type-argument)
431 (should-error (delete 1 (dot2 1 2)) :type 'wrong-type-argument)
432 (should-error (delete 2 (cyc1 1)) :type 'circular-list)
433 (should-error (delete 2 (cyc2 1 2)) :type 'circular-list)
434 (should-error (delete 2 (dot1 1)) :type 'wrong-type-argument)
435 (should-error (delete 2 (dot2 1 2)) :type 'wrong-type-argument)
436 (should-error (delete 3 (cyc1 1)) :type 'circular-list)
437 (should-error (delete 3 (cyc2 1 2)) :type 'circular-list)
438 (should-error (delete 3 (dot1 1)) :type 'wrong-type-argument)
439 (should-error (delete 3 (dot2 1 2)) :type 'wrong-type-argument))
440
441(ert-deftest test-cycle-reverse ()
442 (should-error (reverse (cyc1 1)) :type 'circular-list)
443 (should-error (reverse (cyc2 1 2)) :type 'circular-list)
444 (should-error (reverse (dot1 1)) :type 'wrong-type-argument)
445 (should-error (reverse (dot2 1 2)) :type 'wrong-type-argument))
446
447(ert-deftest test-cycle-plist-get ()
448 (let ((c1 (cyc1 1))
449 (c2 (cyc2 1 2))
450 (d1 (dot1 1))
451 (d2 (dot2 1 2)))
452 (should (plist-get c1 1))
453 (should (plist-get c2 1))
454 (should (plist-get d1 1))
455 (should (plist-get d2 1))
456 (should-not (plist-get c1 2))
457 (should (plist-get c2 2))
458 (should-not (plist-get d1 2))
459 (should (plist-get d2 2))
460 (should-not (plist-get c1 3))
461 (should-not (plist-get c2 3))
462 (should-not (plist-get d1 3))
463 (should-not (plist-get d2 3))))
464
465(ert-deftest test-cycle-lax-plist-get ()
466 (let ((c1 (cyc1 1))
467 (c2 (cyc2 1 2))
468 (d1 (dot1 1))
469 (d2 (dot2 1 2)))
470 (should (lax-plist-get c1 1))
471 (should (lax-plist-get c2 1))
472 (should (lax-plist-get d1 1))
473 (should (lax-plist-get d2 1))
474 (should-error (lax-plist-get c1 2) :type 'circular-list)
475 (should (lax-plist-get c2 2))
476 (should-not (lax-plist-get d1 2))
477 (should (lax-plist-get d2 2))
478 (should-error (lax-plist-get c1 3) :type 'circular-list)
479 (should-error (lax-plist-get c2 3) :type 'circular-list)
480 (should-not (lax-plist-get d1 3))
481 (should-not (lax-plist-get d2 3))))
482
483(ert-deftest test-cycle-plist-member ()
484 (let ((c1 (cyc1 1))
485 (c2 (cyc2 1 2))
486 (d1 (dot1 1))
487 (d2 (dot2 1 2)))
488 (should (plist-member c1 1))
489 (should (plist-member c2 1))
490 (should (plist-member d1 1))
491 (should (plist-member d2 1))
492 (should-error (plist-member c1 2) :type 'circular-list)
493 (should (plist-member c2 2))
494 (should-error (plist-member d1 2) :type 'wrong-type-argument)
495 (should (plist-member d2 2))
496 (should-error (plist-member c1 3) :type 'circular-list)
497 (should-error (plist-member c2 3) :type 'circular-list)
498 (should-error (plist-member d1 3) :type 'wrong-type-argument)
499 (should-error (plist-member d2 3) :type 'wrong-type-argument)))
500
501(ert-deftest test-cycle-plist-put ()
502 (let ((c1 (cyc1 1))
503 (c2 (cyc2 1 2))
504 (d1 (dot1 1))
505 (d2 (dot2 1 2)))
506 (should (plist-put c1 1 1))
507 (should (plist-put c2 1 1))
508 (should (plist-put d1 1 1))
509 (should (plist-put d2 1 1))
510 (should-error (plist-put c1 2 2) :type 'circular-list)
511 (should (plist-put c2 2 2))
512 (should (plist-put d1 2 2))
513 (should (plist-put d2 2 2))
514 (should-error (plist-put c1 3 3) :type 'circular-list)
515 (should-error (plist-put c2 3 3) :type 'circular-list)
516 (should (plist-put d1 3 3))
517 (should (plist-put d2 3 3))))
518
519(ert-deftest test-cycle-lax-plist-put ()
520 (let ((c1 (cyc1 1))
521 (c2 (cyc2 1 2))
522 (d1 (dot1 1))
523 (d2 (dot2 1 2)))
524 (should (lax-plist-put c1 1 1))
525 (should (lax-plist-put c2 1 1))
526 (should (lax-plist-put d1 1 1))
527 (should (lax-plist-put d2 1 1))
528 (should-error (lax-plist-put c1 2 2) :type 'circular-list)
529 (should (lax-plist-put c2 2 2))
530 (should (lax-plist-put d1 2 2))
531 (should (lax-plist-put d2 2 2))
532 (should-error (lax-plist-put c1 3 3) :type 'circular-list)
533 (should-error (lax-plist-put c2 3 3) :type 'circular-list)
534 (should (lax-plist-put d1 3 3))
535 (should (lax-plist-put d2 3 3))))
536
537(ert-deftest test-cycle-equal ()
538 (should-error (equal (cyc1 1) (cyc1 1)))
539 (should-error (equal (cyc2 1 2) (cyc2 1 2))))
540
541(ert-deftest test-cycle-nconc ()
542 (should-error (nconc (cyc1 1) 'tail) :type 'circular-list)
543 (should-error (nconc (cyc2 1 2) 'tail) :type 'circular-list))
544
545(provide 'fns-tests)