summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-08-09 19:18:55 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-08-09 19:21:36 +0200
commit5269842833471c960352ced3c60ce2329660b8cf (patch)
tree714d09b0548bc57c2f5b7d0a8d492cea452cafcc /test
parentb92e88875802724af9e08201ea65a96dd5f20ff1 (diff)
downloademacs-5269842833471c960352ced3c60ce2329660b8cf.tar.gz
emacs-5269842833471c960352ced3c60ce2329660b8cf.tar.bz2
emacs-5269842833471c960352ced3c60ce2329660b8cf.zip
Add a faster seq-uniq for lists
* lisp/emacs-lisp/seq.el (seq-uniq): Add a faster method for lists (bug#57079).
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/seq-tests.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el
index 3b22e42df24..a655377e6cc 100644
--- a/test/lisp/emacs-lisp/seq-tests.el
+++ b/test/lisp/emacs-lisp/seq-tests.el
@@ -559,5 +559,18 @@ Evaluate BODY for each created sequence.
(should (equal (seq-split seq 3)
'("012" "345" "678" "9")))))
+(ert-deftest test-seq-uniq-list ()
+ (let ((list '(1 2 3)))
+ (should (equal (seq-uniq (append list list)) '(1 2 3))))
+ (let ((list '(1 2 3 2 1)))
+ (should (equal (seq-uniq list) '(1 2 3))))
+ (let ((list (list (substring "1")
+ (substring "2")
+ (substring "3")
+ (substring "2")
+ (substring "1"))))
+ (should (equal (seq-uniq list) '("1" "2" "3")))
+ (should (equal (seq-uniq list #'eq) '("1" "2" "3" "2" "1")))))
+
(provide 'seq-tests)
;;; seq-tests.el ends here