Commit 015f0fda authored by pfdietz's avatar pfdietz

Added tests for :allow-other-keys processing in COUNT, COUNT-IF, COUNT-IF-NOT and FILL.

parent 6f4c0e0b
......@@ -418,6 +418,32 @@
(count-if-not #'%onep a :from-end t)))))
2 3 2 3)
;;; Allow-other-keys tests
(deftest count-if-not.keywords.1
(count-if-not #'oddp '(1 2 3 4 5) :bad t :allow-other-keys t)
2)
(deftest count-if-not.keywords.2
(count-if-not #'oddp '(1 2 3 4 5) :allow-other-keys #p"*" :also-bad t)
2)
;;; The leftmost of two :allow-other-keys arguments is the one that matters.
(deftest count-if-not.keywords.3
(count-if-not #'oddp '(1 2 3 4 5)
:allow-other-keys t
:allow-other-keys nil
:bad t)
2)
(deftest count-if-not.keywords.4
(count-if-not #'oddp '(1 2 3 4 5) :key #'identity :key #'1+)
2)
(deftest count-if-not.allow-other-keys.5
(count-if-not #'null '(nil a b c nil) :allow-other-keys nil)
3)
;;; Error tests
(deftest count-if-not.error.1
......@@ -455,3 +481,11 @@
(deftest count-if-not.error.9
(classify-error (count-if-not #'null nil 3 3))
program-error)
;;; Only leftmost :allow-other-keys argument matters
(deftest count-if-not.error.10
(classify-error (count-if-not #'null nil :bad t
:allow-other-keys nil
:allow-other-keys t))
program-error)
......@@ -416,6 +416,30 @@
(count-if #'digit-char-p s :end 2)
(count-if #'digit-char-p s :start 1 :end 2)))
3 3 2 2 1)
;;; Allow-other-keys tests
(deftest count-if.allow-other-keys.1
(count-if #'evenp '(1 2 3 4 5) :bad t :allow-other-keys t)
2)
(deftest count-if.allow-other-keys.2
(count-if #'evenp '(1 2 3 4 5) :allow-other-keys #p"*" :also-bad t)
2)
;;; The leftmost of two :allow-other-keys arguments is the one that matters.
(deftest count-if.allow-other-keys.3
(count-if #'evenp '(1 2 3 4 5)
:allow-other-keys t
:allow-other-keys nil
:bad t)
2)
(deftest count-if.allow-other-keys.4
(count-if #'evenp '(1 2 3 4 5) :key #'identity :key #'1+)
2)
;;; Error tests
......@@ -454,3 +478,10 @@
(deftest count-if.error.9
(classify-error (count-if #'null nil 3 3))
program-error)
;;; Only leftmost :allow-other-keys argument matters
(deftest count-if.error.10
(classify-error (count-if #'null nil :bad t
:allow-other-keys nil
:allow-other-keys t))
program-error)
......@@ -76,7 +76,7 @@
(deftest count-list.16
(count 1 '(1 1 1 3 1 2 1 1) :start 2 :end 7
:test #'(lambda (x y) t))
:test #'(lambda (x y) (declare (ignore x y)) t))
5)
;;; On vectors
......@@ -152,7 +152,7 @@
(deftest count-vector16
(count 1 #(1 1 1 3 1 2 1 1) :start 2 :end 7
:test #'(lambda (x y) t))
:test #'(lambda (x y) (declare (ignore x y)) t))
5)
;;; Non-simple vectors
......@@ -257,7 +257,7 @@
(count 1 (make-array 8 :initial-contents '(1 1 1 3 1 2 1 1)
:fill-pointer t)
:start 2 :end 7
:test #'(lambda (x y) t))
:test #'(lambda (x y) (declare (ignore x y)) t))
5)
(deftest count-filled-vector.17
......@@ -353,7 +353,7 @@
(deftest count-bit-vector.16
(count 1 #*11101101 :start 2 :end 7
:test #'(lambda (x y) t))
:test #'(lambda (x y) (declare (ignore x y)) t))
5)
(deftest count-bit-vector.17
......@@ -456,7 +456,7 @@
(deftest count-string.16
(count #\1 "11101101" :start 2 :end 7
:test #'(lambda (x y) t))
:test #'(lambda (x y) (declare (ignore x y)) t))
5)
(deftest count-string.17
......@@ -486,6 +486,32 @@
:start 2 :end 5)
3)
;;; Allow-other-keys tests
(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)
:allow-other-keys t
:allow-other-keys nil
:bad t)
2)
(deftest count.allow-other-keys.4
(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)
;;; Error tests
(deftest count.error.1
......@@ -524,3 +550,9 @@
(classify-error (count nil nil 3 3))
program-error)
;;; Only leftmost :allow-other-keys argument matters
(deftest count.error.10
(classify-error (count 'a nil :bad t
:allow-other-keys nil
:allow-other-keys t))
program-error)
......@@ -37,6 +37,11 @@
(classify-error (fill (list 'a 'b) 'c 1 2))
program-error)
(deftest fill.error.10
(classify-error (fill (list 'a 'b) 'c :bad t :allow-other-keys nil
:allow-other-keys t))
program-error)
;;; Fill on arrays
(deftest array-fill-1
......@@ -435,3 +440,36 @@
'bit-vector)))
#*11110000)
;;; Test of :allow-other-keys
(deftest fill.allow-other-keys.1
(fill (list 'a 'b 'c 'd 'e) 'a :allow-other-keys t)
(a a a a a))
(deftest fill.allow-other-keys.2
(fill (list 'a 'b 'c 'd 'e) 'a :allow-other-keys nil)
(a a a a a))
(deftest fill.allow-other-keys.3
(fill (list 'a 'b 'c 'd 'e) 'a :allow-other-keys t :bad t)
(a a a a a))
(deftest fill.allow-other-keys.4
(fill (list 'a 'b 'c 'd 'e) 'a :bad t :allow-other-keys t)
(a a a a a))
(deftest fill.allow-other-keys.5
(fill (list 'a 'b 'c 'd 'e) 'a 'bad t :allow-other-keys t)
(a a a a a))
(deftest fill.allow-other-keys.6
(fill (list 'a 'b 'c 'd 'e) 'a :bad t :allow-other-keys t
:allow-other-keys nil)
(a a a a a))
(deftest fill.allow-other-keys.7
(fill (list 'a 'b 'c 'd 'e) 'a :allow-other-keys t :allow-other-keys nil
:bad t)
(a a a a a))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment