summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/seq-tests.el
diff options
context:
space:
mode:
authorDamien Cassou <damien@cassou.me>2017-04-17 11:01:39 +0200
committerNicolas Petton <nicolas@petton.fr>2017-05-04 11:32:58 +0200
commit88f96e69cfcd265f2ef0db3e134ac9e29e64ec3e (patch)
treecdf11ece3a34f982ba3bf28bd8f90d659fdc41b1 /test/lisp/emacs-lisp/seq-tests.el
parent250d24fa7333046fb187cf4f544dc4358f16e2df (diff)
downloademacs-88f96e69cfcd265f2ef0db3e134ac9e29e64ec3e.tar.gz
Add seq-set-equal-p to test for set equality
* lisp/emacs-lisp/seq.el (seq-set-equal-p): Add function to compare two lists as if they were sets. * test/lisp/emacs-lisp/seq-tests.el (test-seq-set-equal-p): Add test for seq-set-equal-p.
Diffstat (limited to 'test/lisp/emacs-lisp/seq-tests.el')
-rw-r--r--test/lisp/emacs-lisp/seq-tests.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el
index 788524bedb5..495cf1e543c 100644
--- a/test/lisp/emacs-lisp/seq-tests.el
+++ b/test/lisp/emacs-lisp/seq-tests.el
@@ -197,6 +197,31 @@ Evaluate BODY for each created sequence.
(should (seq-every-p #'identity seq))
(should (seq-every-p #'test-sequences-evenp seq))))
+(ert-deftest test-seq-set-equal-p ()
+ (with-test-sequences (seq1 '(1 2 3))
+ (should (seq-set-equal-p seq1 seq1))
+ (should (seq-set-equal-p seq1 seq1 #'eq))
+
+ (with-test-sequences (seq2 '(3 2 1))
+ (should (seq-set-equal-p seq1 seq2))
+ (should (seq-set-equal-p seq2 seq1))
+ (should (seq-set-equal-p seq1 seq2 #'eq))
+ (should (seq-set-equal-p seq2 seq1 #'eq)))
+
+ (with-test-sequences (seq2 '(3 1))
+ (should-not (seq-set-equal-p seq1 seq2))
+ (should-not (seq-set-equal-p seq2 seq1))))
+
+ (should (seq-set-equal-p '("a" "b" "c")
+ '("c" "b" "a")))
+ (should-not (seq-set-equal-p '("a" "b" "c")
+ '("c" "b" "a") #'eq))
+ (should-not (seq-set-equal-p '(("a" 1) ("b" 1) ("c" 1))
+ '(("c" 2) ("b" 2) ("a" 2))))
+ (should (seq-set-equal-p '(("a" 1) ("b" 1) ("c" 1))
+ '(("c" 2) ("b" 2) ("a" 2))
+ (lambda (i1 i2) (equal (car i1) (car i2))))))
+
(ert-deftest test-seq-empty-p ()
(with-test-sequences (seq '(0))
(should-not (seq-empty-p seq)))