X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/98af8234e926e2de8910d42dae550ef2626a9289..6f7aa2669e1f2fdda4269b31fa44fb41cf01a8cf:/packages/seq/tests/seq-tests.el diff --git a/packages/seq/tests/seq-tests.el b/packages/seq/tests/seq-tests.el index 7f6e06cc4..deedfb8c3 100644 --- a/packages/seq/tests/seq-tests.el +++ b/packages/seq/tests/seq-tests.el @@ -124,21 +124,32 @@ Evaluate BODY for each created sequence. (should (eq (seq-reduce #'+ seq 0) 0)) (should (eq (seq-reduce #'+ seq 7) 7)))) -(ert-deftest test-seq-some-p () +(ert-deftest test-seq-some () (with-test-sequences (seq '(4 3 2 1)) - (should (= (seq-some-p #'test-sequences-evenp seq) 4)) - (should (= (seq-some-p #'test-sequences-oddp seq) 3)) - (should-not (seq-some-p (lambda (elt) (> elt 10)) seq))) + (should (seq-some #'test-sequences-evenp seq)) + (should (seq-some #'test-sequences-oddp seq)) + (should-not (seq-some (lambda (elt) (> elt 10)) seq))) (with-test-sequences (seq '()) - (should-not (seq-some-p #'test-sequences-oddp seq)))) + (should-not (seq-some #'test-sequences-oddp seq))) + (should (seq-some #'null '(1 nil 2)))) -(ert-deftest test-seq-contains-p () +(ert-deftest test-seq-find () + (with-test-sequences (seq '(4 3 2 1)) + (should (= 4 (seq-find #'test-sequences-evenp seq))) + (should (= 3 (seq-find #'test-sequences-oddp seq))) + (should-not (seq-find (lambda (elt) (> elt 10)) seq))) + (should-not (seq-find #'null '(1 nil 2))) + (should-not (seq-find #'null '(1 nil 2) t)) + (should-not (seq-find #'null '(1 2 3))) + (should (seq-find #'null '(1 2 3) 'sentinel))) + +(ert-deftest test-seq-contains () (with-test-sequences (seq '(3 4 5 6)) - (should (seq-contains-p seq 3)) - (should-not (seq-contains-p seq 7))) + (should (seq-contains seq 3)) + (should-not (seq-contains seq 7))) (with-test-sequences (seq '()) - (should-not (seq-contains-p seq 3)) - (should-not (seq-contains-p seq nil)))) + (should-not (seq-contains seq 3)) + (should-not (seq-contains seq nil)))) (ert-deftest test-seq-every-p () (with-test-sequences (seq '(43 54 22 1)) @@ -276,5 +287,31 @@ Evaluate BODY for each created sequence. (v2 [2 4 6])) (should (seq-empty-p (seq-difference v1 v2))))) +(ert-deftest test-seq-let () + (with-test-sequences (seq '(1 2 3 4)) + (seq-let (a b c d e) seq + (should (= a 1)) + (should (= b 2)) + (should (= c 3)) + (should (= d 4)) + (should (null e))) + (seq-let (a b &rest others) seq + (should (= a 1)) + (should (= b 2)) + (should (same-contents-p others (seq-drop seq 2))))) + (let ((seq '(1 (2 (3 (4)))))) + (seq-let (_ (_ (_ (a)))) seq + (should (= a 4)))) + (let (seq) + (seq-let (a b c) seq + (should (null a)) + (should (null b)) + (should (null c))))) + +(ert-deftest test-seq-min-max () + (with-test-sequences (seq '(4 5 3 2 0 4)) + (should (= (seq-min seq) 0)) + (should (= (seq-max seq) 5)))) + (provide 'seq-tests) ;;; seq-tests.el ends here