[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master ead2845 3/4: Fix seq-contains
From: |
Nicolas Petton |
Subject: |
[Emacs-diffs] master ead2845 3/4: Fix seq-contains |
Date: |
Sat, 18 Jun 2016 08:10:06 +0000 (UTC) |
branch: master
commit ead28454b89c7ba532ecc3f0f4beac68e943b94d
Author: Nicolas Petton <address@hidden>
Commit: Nicolas Petton <address@hidden>
Fix seq-contains
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.
---
lisp/emacs-lisp/seq.el | 5 +++--
test/lisp/emacs-lisp/seq-tests.el | 4 ++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index 20610a7..e5004f8 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -4,7 +4,7 @@
;; Author: Nicolas Petton <address@hidden>
;; Keywords: sequences
-;; Version: 2.17
+;; Version: 2.18
;; Package: seq
;; Maintainer: address@hidden
@@ -349,7 +349,8 @@ found or not."
"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)
diff --git a/test/lisp/emacs-lisp/seq-tests.el
b/test/lisp/emacs-lisp/seq-tests.el
index b227de3..c2065c6 100644
--- a/test/lisp/emacs-lisp/seq-tests.el
+++ b/test/lisp/emacs-lisp/seq-tests.el
@@ -181,6 +181,10 @@ Evaluate BODY for each created sequence.
(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))