count.lsp 17.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Mon Aug 19 07:31:55 2002
;;;; Contains: Tests for COUNT

(in-package :cl-test)

(deftest count-list.1
  (count 'a '(a b c d e a e f))
  2)

(deftest count-list.2
13
  (count 'a '(a b c d e a e f) :test #'eql)
14 15 16
  2)

(deftest count-list.3
17
  (count 'a '(a b c d e a e f) :test 'eql)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
  2)

(deftest count-list.4
  (count 1 '(1 2 2 3 2 1 2 2 5 4) :key #'1-)
  5)

(deftest count-list.5
  (count 1 '(1 2 2 3 2 1 2 2 5 4) :key '1-)
  5)

(deftest count-list.6
  (count 1 '(1 2 2 3 2 1 2 2 5 4) :key #'1- :test #'equal)
  5)

(deftest count-list.7
  (count 1 '(2 1 1 2 3 1 4 1 7 6 1 8) :from-end t)
  5)

(deftest count-list.8
  (let ((c 0))
    (count 1 '(1 2 3 1 4 1 7 6 1 8)
sds's avatar
sds committed
39 40 41
           :key #'(lambda (x)
                    ;; (format t "~%~A ~A" x c)
                    (prog1 (- x c) (incf c)))))
42 43 44 45 46
  4)

(deftest count-list.9
  (let ((c 0))
    (count 1 '(1 2 3 7 4 5 7 6 2 8)
sds's avatar
sds committed
47 48 49 50
           :from-end t
           :key #'(lambda (x)
                    ;; (format t "~%~A ~A" x c)
                    (prog1 (- x c) (incf c)))))
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
  3)

(deftest count-list.10
  (count 1 '(1 1 1 1 1 2 1 1) :start 3)
  4)

(deftest count-list.11
  (count 1 '(1 1 1 1 1 2 1 1) :end 6)
  5)

(deftest count-list.12
  (count 1 '(1 1 1 1 1 2 1 1) :start 2 :end 7)
  4)

(deftest count-list.13
  (count 1 '(1 1 1 1 1 2 1 1) :start 3 :end nil)
  4)

(deftest count-list.14
  (count 1 '(1 1 1 1 1 2 1 1)  :end nil)
  7)

(deftest count-list.15
74
  (count 1 '(1 1 1 1 1 2 1 1)  :test-not #'eql)
75 76 77 78
  1)

(deftest count-list.16
  (count 1 '(1 1 1 3 1 2 1 1) :start 2 :end 7
sds's avatar
sds committed
79
         :test #'(lambda (x y) (declare (ignore x y))  t))
80 81
  5)

82 83 84 85 86 87 88 89
(deftest count-list.17
  (count 10 '(1 11 2 4 14 5 18 6 7) :test #'<)
  3)

(deftest count-list.18
  (count 10 '(1 11 2 4 14 5 18 6 7) :test-not #'>=)
  3)

90 91 92 93 94 95
(defharmless count-list.test-and-test-not.1
  (count 0 '(0 1 2 0 1 2 3 0 1) :test #'eql :test-not #'eql))

(defharmless count-list.test-and-test-not.2
  (count 0 '(0 1 2 0 1 2 3 0 1) :test-not #'eql :test #'eql))

96 97 98 99 100 101 102
;;; On vectors

(deftest count-vector.1
  (count 'a #(a b c d e a e f))
  2)

(deftest count-vector.2
103
  (count 'a #(a b c d e a e f) :test #'eql)
104 105 106
  2)

(deftest count-vector.3
107
  (count 'a #(a b c d e a e f) :test 'eql)
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
  2)

(deftest count-vector.4
  (count 1 #(1 2 2 3 2 1 2 2 5 4) :key #'1-)
  5)

(deftest count-vector.5
  (count 1 #(1 2 2 3 2 1 2 2 5 4) :key '1-)
  5)

(deftest count-vector.6
  (count 1 #(1 2 2 3 2 1 2 2 5 4) :key #'1- :test #'equal)
  5)

(deftest count-vector.7
  (count 1 #(2 1 1 2 3 1 4 1 7 6 1 8) :from-end t)
  5)

(deftest count-vector.8
  (let ((c 0))
    (count 1 #(1 2 3 1 4 1 7 6 1 8)
sds's avatar
sds committed
129 130 131
           :key #'(lambda (x)
                    ;; (format t "~%~A ~A" x c)
                    (prog1 (- x c) (incf c)))))
132 133 134 135 136
  4)

(deftest count-vector.9
  (let ((c 0))
    (count 1 #(1 2 3 7 4 5 7 6 2 8)
sds's avatar
sds committed
137 138 139 140
           :from-end t
           :key #'(lambda (x)
                    ;; (format t "~%~A ~A" x c)
                    (prog1 (- x c) (incf c)))))
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
  3)

(deftest count-vector.10
  (count 1 #(1 1 1 1 1 2 1 1) :start 3)
  4)

(deftest count-vector.11
  (count 1 #(1 1 1 1 1 2 1 1) :end 6)
  5)

(deftest count-vector.12
  (count 1 #(1 1 1 1 1 2 1 1) :start 2 :end 7)
  4)

(deftest count-vector.13
  (count 1 #(1 1 1 1 1 2 1 1) :start 3 :end nil)
  4)

(deftest count-vector.14
  (count 1 #(1 1 1 1 1 2 1 1)  :end nil)
  7)

(deftest count-vector.15
164
  (count 1 #(1 1 1 1 1 2 1 1)  :test-not #'eql)
165 166
  1)

167
(deftest count-vector.16
168
  (count 1 #(1 1 1 3 1 2 1 1) :start 2 :end 7
sds's avatar
sds committed
169
         :test #'(lambda (x y) (declare (ignore x y)) t))
170 171
  5)

172 173 174 175 176 177 178 179
(deftest count-vector.17
  (count 10 #(1 11 2 4 14 5 18 6 7) :test #'<)
  3)

(deftest count-vector.18
  (count 10 #(1 11 2 4 14 5 18 6 7) :test-not #'>=)
  3)

180 181 182 183 184 185
(defharmless count-vector.test-and-test-not.1
  (count 0 #(0 1 2 0 1 2 3 0 1) :test #'eql :test-not #'eql))

(defharmless count-vector.test-and-test-not.2
  (count 0 #(0 1 2 0 1 2 3 0 1) :test-not #'eql :test #'eql))

186 187 188 189
;;; Non-simple vectors

(deftest count-filled-vector.1
  (count 'a (make-array 8 :initial-contents '(a b c d e a e f)
sds's avatar
sds committed
190
                        :fill-pointer t))
191 192 193 194
  2)

(deftest count-filled-vector.2
  (count 'a (make-array 8 :initial-contents '(a b c d e a e f)
sds's avatar
sds committed
195 196
                        :fill-pointer t)
         :test #'eql)
197 198 199 200
  2)

(deftest count-filled-vector.3
  (count 'a (make-array 8 :initial-contents '(a b c d e a e f)
sds's avatar
sds committed
201 202
                        :fill-pointer t)
         :test 'eql)
203 204 205 206
  2)

(deftest count-filled-vector.4
  (count 1 (make-array 10 :initial-contents '(1 2 2 3 2 1 2 2 5 4)
sds's avatar
sds committed
207 208
                       :fill-pointer t)
         :key #'1-)
209 210 211 212
  5)

(deftest count-filled-vector.5
  (count 1 (make-array 10 :initial-contents '(1 2 2 3 2 1 2 2 5 4)
sds's avatar
sds committed
213 214
                       :fill-pointer t)
         :key '1-)
215 216 217 218
  5)

(deftest count-filled-vector.6
  (count 1 (make-array 10 :initial-contents '(1 2 2 3 2 1 2 2 5 4)
sds's avatar
sds committed
219 220
                       :fill-pointer t)
         :key #'1- :test #'equal)
221 222 223 224
  5)

(deftest count-filled-vector.7
  (count 1 (make-array 12 :initial-contents '(2 1 1 2 3 1 4 1 7 6 1 8)
sds's avatar
sds committed
225 226
                       :fill-pointer t)
         :from-end t)
227 228 229 230 231
  5)

(deftest count-filled-vector.8
  (let ((c 0))
    (count 1 (make-array 10 :initial-contents '(1 2 3 1 4 1 7 6 1 8)
sds's avatar
sds committed
232 233 234 235
                         :fill-pointer t)
           :key #'(lambda (x)
                    ;; (format t "~%~A ~A" x c)
                    (prog1 (- x c) (incf c)))))
236 237 238 239 240
  4)

(deftest count-filled-vector.9
  (let ((c 0))
    (count 1 (make-array 10 :initial-contents '(1 2 3 7 4 5 7 6 2 8)
sds's avatar
sds committed
241 242 243 244 245
                         :fill-pointer t)
           :from-end t
           :key #'(lambda (x)
                    ;; (format t "~%~A ~A" x c)
                    (prog1 (- x c) (incf c)))))
246 247 248 249
  3)

(deftest count-filled-vector.10
  (count 1 (make-array 8 :initial-contents '(1 1 1 1 1 2 1 1)
sds's avatar
sds committed
250 251
                       :fill-pointer t)
         :start 3)
252 253 254 255
  4)

(deftest count-filled-vector.11
  (count 1 (make-array 8 :initial-contents '(1 1 1 1 1 2 1 1)
sds's avatar
sds committed
256 257
                       :fill-pointer t)
         :end 6)
258 259 260 261
  5)

(deftest count-filled-vector.12
  (count 1 (make-array 8 :initial-contents '(1 1 1 1 1 2 1 1)
sds's avatar
sds committed
262 263
                       :fill-pointer t)
         :start 2 :end 7)
264 265 266 267
  4)

(deftest count-filled-vector.13
  (count 1 (make-array 8 :initial-contents '(1 1 1 1 1 2 1 1)
sds's avatar
sds committed
268 269
                       :fill-pointer t)
         :start 3 :end nil)
270 271 272 273
  4)

(deftest count-filled-vector.14
  (count 1 (make-array 8 :initial-contents '(1 1 1 1 1 2 1 1)
sds's avatar
sds committed
274 275
                       :fill-pointer t)
         :end nil)
276 277 278 279
  7)

(deftest count-filled-vector.15
  (count 1 (make-array 8 :initial-contents '(1 1 1 1 1 2 1 1)
sds's avatar
sds committed
280 281
                       :fill-pointer t)
         :test-not #'eql)
282 283 284 285
  1)

(deftest count-filled-vector.16
  (count 1 (make-array 8 :initial-contents '(1 1 1 3 1 2 1 1)
sds's avatar
sds committed
286 287 288
                       :fill-pointer t)
         :start 2 :end 7
         :test #'(lambda (x y) (declare (ignore x y)) t))
289 290
  5)

291 292
(deftest count-filled-vector.17
  (count 1 (make-array 8 :initial-contents '(1 1 1 1 1 1 1 1)
sds's avatar
sds committed
293
                       :fill-pointer 6))
294 295 296 297
  6)

(deftest count-filled-vector.18
  (count 1 (make-array 8 :initial-contents '(1 1 1 1 1 1 1 1)
sds's avatar
sds committed
298 299
                       :fill-pointer 6)
         :start 2)
300 301 302
  4)
(deftest count-filled-vector.19
  (count 1 (make-array 8 :initial-contents '(1 1 1 1 1 1 1 1)
sds's avatar
sds committed
303 304
                       :fill-pointer 6)
         :from-end 'foo)
305 306 307 308
  6)

(deftest count-filled-vector.20
  (count 1 (make-array 8 :initial-contents '(1 1 1 1 1 1 1 1)
sds's avatar
sds committed
309 310
                       :fill-pointer 6)
         :start 2 :from-end 'yes)
311 312
  4)

313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
;;; Other specialized vectors

(deftest count.special-vector.1
  (do-special-integer-vectors
   (v #(0 1 1 0 1 1 1 0 1 1 1 1 0) nil)
   (assert (eql (count 0 v) 4))
   (assert (eql (count 1 v) 9))
   (assert (eql (count 2 v) 0))
   (assert (eql (count 0 v :start 2) 3))
   (assert (eql (count 1 v :end 11) 8)))
  nil)

(deftest count.special-vector.2
  (do-special-integer-vectors
   (v #(1 2 3 4 5 6 7) nil)
   (assert (eql (count 0 v) 0))
   (assert (eql (count 1 v) 1))
   (assert (eql (count 2 v) 1))
   (assert (eql (count 3 v) 1))
   (assert (eql (count 4 v) 1))
   (assert (eql (count 5 v) 1))
   (assert (eql (count 6 v) 1))
   (assert (eql (count 7 v) 1)))
  nil)

(deftest count.special-vector.3
  (loop for etype in '(short-float single-float double-float long-float)
sds's avatar
sds committed
340 341 342 343 344 345
        for vals = (loop for e in '(0 1 2 1 3 1 4 5 6 0)
                         collect (coerce e etype))
        for vec = (make-array (length vals) :element-type etype :initial-contents vals)
        for result = (count (coerce 1 etype) vec)
        unless (= result 3)
        collect (list etype vals vec result))
346 347 348 349
  nil)

(deftest count.special-vector.4
  (loop for cetype in '(short-float single-float double-float long-float rational integer)
sds's avatar
sds committed
350 351 352 353 354 355 356
        for etype = `(complex ,cetype)
        for vals = (loop for e in '(4 1 2 1 3 1 4 5 6 6)
                         collect (complex 0 (coerce e cetype)))
        for vec = (make-array (length vals) :element-type etype :initial-contents vals)
        for result = (count (complex 0 (coerce 1 cetype)) vec)
        unless (= result 3)
        collect (list etype vals vec result))
357 358
  nil)

359 360


361 362 363 364 365 366 367
;;; Tests on bit vectors

(deftest count-bit-vector.1
  (count 1 #*00101100011011000)
  7)

(deftest count-bit-vector.2
368
  (count 1 #*00101100011011000 :test #'eql)
369 370 371
  7)

(deftest count-bit-vector.3
372
  (count 1 #*00101100011011000 :test 'eql)
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
  7)

(deftest count-bit-vector.4
  (count 1 #*00101100011011000 :key #'1+)
  10)

(deftest count-bit-vector.5
  (count 0 #*00101100011011000 :key '1-)
  7)

(deftest count-bit-vector.6
  (count 0 #*00101100011011000 :key #'1- :test #'equal)
  7)

(deftest count-bit-vector.7
  (count 1 #*00101100011011000 :from-end t)
  7)

(deftest count-bit-vector.8
  (let ((c 1))
    (count 0 #*0000110101001
sds's avatar
sds committed
394
           :key #'(lambda (x) (setf c (- c)) (+ c x))))
395 396 397 398 399
  2)

(deftest count-bit-vector.9
  (let ((c 1))
    (count 0 #*0000011010101
sds's avatar
sds committed
400 401
           :from-end t
           :key #'(lambda (x) (setf c (- c)) (+ c x))))
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
  4)

(deftest count-bit-vector.10
  (count 1 #*11000110110 :start 3)
  4)

(deftest count-bit-vector.11
  (count 1 '#*110111110111 :end 6)
  5)

(deftest count-bit-vector.12
  (count 1 #*11111011 :start 2 :end 7)
  4)

(deftest count-bit-vector.13
  (count 1 #*11111011 :start 3 :end nil)
  4)

(deftest count-bit-vector.14
  (count 1 #*11111011 :end nil)
  7)

(deftest count-bit-vector.15
425
  (count 1 #*11111011  :test-not #'eql)
426 427 428 429
  1)

(deftest count-bit-vector.16
  (count 1 #*11101101 :start 2 :end 7
sds's avatar
sds committed
430
         :test #'(lambda (x y) (declare (ignore x y)) t))
431 432
  5)

433 434
(deftest count-bit-vector.17
  (count 1 (make-array 8 :initial-contents '(1 0 1 1 1 1 1 1)
sds's avatar
sds committed
435 436
                       :element-type 'bit
                       :fill-pointer 5))
437 438 439 440
  4)

(deftest count-bit-vector.18
  (count 1 (make-array 8 :initial-contents '(1 0 1 1 1 1 1 1)
sds's avatar
sds committed
441 442 443
                       :element-type 'bit
                       :fill-pointer 5)
         :start 1)
444 445 446 447
  3)

(deftest count-bit-vector.19
  (count 1 (make-array 8 :initial-contents '(1 0 1 1 1 1 1 1)
sds's avatar
sds committed
448 449 450
                       :element-type 'bit
                       :fill-pointer 5)
         :end nil)
451 452 453 454 455
  4)


(deftest count-bit-vector.20
  (count 1 (make-array 8 :initial-contents '(1 0 1 1 1 1 1 1)
sds's avatar
sds committed
456 457 458
                       :element-type 'bit
                       :fill-pointer 6)
         :end 4)
459 460
  3)

461 462 463 464 465 466 467
(deftest count-bit-vector.21
  (count 1 #*00001100100 :test #'<=)
  3)

(deftest count-bit-vector.22
  (count 1 #*00001100100 :test-not #'>)
  3)
468

469 470 471 472 473 474
(defharmless count-bit-vector.test-and-test-not.1
  (count 0 #*0011010101100010000 :test #'eql :test-not #'eql))

(defharmless count-bit-vector.test-and-test-not.2
  (count 0 #*0011010101100010000 :test-not #'eql :test #'eql))

475 476 477 478 479 480 481
;;; Tests on strings

(deftest count-string.1
  (count #\1 "00101100011011000")
  7)

(deftest count-string.2
482
  (count #\1 "00101100011011000" :test #'eql)
483 484 485
  7)

(deftest count-string.3
486
  (count #\1 "00101100011011000" :test 'eql)
487 488 489
  7)

(deftest count-string.4
490
  (count #\1 "00101100011011000" :key #'(lambda (x) (if (eql x #\0) #\1 #\2)))
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
  10)

(deftest count-string.5
  (count #\1 "00101100011011000" :key 'identity)
  7)

(deftest count-string.6
  (count #\1 "00101100011011000" :key #'identity :test #'equal)
  7)

(deftest count-string.7
  (count #\1 "00101100011011000" :from-end t)
  7)

(deftest count-string.8
  (let ((c nil))
    (count #\0 "0000110101001"
sds's avatar
sds committed
508 509
           :key #'(lambda (x) (setf c (not c))
                    (and c x))))
510 511 512 513 514
  5)

(deftest count-string.9
  (let ((c nil))
    (count #\0 "0000011010101"
sds's avatar
sds committed
515 516 517
           :from-end t
           :key #'(lambda (x) (setf c (not c))
                    (and c x))))
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540
  3)

(deftest count-string.10
  (count #\1 "11000110110" :start 3)
  4)

(deftest count-string.11
  (count #\1 '"110111110111" :end 6)
  5)

(deftest count-string.12
  (count #\1 "11111011" :start 2 :end 7)
  4)

(deftest count-string.13
  (count #\1 "11111011" :start 3 :end nil)
  4)

(deftest count-string.14
  (count #\1 "11111011" :end nil)
  7)

(deftest count-string.15
541
  (count #\1 "11111011"  :test-not #'eql)
542 543 544 545
  1)

(deftest count-string.16
  (count #\1 "11101101" :start 2 :end 7
sds's avatar
sds committed
546
         :test #'(lambda (x y) (declare (ignore x y)) t))
547 548
  5)

549
(deftest count-string.17
550
  (count #\a (make-array 10 :initial-contents "abaaacaaaa"
sds's avatar
sds committed
551 552
                         :fill-pointer 7
                         :element-type 'character))
553 554 555
  5)

(deftest count-string.18
556
  (count #\a (make-array 10 :initial-contents "abaaacaaaa"
sds's avatar
sds committed
557 558 559
                         :fill-pointer 7
                         :element-type 'character)
         :start 1)
560 561 562
  4)

(deftest count-string.19
563
  (count #\a (make-array 10 :initial-contents "abaaacaaaa"
sds's avatar
sds committed
564 565 566
                         :fill-pointer 7
                         :element-type 'character)
         :end nil)
567 568 569
  5)

(deftest count-string.20
570
  (count #\a (make-array 10 :initial-contents "abaaacaaaa"
sds's avatar
sds committed
571 572 573
                         :fill-pointer 7
                         :element-type 'character)
         :start 2 :end 5)
574 575
  3)

576 577 578 579 580 581 582 583
(deftest count-string.21
  (count #\1 "00001100100" :test #'char<=)
  3)

(deftest count-string.22
  (count #\1 "00001100100" :test-not #'char>)
  3)

584 585 586 587 588 589
(deftest count-string.23
  (do-special-strings
   (s "a1a3abcda" nil)
   (assert (= (count #\a s) 4)))
  nil)

590 591 592 593 594 595
(defharmless count-string.test-and-test-not.1
  (count #\0 "0011010101100010000" :test #'eql :test-not #'eql))

(defharmless count-string.test-and-test-not.2
  (count #\0 "0011010101100010000" :test-not #'eql :test #'eql))

596 597
;;; Argument order tests

598
(deftest count.order.1
599 600 601
  (let ((i 0) c1 c2 c3 c4 c5 c6 c7)
    (values
     (count (progn (setf c1 (incf i)) nil)
sds's avatar
sds committed
602 603 604 605 606 607 608
            (progn (setf c2 (incf i)) '(a nil b c nil d e))
            :start (progn (setf c3 (incf i)) 0)
            :end (progn (setf c4 (incf i)) 3)
            :key (progn (setf c5 (incf i)) #'identity)
            :from-end (progn (setf c6 (incf i)) nil)
            :test (progn (setf c7 (incf i)) #'eql)
            )
609 610 611
     i c1 c2 c3 c4 c5 c6 c7))
  1 7 1 2 3 4 5 6 7)

612
(deftest count.order.2
613 614 615
  (let ((i 0) c1 c2 c3 c4 c5 c6 c7)
    (values
     (count (progn (setf c1 (incf i)) nil)
sds's avatar
sds committed
616 617 618 619 620 621 622
            (progn (setf c2 (incf i)) '(a nil b c nil d e))
            :test (progn (setf c3 (incf i)) #'eql)
            :from-end (progn (setf c4 (incf i)) nil)
            :key (progn (setf c5 (incf i)) #'identity)
            :end (progn (setf c6 (incf i)) 3)
            :start (progn (setf c7 (incf i)) 0)
            )
623 624 625 626
     i c1 c2 c3 c4 c5 c6 c7))
  1 7 1 2 3 4 5 6 7)


627
;;; Keyword tests
628 629 630 631 632 633 634 635 636 637 638 639

(deftest count.allow-other-keys.1
  (count 'a '(b a d a c) :bad t :allow-other-keys t)
  2)

(deftest count.allow-other-keys.2
  (count 'a '(b a d a c) :allow-other-keys #p"*" :also-bad t)
  2)

;;; The leftmost of two :allow-other-keys arguments is the one that  matters.
(deftest count.allow-other-keys.3
  (count 'a '(b a d a c)
sds's avatar
sds committed
640 641 642
         :allow-other-keys t
         :allow-other-keys nil
         :bad t)
643 644
  2)

645
(deftest count.keywords.4
646 647 648 649 650 651 652
  (count 2 '(1 2 3 2 5) :key #'identity :key #'1+)
  2)

(deftest count.allow-other-keys.5
  (count 'a '(a b c a) :allow-other-keys nil)
  2)

653 654
;;; Error tests

655
(deftest count.error.1
656 657
  (check-type-error #'(lambda (x) (count 'a x)) #'sequencep)
  nil)
658

659
(deftest count.error.4
660 661
  (signals-error (count) program-error)
  t)
662 663

(deftest count.error.5
664 665
  (signals-error (count nil) program-error)
  t)
666 667

(deftest count.error.6
668 669
  (signals-error (count nil nil :bad t) program-error)
  t)
670 671

(deftest count.error.7
672
  (signals-error (count nil nil :bad t :allow-other-keys nil)
sds's avatar
sds committed
673
                 program-error)
674
  t)
675 676

(deftest count.error.8
677 678
  (signals-error (count nil nil :key) program-error)
  t)
679 680

(deftest count.error.9
681 682
  (signals-error (count nil nil 3 3) program-error)
  t)
683

684 685
;;; Only leftmost :allow-other-keys argument matters
(deftest count.error.10
686
  (signals-error (count 'a nil :bad t
sds's avatar
sds committed
687 688 689
                         :allow-other-keys nil
                         :allow-other-keys t)
                 program-error)
690
  t)
691 692

(deftest count.error.11
693 694
  (signals-error (locally (count 'a 1) t) type-error)
  t)
695

696
(deftest count.error.12
697
  (signals-error (count 'b '(a b c) :test #'identity)
sds's avatar
sds committed
698
                 program-error)
699
  t)
700 701

(deftest count.error.13
702 703
  (signals-error (count 'b '(a b c) :key #'car) type-error)
  t)
704 705

(deftest count.error.14
706
  (signals-error (count 'b '(a b c) :test-not #'identity)
sds's avatar
sds committed
707
                 program-error)
708
  t)
709 710

(deftest count.error.15
711
  (signals-error (count 'b '(a b c) :key #'cons)
sds's avatar
sds committed
712
                 program-error)
713
  t)