aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMattias EngdegÄrd2025-10-10 15:39:15 +0200
committerMattias EngdegÄrd2025-10-20 11:39:16 +0200
commitd1b3eb7eec64ffb9f2d89efda21660cab92bcf0c (patch)
treef72ab3aa242a7c81d4e0bc449549f0ae92af231a /test
parentcfe3c1c840d279d584350d2426b572e211df7c93 (diff)
downloademacs-d1b3eb7eec64ffb9f2d89efda21660cab92bcf0c.tar.gz
emacs-d1b3eb7eec64ffb9f2d89efda21660cab92bcf0c.zip
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.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/subr-tests.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index ae5932d96b3..fc980eae596 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1545,5 +1545,34 @@ final or penultimate step during initialization."))
1545 (should (equal (funcall (subr--identity #'take-while) #'plusp ls) 1545 (should (equal (funcall (subr--identity #'take-while) #'plusp ls)
1546 '(3 2 1))))) 1546 '(3 2 1)))))
1547 1547
1548(ert-deftest subr-all ()
1549 (should (equal (all #'hash-table-p nil) t))
1550 (let ((ls (append '(3 2 1) '(0) '(-1 -2 -3))))
1551 (should (equal (all #'numberp ls) t))
1552 (should (equal (all (lambda (x) (numberp x)) ls) t))
1553 (should (equal (all #'plusp ls) nil))
1554 (should (equal (all #'bufferp ls) nil))
1555 (let ((z 9))
1556 (should (equal (all (lambda (x) (< x z)) ls) t))
1557 (should (equal (all (lambda (x) (> x (- z 9))) ls) nil))
1558 (should (equal (all (lambda (x) (> x z)) ls) nil)))
1559 (should (equal (funcall (subr--identity #'all) #'plusp ls) nil))
1560 (should (equal (funcall (subr--identity #'all) #'numberp ls) t))))
1561
1562(ert-deftest subr-any ()
1563 (should (equal (any #'hash-table-p nil) nil))
1564 (let ((ls (append '(3 2 1) '(0) '(-1 -2 -3))))
1565 (should (equal (any #'numberp ls) ls))
1566 (should (equal (any (lambda (x) (numberp x)) ls) ls))
1567 (should (equal (any #'plusp ls) ls))
1568 (should (equal (any #'zerop ls) '(0 -1 -2 -3)))
1569 (should (equal (any #'bufferp ls) nil))
1570 (let ((z 9))
1571 (should (equal (any (lambda (x) (< x z)) ls) ls))
1572 (should (equal (any (lambda (x) (< x (- z 9))) ls) '(-1 -2 -3)))
1573 (should (equal (any (lambda (x) (> x z)) ls) nil)))
1574 (should (equal (funcall (subr--identity #'any) #'minusp ls) '(-1 -2 -3)))
1575 (should (equal (funcall (subr--identity #'any) #'stringp ls) nil))))
1576
1548(provide 'subr-tests) 1577(provide 'subr-tests)
1549;;; subr-tests.el ends here 1578;;; subr-tests.el ends here