|
|
|
@ -138,22 +138,22 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal '(1 3 4 5 6) (cl-remove 2 list :key #'identity :test #'eql)))
|
|
|
|
|
(should (equal '(1 2 3 4 2) (cl-remove 4 list :test (lambda (a b) (> b a)))))
|
|
|
|
|
(should (equal '(5 6) (cl-remove 4 list :test-not (lambda (a b) (> b a)))))
|
|
|
|
|
(should (equal '(1 3 5) (cl-remove 'foo list :if #'cl-evenp)))
|
|
|
|
|
(should (equal '(2 4 2 6) (cl-remove 'foo list :if-not #'cl-evenp)))
|
|
|
|
|
(should (equal '(1 2 3 4 5) (cl-remove 'foo list :if #'cl-evenp :start 4)))
|
|
|
|
|
(should (equal '(1 3 5) (cl-remove 'foo list :if #'evenp)))
|
|
|
|
|
(should (equal '(2 4 2 6) (cl-remove 'foo list :if-not #'evenp)))
|
|
|
|
|
(should (equal '(1 2 3 4 5) (cl-remove 'foo list :if #'evenp :start 4)))
|
|
|
|
|
(should (equal '(1 2 3 4 5 6) (cl-remove 2 list :start 5 :end 6)))
|
|
|
|
|
(should (equal '(1 3 4 5 2 6) (cl-remove 2 list :count 1)))
|
|
|
|
|
(should (equal '(1 3 4 5 2 6) (cl-remove 2 list :from-end nil :count 1)))
|
|
|
|
|
(should (equal '(1 2 3 4 5 6) (cl-remove 2 list :from-end t :count 1)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-remove-if-test ()
|
|
|
|
|
(should (equal '(1 3) (cl-remove-if #'cl-evenp '(1 2 3 4))))
|
|
|
|
|
(should (equal '(1 3) (cl-remove-if #'cl-evenp '(1 2 3 4) :count 2)))
|
|
|
|
|
(should (equal '(1 3 4) (cl-remove-if #'cl-evenp '(1 2 3 4) :start 1 :end 3)))
|
|
|
|
|
(should (equal '(1 3) (cl-remove-if #'cl-evenp '(1 2 3 4) :from-end t)))
|
|
|
|
|
(should (equal '(2 4) (cl-remove-if #'cl-oddp '(1 2 3 4))))
|
|
|
|
|
(should (equal '() (cl-remove-if #'cl-evenp '())))
|
|
|
|
|
(should (equal '() (cl-remove-if #'cl-evenp '(2)))))
|
|
|
|
|
(should (equal '(1 3) (cl-remove-if #'evenp '(1 2 3 4))))
|
|
|
|
|
(should (equal '(1 3) (cl-remove-if #'evenp '(1 2 3 4) :count 2)))
|
|
|
|
|
(should (equal '(1 3 4) (cl-remove-if #'evenp '(1 2 3 4) :start 1 :end 3)))
|
|
|
|
|
(should (equal '(1 3) (cl-remove-if #'evenp '(1 2 3 4) :from-end t)))
|
|
|
|
|
(should (equal '(2 4) (cl-remove-if #'oddp '(1 2 3 4))))
|
|
|
|
|
(should (equal '() (cl-remove-if #'evenp '())))
|
|
|
|
|
(should (equal '() (cl-remove-if #'evenp '(2)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-lib-test-remove-if-not ()
|
|
|
|
|
(let ((list (list 'a 'b 'c 'd))
|
|
|
|
@ -170,14 +170,14 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(cl-remove-if-not (lambda (_x) (should nil)) '()))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-remove-if-not-test ()
|
|
|
|
|
(should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4))))
|
|
|
|
|
(should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4) :count 2)))
|
|
|
|
|
(should (equal '(1 2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4) :start 1 :end 3)))
|
|
|
|
|
(should (equal '(2 4) (cl-remove-if-not #'cl-evenp '(1 2 3 4) :from-end t)))
|
|
|
|
|
(should (equal '(1 3) (cl-remove-if-not #'cl-oddp '(1 2 3 4))))
|
|
|
|
|
(should (equal '() (cl-remove-if-not #'cl-evenp '())))
|
|
|
|
|
(should (equal '(2) (cl-remove-if-not #'cl-evenp '(2))))
|
|
|
|
|
(should (equal '(2) (cl-remove-if-not #'cl-evenp '(2) :key #'-))))
|
|
|
|
|
(should (equal '(2 4) (cl-remove-if-not #'evenp '(1 2 3 4))))
|
|
|
|
|
(should (equal '(2 4) (cl-remove-if-not #'evenp '(1 2 3 4) :count 2)))
|
|
|
|
|
(should (equal '(1 2 4) (cl-remove-if-not #'evenp '(1 2 3 4) :start 1 :end 3)))
|
|
|
|
|
(should (equal '(2 4) (cl-remove-if-not #'evenp '(1 2 3 4) :from-end t)))
|
|
|
|
|
(should (equal '(1 3) (cl-remove-if-not #'oddp '(1 2 3 4))))
|
|
|
|
|
(should (equal '() (cl-remove-if-not #'evenp '())))
|
|
|
|
|
(should (equal '(2) (cl-remove-if-not #'evenp '(2))))
|
|
|
|
|
(should (equal '(2) (cl-remove-if-not #'evenp '(2) :key #'-))))
|
|
|
|
|
|
|
|
|
|
;; keywords supported: :test :test-not :key :count :start :end :from-end
|
|
|
|
|
(ert-deftest cl-seq-delete-test ()
|
|
|
|
@ -188,9 +188,9 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal '(1 3 4 5 6) (cl-delete 2 l :key #'identity :test #'eql)))
|
|
|
|
|
(should (equal '(1 2 3 4 2) (cl-delete 4 l :test (lambda (a b) (> b a)))))
|
|
|
|
|
(should (equal '(5 6) (cl-delete 4 l :test-not (lambda (a b) (> b a)))))
|
|
|
|
|
(should (equal '(1 3 5) (cl-delete 'foo l :if #'cl-evenp)))
|
|
|
|
|
(should (equal '(2 4 2 6) (cl-delete 'foo l :if-not #'cl-evenp)))
|
|
|
|
|
(should (equal '(1 2 3 4 5) (cl-delete 'foo l :if #'cl-evenp :start 4)))
|
|
|
|
|
(should (equal '(1 3 5) (cl-delete 'foo l :if #'evenp)))
|
|
|
|
|
(should (equal '(2 4 2 6) (cl-delete 'foo l :if-not #'evenp)))
|
|
|
|
|
(should (equal '(1 2 3 4 5) (cl-delete 'foo l :if #'evenp :start 4)))
|
|
|
|
|
(should (equal '(1 2 3 4 5 6) (cl-delete 2 l :start 5 :end 6)))
|
|
|
|
|
(should (equal '(1 3 4 5 2 6) (cl-delete 2 l :count 1)))
|
|
|
|
|
(should (equal '(1 3 4 5 2 6) (cl-delete 2 l :from-end nil :count 1)))
|
|
|
|
@ -198,17 +198,17 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-delete-if-test ()
|
|
|
|
|
(cl-seq-tests--relet* ((l (list 1 2 3 4 5)))
|
|
|
|
|
(should (equal '(1 3 5) (cl-delete-if #'cl-evenp l)))
|
|
|
|
|
(should (equal '(1 3 5) (cl-delete-if #'cl-evenp l :start 0 :end 4)))
|
|
|
|
|
(should (equal '(1 3 5) (cl-delete-if #'cl-evenp l :from-end t)))
|
|
|
|
|
(should (equal '(2 4) (cl-delete-if #'cl-oddp l))))
|
|
|
|
|
(should (equal '() (cl-delete-if #'cl-evenp '())))
|
|
|
|
|
(should (equal '() (cl-delete-if #'cl-evenp (list 2)))))
|
|
|
|
|
(should (equal '(1 3 5) (cl-delete-if #'evenp l)))
|
|
|
|
|
(should (equal '(1 3 5) (cl-delete-if #'evenp l :start 0 :end 4)))
|
|
|
|
|
(should (equal '(1 3 5) (cl-delete-if #'evenp l :from-end t)))
|
|
|
|
|
(should (equal '(2 4) (cl-delete-if #'oddp l))))
|
|
|
|
|
(should (equal '() (cl-delete-if #'evenp '())))
|
|
|
|
|
(should (equal '() (cl-delete-if #'evenp (list 2)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-delete-if-not-test ()
|
|
|
|
|
(should (equal '(2 4) (cl-delete-if-not #'cl-evenp (list 1 2 3 4 5))))
|
|
|
|
|
(should (equal '() (cl-delete-if-not #'cl-evenp '())))
|
|
|
|
|
(should (equal '() (cl-delete-if-not #'cl-evenp (list 1)))))
|
|
|
|
|
(should (equal '(2 4) (cl-delete-if-not #'evenp (list 1 2 3 4 5))))
|
|
|
|
|
(should (equal '() (cl-delete-if-not #'evenp '())))
|
|
|
|
|
(should (equal '() (cl-delete-if-not #'evenp (list 1)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-delete-duplicates-test ()
|
|
|
|
|
(should (equal '(3 2 1) (cl-delete-duplicates (list 1 2 3 2 1))))
|
|
|
|
@ -263,63 +263,63 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal '(b 2 3 4 5 2 6) (cl-substitute 'b nil list :if-not pred))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-seq-substitute-if-test ()
|
|
|
|
|
(let ((result (cl-substitute-if 'x #'cl-evenp '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-substitute-if 'x #'evenp '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result '(1 x 3 x 5))))
|
|
|
|
|
(let ((result (cl-substitute-if 'x #'cl-evenp '(1 3 5))))
|
|
|
|
|
(let ((result (cl-substitute-if 'x #'evenp '(1 3 5))))
|
|
|
|
|
(should (equal result '(1 3 5))))
|
|
|
|
|
(let ((result (cl-substitute-if 'x #'always '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result '(x x x x x))))
|
|
|
|
|
(let ((result (cl-substitute-if 'x #'cl-evenp '(1 2 3 4 5) :start 1 :end 4)))
|
|
|
|
|
(let ((result (cl-substitute-if 'x #'evenp '(1 2 3 4 5) :start 1 :end 4)))
|
|
|
|
|
(should (equal result '(1 x 3 x 5))))
|
|
|
|
|
(let ((result (cl-substitute-if 'x #'cl-oddp '(1 2 3 4 5) :from-end t)))
|
|
|
|
|
(let ((result (cl-substitute-if 'x #'oddp '(1 2 3 4 5) :from-end t)))
|
|
|
|
|
(should (equal result '(x 2 x 4 x))))
|
|
|
|
|
(let ((result (cl-substitute-if 'x (lambda (n) (= n 3)) '(1 2 3 4 5)
|
|
|
|
|
:key #'identity)))
|
|
|
|
|
(should (equal result '(1 2 x 4 5)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-seq-substitute-if-not-test ()
|
|
|
|
|
(let ((result (cl-substitute-if-not 'x #'cl-evenp '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-substitute-if-not 'x #'evenp '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result '(x 2 x 4 x))))
|
|
|
|
|
(let ((result (cl-substitute-if-not 'x #'cl-evenp '(2 4 6))))
|
|
|
|
|
(let ((result (cl-substitute-if-not 'x #'evenp '(2 4 6))))
|
|
|
|
|
(should (equal result '(2 4 6))))
|
|
|
|
|
(let ((result (cl-substitute-if-not 'x (lambda (n) (> n 5)) '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result '(x x x x x))))
|
|
|
|
|
(let ((result (cl-substitute-if-not 'x #'cl-evenp '(1 2 3 4 5) :start 0 :end 4)))
|
|
|
|
|
(let ((result (cl-substitute-if-not 'x #'evenp '(1 2 3 4 5) :start 0 :end 4)))
|
|
|
|
|
(should (equal result '(x 2 x 4 5))))
|
|
|
|
|
(let ((result (cl-substitute-if-not 'x #'cl-oddp '(1 2 3 4 5) :from-end t)))
|
|
|
|
|
(let ((result (cl-substitute-if-not 'x #'oddp '(1 2 3 4 5) :from-end t)))
|
|
|
|
|
(should (equal result '(1 x 3 x 5))))
|
|
|
|
|
(let ((result (cl-substitute-if-not 'x (lambda (n) (= n 3)) '(1 2 3 4 5)
|
|
|
|
|
:key #'identity)))
|
|
|
|
|
(should (equal result '(x x 3 x x)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-find-if-test ()
|
|
|
|
|
(let ((result (cl-find-if #'cl-evenp '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-find-if #'evenp '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result 2)))
|
|
|
|
|
(let ((result (cl-find-if (lambda (n) (> n 5)) '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-find-if (lambda (n) (> n 3)) '(1 2 3 4 5 6 7))))
|
|
|
|
|
(should (equal result 4)))
|
|
|
|
|
(let ((result (cl-find-if #'cl-evenp '(1 2 3 4 5) :start 2)))
|
|
|
|
|
(let ((result (cl-find-if #'evenp '(1 2 3 4 5) :start 2)))
|
|
|
|
|
(should (equal result 4)))
|
|
|
|
|
(let ((result (cl-find-if #'cl-evenp '(1 2 3 4 5) :end 1)))
|
|
|
|
|
(let ((result (cl-find-if #'evenp '(1 2 3 4 5) :end 1)))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-find-if #'cl-oddp '(2 4 5 6 7) :from-end t)))
|
|
|
|
|
(let ((result (cl-find-if #'oddp '(2 4 5 6 7) :from-end t)))
|
|
|
|
|
(should (equal result 7)))
|
|
|
|
|
(let ((result (cl-find-if (lambda (n) (= n 4)) '(1 2 3 4 5) :key #'identity)))
|
|
|
|
|
(should (equal result 4))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-find-if-not-test ()
|
|
|
|
|
(let ((result (cl-find-if-not #'cl-evenp '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-find-if-not #'evenp '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result 1)))
|
|
|
|
|
(let ((result (cl-find-if-not #'cl-oddp '(1 3 5))))
|
|
|
|
|
(let ((result (cl-find-if-not #'oddp '(1 3 5))))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-find-if-not (lambda (n) (< n 4)) '(1 2 3 4 5 6 7))))
|
|
|
|
|
(should (equal result 4)))
|
|
|
|
|
(let ((result (cl-find-if-not #'cl-evenp '(1 2 3 4 5) :start 2)))
|
|
|
|
|
(let ((result (cl-find-if-not #'evenp '(1 2 3 4 5) :start 2)))
|
|
|
|
|
(should (equal result 3)))
|
|
|
|
|
(let ((result (cl-find-if-not #'cl-evenp '(1 2 3 4 5) :end 3)))
|
|
|
|
|
(let ((result (cl-find-if-not #'evenp '(1 2 3 4 5) :end 3)))
|
|
|
|
|
(should (equal result 1)))
|
|
|
|
|
(let ((result (cl-find-if-not #'cl-oddp '(2 4 6 7 8) :from-end t)))
|
|
|
|
|
(let ((result (cl-find-if-not #'oddp '(2 4 6 7 8) :from-end t)))
|
|
|
|
|
(should (equal result 8)))
|
|
|
|
|
(let ((result (cl-find-if-not (lambda (n) (= n 4)) '(1 2 3 4 5) :key #'identity)))
|
|
|
|
|
(should (equal result 1))))
|
|
|
|
@ -383,17 +383,17 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (= 5 (cl-position 5 list :key (lambda (x) (1+ (* x x))) :from-end t)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-position-if-test ()
|
|
|
|
|
(let ((result (cl-position-if #'cl-evenp '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-position-if #'evenp '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result 1)))
|
|
|
|
|
(let ((result (cl-position-if (lambda (n) (> n 5)) '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-position-if (lambda (n) (> n 3)) '(1 2 3 4 5 6 7))))
|
|
|
|
|
(should (equal result 3)))
|
|
|
|
|
(let ((result (cl-position-if #'cl-evenp '(1 2 3 4 5) :start 2)))
|
|
|
|
|
(let ((result (cl-position-if #'evenp '(1 2 3 4 5) :start 2)))
|
|
|
|
|
(should (equal result 3)))
|
|
|
|
|
(let ((result (cl-position-if #'cl-evenp '(1 2 3 4 5) :end 1)))
|
|
|
|
|
(let ((result (cl-position-if #'evenp '(1 2 3 4 5) :end 1)))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-position-if #'cl-oddp '(2 4 5 6 7) :from-end t)))
|
|
|
|
|
(let ((result (cl-position-if #'oddp '(2 4 5 6 7) :from-end t)))
|
|
|
|
|
(should (equal result 4)))
|
|
|
|
|
(let ((result (cl-position-if (lambda (n) (= n 4)) '(1 2 3 4 5) :key #'identity)))
|
|
|
|
|
(should (equal result 3))))
|
|
|
|
@ -406,15 +406,15 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (= 1 (cl-count 2 list :end 4)))
|
|
|
|
|
(should (= 0 (cl-count -5 list)))
|
|
|
|
|
(should (= 0 (cl-count 2 list :start 2 :end 4)))
|
|
|
|
|
(should (= 4 (cl-count 'foo list :key (lambda (x) (and (cl-evenp x) 'foo)))))
|
|
|
|
|
(should (= 4 (cl-count 'foo list :test (lambda (_a b) (cl-evenp b)))))
|
|
|
|
|
(should (equal (cl-count 'foo list :test (lambda (_a b) (cl-oddp b)))
|
|
|
|
|
(cl-count 'foo list :test-not (lambda (_a b) (cl-evenp b)))))))
|
|
|
|
|
(should (= 4 (cl-count 'foo list :key (lambda (x) (and (evenp x) 'foo)))))
|
|
|
|
|
(should (= 4 (cl-count 'foo list :test (lambda (_a b) (evenp b)))))
|
|
|
|
|
(should (equal (cl-count 'foo list :test (lambda (_a b) (oddp b)))
|
|
|
|
|
(cl-count 'foo list :test-not (lambda (_a b) (evenp b)))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-count-if-test ()
|
|
|
|
|
(let ((result (cl-count-if #'cl-evenp '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-count-if #'evenp '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result 2)))
|
|
|
|
|
(let ((result (cl-count-if #'cl-oddp '(2 4 6 8))))
|
|
|
|
|
(let ((result (cl-count-if #'oddp '(2 4 6 8))))
|
|
|
|
|
(should (equal result 0)))
|
|
|
|
|
(let ((result (cl-count-if #'always '(1 2 3 4))))
|
|
|
|
|
(should (equal result 4)))
|
|
|
|
@ -422,11 +422,11 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal result 0)))
|
|
|
|
|
(let ((result (cl-count-if (lambda (x) (> x 2)) '(1 2 3 4 5) :key #'identity)))
|
|
|
|
|
(should (equal result 3)))
|
|
|
|
|
(let ((result (cl-count-if #'cl-evenp '(1 2 3 4 5) :start 2)))
|
|
|
|
|
(let ((result (cl-count-if #'evenp '(1 2 3 4 5) :start 2)))
|
|
|
|
|
(should (equal result 1)))
|
|
|
|
|
(let ((result (cl-count-if #'cl-evenp '(1 2 3 4 5) :end 3)))
|
|
|
|
|
(let ((result (cl-count-if #'evenp '(1 2 3 4 5) :end 3)))
|
|
|
|
|
(should (equal result 1)))
|
|
|
|
|
(let ((result (cl-count-if #'cl-evenp '())))
|
|
|
|
|
(let ((result (cl-count-if #'evenp '())))
|
|
|
|
|
(should (equal result 0)))
|
|
|
|
|
(let ((result (cl-count-if #'numberp '(1 "two" 3 4 "five" 6))))
|
|
|
|
|
(should (equal result 4)))
|
|
|
|
@ -434,9 +434,9 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal result 4))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-count-if-not-test ()
|
|
|
|
|
(let ((result (cl-count-if-not #'cl-evenp '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-count-if-not #'evenp '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result 3)))
|
|
|
|
|
(let ((result (cl-count-if-not #'cl-oddp '(1 3 5))))
|
|
|
|
|
(let ((result (cl-count-if-not #'oddp '(1 3 5))))
|
|
|
|
|
(should (equal result 0)))
|
|
|
|
|
(let ((result (cl-count-if-not #'always '(1 2 3 4))))
|
|
|
|
|
(should (equal result 0)))
|
|
|
|
@ -444,11 +444,11 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal result 4)))
|
|
|
|
|
(let ((result (cl-count-if-not (lambda (x) (> x 3)) '(1 2 3 4 5) :key #'identity)))
|
|
|
|
|
(should (equal result 3)))
|
|
|
|
|
(let ((result (cl-count-if-not #'cl-evenp '(1 2 3 4 5) :start 2)))
|
|
|
|
|
(let ((result (cl-count-if-not #'evenp '(1 2 3 4 5) :start 2)))
|
|
|
|
|
(should (equal result 2)))
|
|
|
|
|
(let ((result (cl-count-if-not #'cl-evenp '(1 2 3 4 5) :end 3)))
|
|
|
|
|
(let ((result (cl-count-if-not #'evenp '(1 2 3 4 5) :end 3)))
|
|
|
|
|
(should (equal result 2)))
|
|
|
|
|
(let ((result (cl-count-if-not #'cl-evenp '())))
|
|
|
|
|
(let ((result (cl-count-if-not #'evenp '())))
|
|
|
|
|
(should (equal result 0)))
|
|
|
|
|
(let ((result (cl-count-if-not #'numberp '(1 "two" 3 4 "five" 6))))
|
|
|
|
|
(should (equal result 2)))
|
|
|
|
@ -627,7 +627,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal result '(2 3 4 5)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-member-if-test ()
|
|
|
|
|
(let ((result (cl-member-if #'cl-evenp '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-member-if #'evenp '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result '(2 3 4 5))))
|
|
|
|
|
(let ((result (cl-member-if #'ignore '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
@ -635,7 +635,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal result '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-member-if (lambda (x) (= x 1)) '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-member-if (lambda (x) (and (numberp x) (cl-evenp x)))
|
|
|
|
|
(let ((result (cl-member-if (lambda (x) (and (numberp x) (evenp x)))
|
|
|
|
|
'(1 3 5 4 2))))
|
|
|
|
|
(should (equal result '(4 2))))
|
|
|
|
|
(let ((result (cl-member-if (lambda (x) (string= (number-to-string x) "3"))
|
|
|
|
@ -643,7 +643,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal result '(3 4 5))))
|
|
|
|
|
(let ((result (cl-member-if (lambda (x) (eq x 'a)) '(a a a a))))
|
|
|
|
|
(should (equal result '(a a a a))))
|
|
|
|
|
(let ((result (cl-member-if #'cl-evenp '())))
|
|
|
|
|
(let ((result (cl-member-if #'evenp '())))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-member-if #'cl-minusp '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
@ -655,9 +655,9 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal result '(6 7 8)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-member-if-not-test ()
|
|
|
|
|
(let ((result (cl-member-if-not #'cl-evenp '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-member-if-not #'evenp '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-member-if-not #'cl-evenp '(2 4 6 8 10 11))))
|
|
|
|
|
(let ((result (cl-member-if-not #'evenp '(2 4 6 8 10 11))))
|
|
|
|
|
(should (equal result '(11))))
|
|
|
|
|
(let ((result (cl-member-if-not (lambda (x) (> x 5)) '(1 2 3 4 5))))
|
|
|
|
|
(should (equal result '(1 2 3 4 5))))
|
|
|
|
@ -668,7 +668,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(let ((result (cl-member-if-not (lambda (x) (string= (number-to-string x) "2"))
|
|
|
|
|
'(1 2 3 4 5) :key #'identity)))
|
|
|
|
|
(should (equal result '(1 2 3 4 5))))
|
|
|
|
|
(let ((result (cl-member-if-not #'cl-evenp '())))
|
|
|
|
|
(let ((result (cl-member-if-not #'evenp '())))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-member-if-not (lambda (x) (eq x 'a)) '(a a a a))))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
@ -701,7 +701,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal result '(b . 2)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-assoc-if-test ()
|
|
|
|
|
(let ((result (cl-assoc-if #'cl-evenp
|
|
|
|
|
(let ((result (cl-assoc-if #'evenp
|
|
|
|
|
'((1 . "odd") (2 . "even") (3 . "odd") (4 . "even")))))
|
|
|
|
|
(should (equal result '(2 . "even"))))
|
|
|
|
|
(let ((result (cl-assoc-if (lambda (x) (= x 5))
|
|
|
|
@ -719,7 +719,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(let ((result (cl-assoc-if (lambda (x) (> x 1))
|
|
|
|
|
'((0 . "zero") (1 . "one") (2 . "two")))))
|
|
|
|
|
(should (equal result '(2 . "two"))))
|
|
|
|
|
(let ((result (cl-assoc-if #'cl-evenp '())))
|
|
|
|
|
(let ((result (cl-assoc-if #'evenp '())))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-assoc-if (lambda (x) (eq x 'a))
|
|
|
|
|
'((a . "first") (a . "second") (b . "third")))))
|
|
|
|
@ -732,7 +732,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-assoc-if-not-test ()
|
|
|
|
|
(let* ((alist '((1 . "odd") (2 . "even") (3 . "odd") (4 . "even")))
|
|
|
|
|
(result (cl-assoc-if-not #'cl-evenp alist)))
|
|
|
|
|
(result (cl-assoc-if-not #'evenp alist)))
|
|
|
|
|
(should (equal result '(1 . "odd"))))
|
|
|
|
|
(let ((result (cl-assoc-if-not #'cl-plusp
|
|
|
|
|
'((1 . "one") (2 . "two") (3 . "three")))))
|
|
|
|
@ -753,7 +753,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(let ((result (cl-assoc-if-not #'symbolp
|
|
|
|
|
'((1 . "one") (b . "bee") (2 . "two")))))
|
|
|
|
|
(should (equal result '(1 . "one"))))
|
|
|
|
|
(let ((result (cl-assoc-if-not #'cl-evenp '())))
|
|
|
|
|
(let ((result (cl-assoc-if-not #'evenp '())))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-assoc-if-not (lambda (x) (eq x 'a))
|
|
|
|
|
'((a . "first") (a . "second") (b . "third")))))
|
|
|
|
@ -781,10 +781,10 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal result nil))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-rassoc-if-test ()
|
|
|
|
|
(let ((result (cl-rassoc-if #'cl-evenp
|
|
|
|
|
(let ((result (cl-rassoc-if #'evenp
|
|
|
|
|
'(("one" . 1) ("two" . 2) ("three" . 3)))))
|
|
|
|
|
(should (equal result '("two" . 2))))
|
|
|
|
|
(let ((result (cl-rassoc-if #'cl-evenp
|
|
|
|
|
(let ((result (cl-rassoc-if #'evenp
|
|
|
|
|
'(("one" . 1) ("three" . 3) ("five" . 5)))))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-rassoc-if (lambda (x) (= x 1))
|
|
|
|
@ -796,7 +796,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(let ((result (cl-rassoc-if (lambda (x) (and (numberp x) (< x 3)))
|
|
|
|
|
'(("one" . 1) ("two" . 2) ("three" . 3)))))
|
|
|
|
|
(should (equal result '("one" . 1))))
|
|
|
|
|
(let ((result (cl-rassoc-if #'cl-evenp '())))
|
|
|
|
|
(let ((result (cl-rassoc-if #'evenp '())))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-rassoc-if #'cl-plusp
|
|
|
|
|
'(("first" . 1) ("second" . 2) ("third" . 3)))))
|
|
|
|
@ -809,7 +809,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(should (equal result nil))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest cl-rassoc-if-not-test ()
|
|
|
|
|
(let ((result (cl-rassoc-if-not #'cl-evenp
|
|
|
|
|
(let ((result (cl-rassoc-if-not #'evenp
|
|
|
|
|
'(("one" . 1) ("two" . 2) ("three" . 3)))))
|
|
|
|
|
(should (equal result '("one" . 1))))
|
|
|
|
|
(let ((result (cl-rassoc-if-not #'cl-plusp
|
|
|
|
@ -830,7 +830,7 @@ Additionally register an `ert-info' to help identify test failures."
|
|
|
|
|
(let ((result (cl-rassoc-if-not (lambda (x) (equal x 2))
|
|
|
|
|
'(("one" . 1) ("two" . 2) ("three" . 3)))))
|
|
|
|
|
(should (equal result '("one" . 1))))
|
|
|
|
|
(let ((result (cl-rassoc-if-not #'cl-evenp '())))
|
|
|
|
|
(let ((result (cl-rassoc-if-not #'evenp '())))
|
|
|
|
|
(should (equal result nil)))
|
|
|
|
|
(let ((result (cl-rassoc-if-not #'numberp
|
|
|
|
|
'(("one" . 1) ("two" . 2) ("three" . 3)))))
|
|
|
|
|