diff options
author | Basil L. Contovounesios <contovob@tcd.ie> | 2018-07-09 18:46:33 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-07-09 19:00:43 -0700 |
commit | 2fde6275b69fd113e78243790bf112bbdd2fe2bf (patch) | |
tree | f28a04fdabc51d275689066b41b9149422d9f3cb /test/lisp/subr-tests.el | |
parent | e4ad2d1a8fad8c8c786b61083b05cfaa1ea5669c (diff) | |
download | emacs-2fde6275b69fd113e78243790bf112bbdd2fe2bf.tar.gz emacs-2fde6275b69fd113e78243790bf112bbdd2fe2bf.tar.bz2 emacs-2fde6275b69fd113e78243790bf112bbdd2fe2bf.zip |
Add predicate proper-list-p
For discussion, see emacs-devel thread starting at
https://lists.gnu.org/archive/html/emacs-devel/2018-04/msg00460.html.
* lisp/subr.el (proper-list-p): New function.
Implementation suggested by Paul Eggert <eggert@cs.ucla.edu> in
https://lists.gnu.org/archive/html/emacs-devel/2018-06/msg00138.html.
* doc/lispref/lists.texi (List Elements):
* etc/NEWS: Document proper-list-p.
* lisp/org/ob-core.el (org-babel-insert-result):
* lisp/emacs-lisp/byte-opt.el (byte-optimize-if):
* lisp/emacs-lisp/cl-macs.el (cl--make-usage-args): Use proper-list-p.
* lisp/emacs-lisp/ert.el (ert--proper-list-p): Remove.
Replaced by proper-list-p in lisp/subr.el.
(ert--explain-equal-rec): Use proper-list-length.
* lisp/format.el (format-proper-list-p): Remove.
Replaced by proper-list-p in lisp/subr.el.
(format-annotate-single-property-change): Use proper-list-p.
* test/lisp/emacs-lisp/ert-tests.el (ert-test-proper-list-p):
Move from here...
* test/lisp/subr-tests.el (subr-tests--proper-list-length):
...to here, mutatis mutandis.
Diffstat (limited to 'test/lisp/subr-tests.el')
-rw-r--r-- | test/lisp/subr-tests.el | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 52b61d9fb97..86938d5dbe0 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -306,6 +306,24 @@ cf. Bug#25477." (should (eq (string-to-char (symbol-name (gensym))) ?g)) (should (eq (string-to-char (symbol-name (gensym "X"))) ?X))) +(ert-deftest subr-tests--proper-list-p () + "Test `proper-list-p' behavior." + (dotimes (length 4) + ;; Proper and dotted lists. + (let ((list (make-list length 0))) + (should (= (proper-list-p list) length)) + (should (not (proper-list-p (nconc list 0))))) + ;; Circular lists. + (dotimes (n (1+ length)) + (let ((circle (make-list (1+ length) 0))) + (should (not (proper-list-p (nconc circle (nthcdr n circle)))))))) + ;; Atoms. + (should (not (proper-list-p 0))) + (should (not (proper-list-p ""))) + (should (not (proper-list-p []))) + (should (not (proper-list-p (make-bool-vector 0 nil)))) + (should (not (proper-list-p (make-symbol "a"))))) + (ert-deftest subr-tests--assq-delete-all () "Test `assq-delete-all' behavior." (cl-flet ((new-list-fn |