diff options
| author | Noam Postavsky | 2017-05-28 17:01:05 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2017-05-31 07:45:43 -0400 |
| commit | a415c8bccb917c247792c4ce8e77b2512b3414d6 (patch) | |
| tree | 222b1fd62276c7220ed06b13e2125e51e96c567c /test | |
| parent | 94306c8b0d61a53b19dcee18475ea8692b001f5d (diff) | |
| download | emacs-a415c8bccb917c247792c4ce8e77b2512b3414d6.tar.gz emacs-a415c8bccb917c247792c4ce8e77b2512b3414d6.zip | |
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.el | 8 |
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 @@ | |||
| 47 | "\\`(#1=#s(foo 1 2 3) #1#)\\'" | 47 | "\\`(#1=#s(foo 1 2 3) #1#)\\'" |
| 48 | (cl-prin1-to-string (list x x))))))) | 48 | (cl-prin1-to-string (list x x))))))) |
| 49 | 49 | ||
| 50 | (ert-deftest cl-print-circle () | ||
| 51 | (let ((x '(#1=(a . #1#) #1#))) | ||
| 52 | (let ((print-circle nil)) | ||
| 53 | (should (string-match "\\`((a . #[0-9]) (a . #[0-9]))\\'" | ||
| 54 | (cl-prin1-to-string x)))) | ||
| 55 | (let ((print-circle t)) | ||
| 56 | (should (equal "(#1=(a . #1#) #1#)" (cl-prin1-to-string x)))))) | ||
| 57 | |||
| 50 | ;;; cl-print-tests.el ends here. | 58 | ;;; cl-print-tests.el ends here. |