Make sure seq-contains return the element of the sequence instead of t.
* lisp/emacs-lisp/seq.el (seq-contains): Fix the function.
* test/lisp/emacs-lisp/seq-tests.el: Add a regression test.
;; Author: Nicolas Petton <nicolas@petton.fr>
;; Keywords: sequences
-;; Version: 2.17
+;; Version: 2.18
;; Package: seq
;; Maintainer: emacs-devel@gnu.org
"Return the first element in SEQUENCE that is equal to ELT.
Equality is defined by TESTFN if non-nil or by `equal' if nil."
(seq-some (lambda (e)
- (funcall (or testfn #'equal) elt e))
+ (when (funcall (or testfn #'equal) elt e)
+ e))
sequence))
(cl-defgeneric seq-position (sequence elt &optional testfn)
(should-not (seq-contains seq 3))
(should-not (seq-contains seq nil))))
+(ert-deftest test-seq-contains-should-return-the-elt ()
+ (with-test-sequences (seq '(3 4 5 6))
+ (should (= 5 (seq-contains seq 5)))))
+
(ert-deftest test-seq-every-p ()
(with-test-sequences (seq '(43 54 22 1))
(should (seq-every-p (lambda (elt) t) seq))