diff options
author | Damien Cassou <damien@cassou.me> | 2022-09-04 13:21:59 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-09-04 13:21:59 +0200 |
commit | 4751b51d5e1182975aa002af08a625e4859ec276 (patch) | |
tree | 1dcabd8ede4a44d931d998dca9ddba21d2faa324 /test/lisp/emacs-lisp | |
parent | 4d50d413e67dd8ae183af8b68f315a667ebf2add (diff) | |
download | emacs-4751b51d5e1182975aa002af08a625e4859ec276.tar.gz emacs-4751b51d5e1182975aa002af08a625e4859ec276.tar.bz2 emacs-4751b51d5e1182975aa002af08a625e4859ec276.zip |
Add new function `seq-positions'
* doc/lispref/sequences.texi (Sequence Functions): Document it.
* lisp/emacs-lisp/seq.el (seq-positions): New function.
* lisp/emacs-lisp/shortdoc.el (sequence): Mention it.
* test/lisp/emacs-lisp/seq-tests.el (test-seq-positions): Test it
(bug#57548).
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/seq-tests.el | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el index 6249e486173..d95b35c45eb 100644 --- a/test/lisp/emacs-lisp/seq-tests.el +++ b/test/lisp/emacs-lisp/seq-tests.el @@ -490,6 +490,13 @@ Evaluate BODY for each created sequence. (should (= (seq-position seq 'a #'eq) 0)) (should (null (seq-position seq (make-symbol "a") #'eq))))) +(ert-deftest test-seq-positions () + (with-test-sequences (seq '(1 2 3 1 4)) + (should (equal '(0 3) (seq-positions seq 1))) + (should (seq-empty-p (seq-positions seq 9)))) + (with-test-sequences (seq '(11 5 7 12 9 15)) + (should (equal '(0 3 5) (seq-positions seq 10 #'>=))))) + (ert-deftest test-seq-sort-by () (let ((seq ["x" "xx" "xxx"])) (should (equal (seq-sort-by #'seq-length #'> seq) |