mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-05 22:20:24 -08:00
Add any and all (bug#79611)
* lisp/subr.el (all, any): New. * test/lisp/subr-tests.el (subr-all, subr-any): New tests. * doc/lispref/lists.texi (List Elements): Document. * etc/NEWS: Announce.
This commit is contained in:
parent
cfe3c1c840
commit
d1b3eb7eec
4 changed files with 75 additions and 0 deletions
|
|
@ -1545,5 +1545,34 @@ final or penultimate step during initialization."))
|
|||
(should (equal (funcall (subr--identity #'take-while) #'plusp ls)
|
||||
'(3 2 1)))))
|
||||
|
||||
(ert-deftest subr-all ()
|
||||
(should (equal (all #'hash-table-p nil) t))
|
||||
(let ((ls (append '(3 2 1) '(0) '(-1 -2 -3))))
|
||||
(should (equal (all #'numberp ls) t))
|
||||
(should (equal (all (lambda (x) (numberp x)) ls) t))
|
||||
(should (equal (all #'plusp ls) nil))
|
||||
(should (equal (all #'bufferp ls) nil))
|
||||
(let ((z 9))
|
||||
(should (equal (all (lambda (x) (< x z)) ls) t))
|
||||
(should (equal (all (lambda (x) (> x (- z 9))) ls) nil))
|
||||
(should (equal (all (lambda (x) (> x z)) ls) nil)))
|
||||
(should (equal (funcall (subr--identity #'all) #'plusp ls) nil))
|
||||
(should (equal (funcall (subr--identity #'all) #'numberp ls) t))))
|
||||
|
||||
(ert-deftest subr-any ()
|
||||
(should (equal (any #'hash-table-p nil) nil))
|
||||
(let ((ls (append '(3 2 1) '(0) '(-1 -2 -3))))
|
||||
(should (equal (any #'numberp ls) ls))
|
||||
(should (equal (any (lambda (x) (numberp x)) ls) ls))
|
||||
(should (equal (any #'plusp ls) ls))
|
||||
(should (equal (any #'zerop ls) '(0 -1 -2 -3)))
|
||||
(should (equal (any #'bufferp ls) nil))
|
||||
(let ((z 9))
|
||||
(should (equal (any (lambda (x) (< x z)) ls) ls))
|
||||
(should (equal (any (lambda (x) (< x (- z 9))) ls) '(-1 -2 -3)))
|
||||
(should (equal (any (lambda (x) (> x z)) ls) nil)))
|
||||
(should (equal (funcall (subr--identity #'any) #'minusp ls) '(-1 -2 -3)))
|
||||
(should (equal (funcall (subr--identity #'any) #'stringp ls) nil))))
|
||||
|
||||
(provide 'subr-tests)
|
||||
;;; subr-tests.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue