summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2017-05-28 17:01:05 -0400
committerNoam Postavsky <npostavs@gmail.com>2017-05-31 07:45:43 -0400
commita415c8bccb917c247792c4ce8e77b2512b3414d6 (patch)
tree222b1fd62276c7220ed06b13e2125e51e96c567c /test
parent94306c8b0d61a53b19dcee18475ea8692b001f5d (diff)
downloademacs-a415c8bccb917c247792c4ce8e77b2512b3414d6.tar.gz
cl-print: handle circular objects when `print-circle' is nil (Bug#27117)
* lisp/emacs-lisp/cl-print.el (cl-print--currently-printing): New variable. (cl-print-object): When `print-circle' is nil, bind it to a list of objects that are currently printing to avoid printing the same object endlessly. * test/lisp/emacs-lisp/cl-print-tests.el (cl-print-circle): New test.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/cl-print-tests.el8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/cl-print-tests.el b/test/lisp/emacs-lisp/cl-print-tests.el
index 772601fe87d..dfbe18d7844 100644
--- a/test/lisp/emacs-lisp/cl-print-tests.el
+++ b/test/lisp/emacs-lisp/cl-print-tests.el
@@ -47,4 +47,12 @@
"\\`(#1=#s(foo 1 2 3) #1#)\\'"
(cl-prin1-to-string (list x x)))))))
+(ert-deftest cl-print-circle ()
+ (let ((x '(#1=(a . #1#) #1#)))
+ (let ((print-circle nil))
+ (should (string-match "\\`((a . #[0-9]) (a . #[0-9]))\\'"
+ (cl-prin1-to-string x))))
+ (let ((print-circle t))
+ (should (equal "(#1=(a . #1#) #1#)" (cl-prin1-to-string x))))))
+
;;; cl-print-tests.el ends here.