Prefer oddp/evenp to cl-oddp/cl-evenp

* lisp/calc/calc-ext.el (math-oddp):
* lisp/calc/calc-misc.el (math-evenp):
* lisp/calendar/todo-mode.el
(todo-adjusted-category-label-length, todo-insert-category-line)
(todo-update-categories-display):
* lisp/emacs-lisp/cl-macs.el (cl-defstruct):
* lisp/net/gnutls.el (open-gnutls-stream):
* lisp/tab-line.el (tab-line-tab-face-inactive-alternating):
* test/lisp/auth-source-tests.el
(auth-source-test-macos-keychain-search):
* test/lisp/emacs-lisp/cl-extra-tests.el (cl-extra-test-notany)
(cl-extra-test-notevery):
* test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-adjoin-test):
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-collect)
(cl-macs-loop-append/nconc, cl-macs-loop-when)
(cl-macs-loop-if):
* test/lisp/emacs-lisp/cl-seq-tests.el (cl-seq-remove-test)
(cl-remove-if-test, cl-remove-if-not-test, cl-seq-delete-test)
(cl-delete-if-test, cl-delete-if-not-test)
(cl-seq-substitute-if-test, cl-seq-substitute-if-not-test)
(cl-find-if-test, cl-find-if-not-test, cl-position-if-test)
(cl-seq-count-test, cl-count-if-test, cl-count-if-not-test)
(cl-member-if-test, cl-member-if-not-test, cl-assoc-if-test)
(cl-assoc-if-not-test, cl-rassoc-if-test)
(cl-rassoc-if-not-test):
* test/src/treesit-tests.el (treesit-search-forward-predicate):
Prefer oddp/evenp to cl-oddp/cl-evenp where possible.

* lisp/calc/calc-ext.el (cl-lib):
* lisp/calc/calc-misc.el (cl-lib): Don't require.
This commit is contained in:
Stefan Kangas 2025-02-17 03:33:54 +01:00
parent 667d011410
commit 657f4658a7
12 changed files with 105 additions and 107 deletions

View file

@ -25,7 +25,6 @@
(require 'calc)
(require 'calc-macs)
(require 'cl-lib)
;; Declare functions which are defined elsewhere.
(declare-function math-clip "calc-bin" (a &optional w))
@ -2111,7 +2110,7 @@ calc-kill calc-kill-region calc-yank))))
;;; True if A is an odd integer. [P R R] [Public]
(defun math-oddp (a)
(and (integerp a) (cl-oddp a)))
(and (integerp a) (oddp a)))
;;; True if A is an integer. [P x] [Public]
(defalias 'math-integerp #'integerp)

View file

@ -27,7 +27,6 @@
(require 'calc)
(require 'calc-macs)
(require 'cl-lib)
;; Declare functions which are defined elsewhere.
(declare-function calc-do-keypad "calc-keypd" (&optional full-display interactive))
@ -736,7 +735,7 @@ loaded and the keystroke automatically re-typed."
;; True if A is an even integer. [P R R] [Public]
;;;###autoload
(defun math-evenp (a)
(and (integerp a) (cl-evenp a)))
(and (integerp a) (evenp a)))
;; Compute A / 2, for small or big integer A. [I i]
;; If A is negative, type of truncation is undefined.

View file

@ -55,7 +55,7 @@
;;; Code:
(require 'diary-lib)
(require 'cl-lib) ; For cl-oddp and cl-assert.
(require 'cl-lib)
;; -----------------------------------------------------------------------------
;;; Setting up todo files, categories, and items
@ -3742,7 +3742,7 @@ Categories mode."
(longest (todo-longest-category-name-length categories))
(catlablen (length todo-categories-category-label))
(lc-diff (- longest catlablen)))
(if (and (natnump lc-diff) (cl-oddp lc-diff))
(if (and (natnump lc-diff) (oddp lc-diff))
(1+ longest)
(max longest catlablen))))
@ -3870,7 +3870,7 @@ which is the value of the user option
(make-string (1+ (/ (length (car elt)) 2)) 32) ; label
(format "%3d" (todo-get-count (cdr elt) cat)) ; count
;; Add an extra space if label length is odd.
(when (cl-oddp (length (car elt))) " ")))
(when (oddp (length (car elt))) " ")))
(if archive
(list (cons todo-categories-done-label 'done))
(list (cons todo-categories-todo-label 'todo)
@ -3979,7 +3979,7 @@ which is the value of the user option
(make-string (1+ (/ (length (car elt)) 2)) 32)
(format "%3d" (nth (cdr elt) (todo-total-item-counts)))
;; Add an extra space if label length is odd.
(when (cl-oddp (length (car elt))) " ")))
(when (oddp (length (car elt))) " ")))
(if archive
(list (cons todo-categories-done-label 2))
(list (cons todo-categories-todo-label 0)

View file

@ -3259,7 +3259,7 @@ To see the documentation for a defined struct type, use
(declare (side-effect-free t))
,access-body)
forms)
(when (cl-oddp (length desc))
(when (oddp (length desc))
(push
(macroexp-warn-and-return
(format-message

View file

@ -188,7 +188,7 @@ trust and key files, and priority string."
(let* ((parameters
(cond ((symbolp parameters)
(list :nowait parameters))
((not (cl-evenp (length parameters)))
((not (evenp (length parameters)))
(error "Malformed keyword list"))
((consp parameters)
parameters)

View file

@ -668,7 +668,7 @@ SELECTED-P nil means TAB is not the selected tab.
When TAB is not selected and is even-numbered, make FACE
inherit from `tab-line-tab-inactive-alternate'. For use in
`tab-line-tab-face-functions'."
(when (and (not selected-p) (cl-evenp (cl-position tab tabs)))
(when (and (not selected-p) (evenp (cl-position tab tabs)))
(setf face `(:inherit (tab-line-tab-inactive-alternate ,face))))
face)

View file

@ -468,7 +468,7 @@ machine c1 port c2 user c3 password c4\n"
;; Arguments must be all strings.
(should (cl-every #'stringp args))
;; Argument number should be even.
(should (cl-evenp (length args)))
(should (evenp (length args)))
(should
(cond
((string= (car args) "find-internet-password")

View file

@ -228,14 +228,14 @@
nil)))
(ert-deftest cl-extra-test-notany ()
(should (equal (cl-notany #'cl-oddp '(1 3 5)) nil))
(should (equal (cl-notany #'cl-oddp '(2 4 6)) t))
(should (equal (cl-notany #'cl-oddp '(1 2 3 4 5)) nil)))
(should (equal (cl-notany #'oddp '(1 3 5)) nil))
(should (equal (cl-notany #'oddp '(2 4 6)) t))
(should (equal (cl-notany #'oddp '(1 2 3 4 5)) nil)))
(ert-deftest cl-extra-test-notevery ()
(should (equal (cl-notevery #'cl-oddp '(1 3 5)) nil))
(should (equal (cl-notevery #'cl-oddp '(2 4 6)) t))
(should (equal (cl-notevery #'cl-oddp '(1 2 3 4 5)) t)))
(should (equal (cl-notevery #'oddp '(1 3 5)) nil))
(should (equal (cl-notevery #'oddp '(2 4 6)) t))
(should (equal (cl-notevery #'oddp '(1 2 3 4 5)) t)))
(ert-deftest cl-extra-test-gcd ()
(should (equal (cl-gcd 4) 4))

View file

@ -288,8 +288,8 @@
;;(should-error (cl-adjoin 3 nums :test 'myfn-p :test-not myfn-p))
;; own :key fn
(should (eq nums (cl-adjoin 3 nums :key (lambda (x) (if (cl-evenp x) (1+ x) x)))))
(should (equal '(3 1 2) (cl-adjoin 3 nums :key (lambda (x) (if (cl-evenp x) (+ 2 x) x)))))
(should (eq nums (cl-adjoin 3 nums :key (lambda (x) (if (evenp x) (1+ x) x)))))
(should (equal '(3 1 2) (cl-adjoin 3 nums :key (lambda (x) (if (evenp x) (+ 2 x) x)))))
;; convert using :key, then compare with :test
(should (eq nums (cl-adjoin 1 nums :key 'int-to-string :test 'string=)))

View file

@ -212,7 +212,7 @@
when (symbolp i) collect i)
'(bird turtle horse cat)))
(should (equal (cl-loop for i from 1 to 10
if (cl-oddp i) collect i)
if (oddp i) collect i)
'(1 3 5 7 9)))
(should (equal (cl-loop for i in '(a b c d e f g) by #'cddr
collect i into my-list
@ -225,7 +225,7 @@
'(a b (c))))
(should (equal (cl-loop for i upfrom 0
as x in '(a b (c))
nconc (if (cl-evenp i) (list x) nil))
nconc (if (evenp i) (list x) nil))
'(a (c)))))
(ert-deftest cl-macs-loop-count ()
@ -346,7 +346,7 @@ collection clause."
(should (equal (cl-loop for elt in '(1 a 2 "a" (3 4) 5 6)
when (numberp elt)
when (cl-evenp elt) collect elt into even
when (evenp elt) collect elt into even
else collect elt into odd
else
when (symbolp elt) collect elt into syms
@ -356,7 +356,7 @@ collection clause."
(ert-deftest cl-macs-loop-if ()
(should (equal (cl-loop for i to 5
if (cl-evenp i)
if (evenp i)
collect i
and when (and (= i 2) 'two)
collect it
@ -364,7 +364,7 @@ collection clause."
collect "low")
'(0 2 two "low" 4)))
(should (equal (cl-loop for i to 5
if (cl-evenp i)
if (evenp i)
collect i
and when (and (= i 2) 'two)
collect it
@ -374,7 +374,7 @@ collection clause."
'(0 "low" 2 two "low" 4)))
(should (equal (cl-loop with funny-numbers = '(6 13 -1)
for x below 10
if (cl-evenp x)
if (evenp x)
collect x into evens
else
collect x into odds

View file

@ -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)))))

View file

@ -380,7 +380,7 @@ BODY is the test body."
(let ((is-odd (lambda (node)
(let ((string (treesit-node-text node)))
(and (eq 1 (length string))
(cl-oddp (string-to-number string)))))))
(oddp (string-to-number string)))))))
(cl-loop for cursor = (treesit-node-child array 0)
then (treesit-search-forward cursor `("number" . ,is-odd)
nil t)