diff options
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 8 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/seq-tests.el | 29 |
2 files changed, 32 insertions, 5 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 9c5bef09a34..a246c25e24f 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -38,7 +38,7 @@ bytecomp-test-var) (defun bytecomp-test-identity (x) - "Identity, but hidden from some optimisations." + "Identity, but hidden from some optimizations." x) (defmacro bytecomp-test-loop (outer1 outer2 inner1 inner2) @@ -556,7 +556,7 @@ inner loops respectively." ((not x) 3))) '("a" "b" "c" "d" nil)) - ;; `let' and `let*' optimisations with body being constant or variable + ;; `let' and `let*' optimizations with body being constant or variable (let* (a (b (progn (setq a (cons 1 a)) 2)) (c (1+ b)) @@ -582,7 +582,7 @@ inner loops respectively." (let* (x y) 'a) - ;; Check empty-list optimisations. + ;; Check empty-list optimizations. (mapcar (lambda (x) (member x nil)) '("a" 2 nil)) (mapcar (lambda (x) (memql x nil)) '(a 2 nil)) (mapcar (lambda (x) (memq x nil)) '(a nil)) @@ -597,7 +597,7 @@ inner loops respectively." (list (mapcar (lambda (x) (assoc (setq n (1+ n)) nil)) '(a "nil")) n)) - ;; Exercise variable-aliasing optimisations. + ;; Exercise variable-aliasing optimizations. (let ((a (list 1))) (let ((b a)) (let ((a (list 2))) diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el index d979604910e..3b22e42df24 100644 --- a/test/lisp/emacs-lisp/seq-tests.el +++ b/test/lisp/emacs-lisp/seq-tests.el @@ -257,6 +257,19 @@ Evaluate BODY for each created sequence. (with-test-sequences (seq '()) (should (equal (seq-uniq seq) '())))) +(defun seq-tests--list-subseq-ref (list start &optional end) + "Reference implementation of `seq-subseq' for lists." + (let ((len (length list))) + (when (< start 0) + (setq start (+ start len))) + (unless end + (setq end len)) + (when (< end 0) + (setq end (+ end len))) + (if (<= 0 start end len) + (take (- end start) (nthcdr start list)) + (error "bad args")))) + (ert-deftest test-seq-subseq () (with-test-sequences (seq '(2 3 4 5)) (should (equal (seq-subseq seq 0 4) seq)) @@ -275,7 +288,21 @@ Evaluate BODY for each created sequence. (should-error (seq-subseq [] -1)) (should-error (seq-subseq "" -1)) (should-not (seq-subseq '() 0)) - (should-error (seq-subseq '() 0 -1))) + (should-error (seq-subseq '() 0 -1)) + + (dolist (list '(() (a b c d))) + (ert-info ((prin1-to-string list) :prefix "list: ") + (let ((len (length list))) + (dolist (start (number-sequence (- -2 len) (+ 2 len))) + (ert-info ((prin1-to-string start) :prefix "start: ") + (dolist (end (cons nil (number-sequence (- -2 len) (+ 2 len)))) + (ert-info ((prin1-to-string end) :prefix "end: ") + (condition-case res + (seq-tests--list-subseq-ref list start end) + (error + (should-error (seq-subseq list start end))) + (:success + (should (equal (seq-subseq list start end) res)))))))))))) (ert-deftest test-seq-concatenate () (with-test-sequences (seq '(2 4 6)) |