diff options
| author | Lars Ingebrigtsen | 2022-05-15 15:29:28 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-05-15 15:29:38 +0200 |
| commit | aa95b2a47dce8cf74f70f43f72e35349782d1c74 (patch) | |
| tree | 169ef433c0b42ae69f09abf71e0d04c7c79ac925 /test/src | |
| parent | 22873b5415fbcc81f2d1e0e69cccd5dbeaac51ee (diff) | |
| download | emacs-aa95b2a47dce8cf74f70f43f72e35349782d1c74.tar.gz emacs-aa95b2a47dce8cf74f70f43f72e35349782d1c74.zip | |
Add OVERRIDES argument to prin1/prin1-to-string
* doc/lispref/streams.texi (Output Functions): Document it.
(Output Overrides): New node.
* src/process.c (Faccept_process_output):
* src/print.c (debug_print, print_error_message):
* src/pdumper.c (print_paths_to_root_1, decode_emacs_reloc):
* src/lread.c (readevalloop):
* src/eval.c (internal_lisp_condition_case):
* src/editfns.c (styled_format): Adjust prin1/prin1-to-string
callers.
* src/print.c (Fprin1): Take an OVERRIDES parameter.
(print_bind_overrides, print_bind_all_defaults): New functions.
(Fprin1_to_string): Take an OVERRIDES parameter.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/print-tests.el | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/src/print-tests.el b/test/src/print-tests.el index 0bae1959d1b..b9b282e5809 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el | |||
| @@ -425,5 +425,48 @@ otherwise, use a different charset." | |||
| 425 | (should (equal (prin1-to-string '\?bar) "\\?bar")) | 425 | (should (equal (prin1-to-string '\?bar) "\\?bar")) |
| 426 | (should (equal (prin1-to-string '\?bar?) "\\?bar?"))) | 426 | (should (equal (prin1-to-string '\?bar?) "\\?bar?"))) |
| 427 | 427 | ||
| 428 | (ert-deftest test-prin1-overrides () | ||
| 429 | (with-temp-buffer | ||
| 430 | (let ((print-length 10)) | ||
| 431 | (prin1 (make-list 20 t) (current-buffer) t) | ||
| 432 | (should (= print-length 10))) | ||
| 433 | (goto-char (point-min)) | ||
| 434 | (should (= (length (read (current-buffer))) 20))) | ||
| 435 | |||
| 436 | (with-temp-buffer | ||
| 437 | (let ((print-length 10)) | ||
| 438 | (prin1 (make-list 20 t) (current-buffer) '((length . 5))) | ||
| 439 | (should (= print-length 10))) | ||
| 440 | (goto-char (point-min)) | ||
| 441 | (should (= (length (read (current-buffer))) 6))) | ||
| 442 | |||
| 443 | (with-temp-buffer | ||
| 444 | (let ((print-length 10)) | ||
| 445 | (prin1 (make-list 20 t) (current-buffer) '(t (length . 5))) | ||
| 446 | (should (= print-length 10))) | ||
| 447 | (goto-char (point-min)) | ||
| 448 | (should (= (length (read (current-buffer))) 6)))) | ||
| 449 | |||
| 450 | (ert-deftest test-prin1-to-string-overrides () | ||
| 451 | (let ((print-length 10)) | ||
| 452 | (should | ||
| 453 | (= (length (car (read-from-string | ||
| 454 | (prin1-to-string (make-list 20 t) nil t)))) | ||
| 455 | 20))) | ||
| 456 | |||
| 457 | (let ((print-length 10)) | ||
| 458 | (should | ||
| 459 | (= (length (car (read-from-string | ||
| 460 | (prin1-to-string (make-list 20 t) nil | ||
| 461 | '((length . 5)))))) | ||
| 462 | 6))) | ||
| 463 | |||
| 464 | (should-error (prin1-to-string 'foo nil 'a)) | ||
| 465 | (should-error (prin1-to-string 'foo nil '(a))) | ||
| 466 | (should-error (prin1-to-string 'foo nil '(t . b))) | ||
| 467 | (should-error (prin1-to-string 'foo nil '(t b))) | ||
| 468 | (should-error (prin1-to-string 'foo nil '((a . b) b))) | ||
| 469 | (should-error (prin1-to-string 'foo nil '((length . 10) . b)))) | ||
| 470 | |||
| 428 | (provide 'print-tests) | 471 | (provide 'print-tests) |
| 429 | ;;; print-tests.el ends here | 472 | ;;; print-tests.el ends here |