diff options
| author | Juri Linkov | 2020-10-31 22:11:02 +0200 |
|---|---|---|
| committer | Juri Linkov | 2020-10-31 22:11:02 +0200 |
| commit | 5d9e456c3ed3dcefe6bf48e24a1a8f275fc887cb (patch) | |
| tree | fc7e141fbde3a524969741ecbc91614c67550503 /test/src | |
| parent | c307c9648d541338814fe541389ea8c7a1cf50a5 (diff) | |
| download | emacs-5d9e456c3ed3dcefe6bf48e24a1a8f275fc887cb.tar.gz emacs-5d9e456c3ed3dcefe6bf48e24a1a8f275fc887cb.zip | |
New variable integer-output-format to print integers as characters (bug#44155)
* doc/lispref/streams.texi (Output Variables): Add integer-output-format.
* src/print.c (print_object): In case of Lisp_Int, print integers
as characters when Vinteger_output_format is Qt, and in hex format
when Vinteger_output_format is 16.
(Vinteger_output_format): New variable.
* test/src/print-tests.el (print-integer-output-format): New test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/print-tests.el | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/src/print-tests.el b/test/src/print-tests.el index eb9572dbdf4..7b026b6b21f 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el | |||
| @@ -383,5 +383,25 @@ otherwise, use a different charset." | |||
| 383 | (let ((print-length 1)) | 383 | (let ((print-length 1)) |
| 384 | (format "%S" h)))))) | 384 | (format "%S" h)))))) |
| 385 | 385 | ||
| 386 | (print-tests--deftest print-integer-output-format () | ||
| 387 | ;; Bug#44155. | ||
| 388 | (let ((integer-output-format t) | ||
| 389 | (syms (list ?? ?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\ ?Á))) | ||
| 390 | (should (equal (read (print-tests--prin1-to-string syms)) syms)) | ||
| 391 | (should (equal (print-tests--prin1-to-string syms) | ||
| 392 | (concat "(" (mapconcat #'prin1-char syms " ") ")")))) | ||
| 393 | (let ((integer-output-format t) | ||
| 394 | (syms (list -1 0 1 ?\120 4194175 4194176 (max-char) (1+ (max-char))))) | ||
| 395 | (should (equal (read (print-tests--prin1-to-string syms)) syms))) | ||
| 396 | (let ((integer-output-format 16) | ||
| 397 | (syms (list -1 0 1 most-positive-fixnum (1+ most-positive-fixnum)))) | ||
| 398 | (should (equal (read (print-tests--prin1-to-string syms)) syms)) | ||
| 399 | (should (equal (print-tests--prin1-to-string syms) | ||
| 400 | (concat "(" (mapconcat | ||
| 401 | (lambda (i) | ||
| 402 | (if (and (>= i 0) (<= i most-positive-fixnum)) | ||
| 403 | (format "#x%x" i) (format "%d" i))) | ||
| 404 | syms " ") ")"))))) | ||
| 405 | |||
| 386 | (provide 'print-tests) | 406 | (provide 'print-tests) |
| 387 | ;;; print-tests.el ends here | 407 | ;;; print-tests.el ends here |