diff options
| author | Tassilo Horn | 2019-09-22 11:02:39 +0200 |
|---|---|---|
| committer | Tassilo Horn | 2019-09-22 11:02:39 +0200 |
| commit | af0642a4cb220f33a43d1380be085bc0b7134bb8 (patch) | |
| tree | e3b1b57bc42e712c77bd55fc4fc722cf93fe6c66 /test | |
| parent | 8992bc7d1b7e7babbf2899b5c45e84b486f504e6 (diff) | |
| parent | 37a4233a366797360c2f4f475591a3406586bcfb (diff) | |
| download | emacs-scratch/tsdh-vc-list-files.tar.gz emacs-scratch/tsdh-vc-list-files.zip | |
Merge remote-tracking branch 'origin/master' into scratch/tsdh-vc-list-filesscratch/tsdh-vc-list-files
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/backquote-tests.el | 47 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/backtrace-tests.el | 49 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/cl-print-tests.el | 115 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 21 | ||||
| -rw-r--r-- | test/lisp/progmodes/python-tests.el | 13 | ||||
| -rw-r--r-- | test/lisp/replace-tests.el | 18 | ||||
| -rw-r--r-- | test/lisp/shadowfile-tests.el | 13 | ||||
| -rw-r--r-- | test/src/print-tests.el | 259 |
8 files changed, 392 insertions, 143 deletions
diff --git a/test/lisp/emacs-lisp/backquote-tests.el b/test/lisp/emacs-lisp/backquote-tests.el new file mode 100644 index 00000000000..01f2c4a897e --- /dev/null +++ b/test/lisp/emacs-lisp/backquote-tests.el | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | ;;; backquote-tests.el --- Tests for backquote.el -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2019 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (require 'ert) | ||
| 25 | |||
| 26 | (ert-deftest backquote-test-basic () | ||
| 27 | (let ((lst '(ba bb bc)) | ||
| 28 | (vec [ba bb bc])) | ||
| 29 | (should (equal 3 `,(eval '(+ x y) '((x . 1) (y . 2))))) | ||
| 30 | (should (equal vec `[,@lst])) | ||
| 31 | (should (equal `(a lst c) '(a lst c))) | ||
| 32 | (should (equal `(a ,lst c) '(a (ba bb bc) c))) | ||
| 33 | (should (equal `(a ,@lst c) '(a ba bb bc c))) | ||
| 34 | ;; Vectors work just like lists. | ||
| 35 | (should (equal `(a vec c) '(a vec c))) | ||
| 36 | (should (equal `(a ,vec c) '(a [ba bb bc] c))) | ||
| 37 | (should (equal `(a ,@vec c) '(a ba bb bc c))))) | ||
| 38 | |||
| 39 | (ert-deftest backquote-test-nested () | ||
| 40 | "Test nested backquotes." | ||
| 41 | (let ((lst '(ba bb bc)) | ||
| 42 | (vec [ba bb bc])) | ||
| 43 | (should (equal `(a ,`(,@lst) c) `(a ,lst c))) | ||
| 44 | (should (equal `(a ,`[,@lst] c) `(a ,vec c))) | ||
| 45 | (should (equal `(a ,@`[,@lst] c) `(a ,@lst c))))) | ||
| 46 | |||
| 47 | ;;; backquote-tests.el ends here | ||
diff --git a/test/lisp/emacs-lisp/backtrace-tests.el b/test/lisp/emacs-lisp/backtrace-tests.el index ce827e0166f..be154953423 100644 --- a/test/lisp/emacs-lisp/backtrace-tests.el +++ b/test/lisp/emacs-lisp/backtrace-tests.el | |||
| @@ -335,6 +335,55 @@ line contains the strings \"lambda\" and \"number\"." | |||
| 335 | (should (string-match-p results | 335 | (should (string-match-p results |
| 336 | (backtrace-tests--get-substring (point-min) (point-max))))))) | 336 | (backtrace-tests--get-substring (point-min) (point-max))))))) |
| 337 | 337 | ||
| 338 | (ert-deftest backtrace-tests--print-gensym () | ||
| 339 | "Backtrace buffers can toggle `print-gensym' syntax." | ||
| 340 | (ert-with-test-buffer (:name "print-gensym") | ||
| 341 | (let* ((print-gensym nil) | ||
| 342 | (arg (list (gensym "first") (gensym) (gensym "last"))) | ||
| 343 | (results (backtrace-tests--make-regexp | ||
| 344 | (backtrace-tests--result arg))) | ||
| 345 | (results-gensym (regexp-quote (let ((print-gensym t)) | ||
| 346 | (backtrace-tests--result arg)))) | ||
| 347 | (last-frame (backtrace-tests--make-regexp | ||
| 348 | (format (nth (1- backtrace-tests--line-count) | ||
| 349 | (backtrace-tests--backtrace-lines)) | ||
| 350 | arg))) | ||
| 351 | (last-frame-gensym (regexp-quote | ||
| 352 | (let ((print-gensym t)) | ||
| 353 | (format (nth (1- backtrace-tests--line-count) | ||
| 354 | (backtrace-tests--backtrace-lines)) | ||
| 355 | arg))))) | ||
| 356 | (backtrace-tests--make-backtrace arg) | ||
| 357 | (backtrace-print) | ||
| 358 | (should (string-match-p results | ||
| 359 | (backtrace-tests--get-substring (point-min) (point-max)))) | ||
| 360 | ;; Go to the last frame. | ||
| 361 | (goto-char (point-max)) | ||
| 362 | (forward-line -1) | ||
| 363 | ;; Turn on print-gensym for that frame. | ||
| 364 | (backtrace-toggle-print-gensym) | ||
| 365 | (should (string-match-p last-frame-gensym | ||
| 366 | (backtrace-tests--get-substring (point) (point-max)))) | ||
| 367 | ;; Turn off print-gensym for the frame. | ||
| 368 | (backtrace-toggle-print-gensym) | ||
| 369 | (should (string-match-p last-frame | ||
| 370 | (backtrace-tests--get-substring (point) (point-max)))) | ||
| 371 | (should (string-match-p results | ||
| 372 | (backtrace-tests--get-substring (point-min) (point-max)))) | ||
| 373 | ;; Turn print-gensym on for the buffer. | ||
| 374 | (backtrace-toggle-print-gensym '(4)) | ||
| 375 | (should (string-match-p last-frame-gensym | ||
| 376 | (backtrace-tests--get-substring (point) (point-max)))) | ||
| 377 | (should (string-match-p results-gensym | ||
| 378 | (backtrace-tests--get-substring (point-min) (point-max)))) | ||
| 379 | ;; Turn print-gensym off. | ||
| 380 | (backtrace-toggle-print-gensym '(4)) | ||
| 381 | (should (string-match-p last-frame | ||
| 382 | (backtrace-tests--get-substring | ||
| 383 | (point) (+ (point) (length last-frame))))) | ||
| 384 | (should (string-match-p results | ||
| 385 | (backtrace-tests--get-substring (point-min) (point-max))))))) | ||
| 386 | |||
| 338 | (defun backtrace-tests--make-regexp (str) | 387 | (defun backtrace-tests--make-regexp (str) |
| 339 | "Make regexp from STR for `backtrace-tests--print-circle'. | 388 | "Make regexp from STR for `backtrace-tests--print-circle'. |
| 340 | Used for results of printing circular objects without | 389 | Used for results of printing circular objects without |
diff --git a/test/lisp/emacs-lisp/cl-print-tests.el b/test/lisp/emacs-lisp/cl-print-tests.el index 406c528dce5..31d79df71b5 100644 --- a/test/lisp/emacs-lisp/cl-print-tests.el +++ b/test/lisp/emacs-lisp/cl-print-tests.el | |||
| @@ -19,109 +19,17 @@ | |||
| 19 | 19 | ||
| 20 | ;;; Commentary: | 20 | ;;; Commentary: |
| 21 | 21 | ||
| 22 | ;; See test/src/print-tests.el for tests which apply to both | ||
| 23 | ;; cl-print.el and src/print.c. | ||
| 24 | |||
| 22 | ;;; Code: | 25 | ;;; Code: |
| 23 | 26 | ||
| 24 | (require 'ert) | 27 | (require 'ert) |
| 25 | 28 | ||
| 26 | (cl-defstruct cl-print--test a b) | ||
| 27 | |||
| 28 | (ert-deftest cl-print-tests-1 () | ||
| 29 | "Test cl-print code." | ||
| 30 | (let ((x (make-cl-print--test :a 1 :b 2))) | ||
| 31 | (let ((print-circle nil)) | ||
| 32 | (should (equal (cl-prin1-to-string `((x . ,x) (y . ,x))) | ||
| 33 | "((x . #s(cl-print--test :a 1 :b 2)) (y . #s(cl-print--test :a 1 :b 2)))"))) | ||
| 34 | (let ((print-circle t)) | ||
| 35 | (should (equal (cl-prin1-to-string `((x . ,x) (y . ,x))) | ||
| 36 | "((x . #1=#s(cl-print--test :a 1 :b 2)) (y . #1#))"))) | ||
| 37 | (should (string-match "\\`#f(compiled-function (x) \"[^\"]+\" [^)]*)\\'" | ||
| 38 | (cl-prin1-to-string (symbol-function #'caar)))))) | ||
| 39 | |||
| 40 | (ert-deftest cl-print-tests-2 () | ||
| 41 | (let ((x (record 'foo 1 2 3))) | ||
| 42 | (should (equal | ||
| 43 | x | ||
| 44 | (car (read-from-string (with-output-to-string (prin1 x)))))) | ||
| 45 | (let ((print-circle t)) | ||
| 46 | (should (string-match | ||
| 47 | "\\`(#1=#s(foo 1 2 3) #1#)\\'" | ||
| 48 | (cl-prin1-to-string (list x x))))))) | ||
| 49 | |||
| 50 | (cl-defstruct (cl-print-tests-struct | 29 | (cl-defstruct (cl-print-tests-struct |
| 51 | (:constructor cl-print-tests-con)) | 30 | (:constructor cl-print-tests-con)) |
| 52 | a b c d e) | 31 | a b c d e) |
| 53 | 32 | ||
| 54 | (ert-deftest cl-print-tests-3 () | ||
| 55 | "CL printing observes `print-length'." | ||
| 56 | (let ((long-list (make-list 5 'a)) | ||
| 57 | (long-vec (make-vector 5 'b)) | ||
| 58 | (long-struct (cl-print-tests-con)) | ||
| 59 | (long-string (make-string 5 ?a)) | ||
| 60 | (print-length 4)) | ||
| 61 | (should (equal "(a a a a ...)" (cl-prin1-to-string long-list))) | ||
| 62 | (should (equal "[b b b b ...]" (cl-prin1-to-string long-vec))) | ||
| 63 | (should (equal "#s(cl-print-tests-struct :a nil :b nil :c nil :d nil ...)" | ||
| 64 | (cl-prin1-to-string long-struct))) | ||
| 65 | (should (equal "\"aaaa...\"" (cl-prin1-to-string long-string))))) | ||
| 66 | |||
| 67 | (ert-deftest cl-print-tests-4 () | ||
| 68 | "CL printing observes `print-level'." | ||
| 69 | (let* ((deep-list '(a (b (c (d (e)))))) | ||
| 70 | (buried-vector '(a (b (c (d [e]))))) | ||
| 71 | (deep-struct (cl-print-tests-con)) | ||
| 72 | (buried-struct `(a (b (c (d ,deep-struct))))) | ||
| 73 | (buried-string '(a (b (c (d #("hello" 0 5 (cl-print-test t))))))) | ||
| 74 | (buried-simple-string '(a (b (c (d "hello"))))) | ||
| 75 | (print-level 4)) | ||
| 76 | (setf (cl-print-tests-struct-a deep-struct) deep-list) | ||
| 77 | (should (equal "(a (b (c (d ...))))" (cl-prin1-to-string deep-list))) | ||
| 78 | (should (equal "(a (b (c (d ...))))" (cl-prin1-to-string buried-vector))) | ||
| 79 | (should (equal "(a (b (c (d ...))))" (cl-prin1-to-string buried-struct))) | ||
| 80 | (should (equal "(a (b (c (d ...))))" (cl-prin1-to-string buried-string))) | ||
| 81 | (should (equal "(a (b (c (d \"hello\"))))" | ||
| 82 | (cl-prin1-to-string buried-simple-string))) | ||
| 83 | (should (equal "#s(cl-print-tests-struct :a (a (b (c ...))) :b nil :c nil :d nil :e nil)" | ||
| 84 | (cl-prin1-to-string deep-struct))))) | ||
| 85 | |||
| 86 | (ert-deftest cl-print-tests-5 () | ||
| 87 | "CL printing observes `print-quoted'." | ||
| 88 | (let ((quoted-stuff '('a #'b `(,c ,@d)))) | ||
| 89 | (let ((print-quoted t)) | ||
| 90 | (should (equal "('a #'b `(,c ,@d))" | ||
| 91 | (cl-prin1-to-string quoted-stuff)))) | ||
| 92 | (let ((print-quoted nil)) | ||
| 93 | (should (equal "((quote a) (function b) (\\` ((\\, c) (\\,@ d))))" | ||
| 94 | (cl-prin1-to-string quoted-stuff)))))) | ||
| 95 | |||
| 96 | (ert-deftest cl-print-tests-strings () | ||
| 97 | "CL printing prints strings and propertized strings." | ||
| 98 | (let* ((str1 "abcdefghij") | ||
| 99 | (str2 #("abcdefghij" 3 6 (bold t) 7 9 (italic t))) | ||
| 100 | (str3 #("abcdefghij" 0 10 (test t))) | ||
| 101 | (obj '(a b)) | ||
| 102 | ;; Since the byte compiler reuses string literals, | ||
| 103 | ;; and the put-text-property call is destructive, use | ||
| 104 | ;; copy-sequence to make a new string. | ||
| 105 | (str4 (copy-sequence "abcdefghij"))) | ||
| 106 | (put-text-property 0 5 'test obj str4) | ||
| 107 | (put-text-property 7 10 'test obj str4) | ||
| 108 | |||
| 109 | (should (equal "\"abcdefghij\"" (cl-prin1-to-string str1))) | ||
| 110 | (should (equal "#(\"abcdefghij\" 3 6 (bold t) 7 9 (italic t))" | ||
| 111 | (cl-prin1-to-string str2))) | ||
| 112 | (should (equal "#(\"abcdefghij\" 0 10 (test t))" | ||
| 113 | (cl-prin1-to-string str3))) | ||
| 114 | (let ((print-circle nil)) | ||
| 115 | (should | ||
| 116 | (equal | ||
| 117 | "#(\"abcdefghij\" 0 5 (test (a b)) 7 10 (test (a b)))" | ||
| 118 | (cl-prin1-to-string str4)))) | ||
| 119 | (let ((print-circle t)) | ||
| 120 | (should | ||
| 121 | (equal | ||
| 122 | "#(\"abcdefghij\" 0 5 (test #1=(a b)) 7 10 (test #1#))" | ||
| 123 | (cl-prin1-to-string str4)))))) | ||
| 124 | |||
| 125 | (ert-deftest cl-print-tests-ellipsis-cons () | 33 | (ert-deftest cl-print-tests-ellipsis-cons () |
| 126 | "Ellipsis expansion works in conses." | 34 | "Ellipsis expansion works in conses." |
| 127 | (let ((print-length 4) | 35 | (let ((print-length 4) |
| @@ -216,23 +124,6 @@ | |||
| 216 | (should (string-match expanded (with-output-to-string | 124 | (should (string-match expanded (with-output-to-string |
| 217 | (cl-print-expand-ellipsis value nil)))))) | 125 | (cl-print-expand-ellipsis value nil)))))) |
| 218 | 126 | ||
| 219 | (ert-deftest cl-print-circle () | ||
| 220 | (let ((x '(#1=(a . #1#) #1#))) | ||
| 221 | (let ((print-circle nil)) | ||
| 222 | (should (string-match "\\`((a . #[0-9]) (a . #[0-9]))\\'" | ||
| 223 | (cl-prin1-to-string x)))) | ||
| 224 | (let ((print-circle t)) | ||
| 225 | (should (equal "(#1=(a . #1#) #1#)" (cl-prin1-to-string x)))))) | ||
| 226 | |||
| 227 | (ert-deftest cl-print-circle-2 () | ||
| 228 | ;; Bug#31146. | ||
| 229 | (let ((x '(0 . #1=(0 . #1#)))) | ||
| 230 | (let ((print-circle nil)) | ||
| 231 | (should (string-match "\\`(0 0 . #[0-9])\\'" | ||
| 232 | (cl-prin1-to-string x)))) | ||
| 233 | (let ((print-circle t)) | ||
| 234 | (should (equal "(0 . #1=(0 . #1#))" (cl-prin1-to-string x)))))) | ||
| 235 | |||
| 236 | (ert-deftest cl-print-tests-print-to-string-with-limit () | 127 | (ert-deftest cl-print-tests-print-to-string-with-limit () |
| 237 | (let* ((thing10 (make-list 10 'a)) | 128 | (let* ((thing10 (make-list 10 'a)) |
| 238 | (thing100 (make-list 100 'a)) | 129 | (thing100 (make-list 100 'a)) |
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index dd6b9edd000..d7e0a045106 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -2412,9 +2412,7 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 2412 | (unwind-protect | 2412 | (unwind-protect |
| 2413 | ;; FIXME: This fails on my QNAP server, see | 2413 | ;; FIXME: This fails on my QNAP server, see |
| 2414 | ;; /share/Web/owncloud/data/owncloud.log | 2414 | ;; /share/Web/owncloud/data/owncloud.log |
| 2415 | (unless (and (tramp--test-nextcloud-p) | 2415 | (unless (tramp--test-nextcloud-p) |
| 2416 | (or (not (file-remote-p source)) | ||
| 2417 | (not (file-remote-p target)))) | ||
| 2418 | (make-directory source) | 2416 | (make-directory source) |
| 2419 | (should (file-directory-p source)) | 2417 | (should (file-directory-p source)) |
| 2420 | (write-region "foo" nil (expand-file-name "foo" source)) | 2418 | (write-region "foo" nil (expand-file-name "foo" source)) |
| @@ -2437,8 +2435,7 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 2437 | (unwind-protect | 2435 | (unwind-protect |
| 2438 | ;; FIXME: This fails on my QNAP server, see | 2436 | ;; FIXME: This fails on my QNAP server, see |
| 2439 | ;; /share/Web/owncloud/data/owncloud.log | 2437 | ;; /share/Web/owncloud/data/owncloud.log |
| 2440 | (unless | 2438 | (unless (tramp--test-nextcloud-p) |
| 2441 | (and (tramp--test-nextcloud-p) (not (file-remote-p source))) | ||
| 2442 | (make-directory source) | 2439 | (make-directory source) |
| 2443 | (should (file-directory-p source)) | 2440 | (should (file-directory-p source)) |
| 2444 | (write-region "foo" nil (expand-file-name "foo" source)) | 2441 | (write-region "foo" nil (expand-file-name "foo" source)) |
| @@ -4407,7 +4404,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4407 | "foo" | 4404 | "foo" |
| 4408 | (funcall | 4405 | (funcall |
| 4409 | this-shell-command-to-string | 4406 | this-shell-command-to-string |
| 4410 | (format "echo -n ${%s:?bla}" envvar)))))) | 4407 | (format "echo -n ${%s:-bla}" envvar)))))) |
| 4411 | 4408 | ||
| 4412 | (unwind-protect | 4409 | (unwind-protect |
| 4413 | ;; Set the empty value. | 4410 | ;; Set the empty value. |
| @@ -4419,7 +4416,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4419 | "bla" | 4416 | "bla" |
| 4420 | (funcall | 4417 | (funcall |
| 4421 | this-shell-command-to-string | 4418 | this-shell-command-to-string |
| 4422 | (format "echo -n ${%s:?bla}" envvar)))) | 4419 | (format "echo -n ${%s:-bla}" envvar)))) |
| 4423 | ;; Variable is set. | 4420 | ;; Variable is set. |
| 4424 | (should | 4421 | (should |
| 4425 | (string-match | 4422 | (string-match |
| @@ -4441,7 +4438,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4441 | "foo" | 4438 | "foo" |
| 4442 | (funcall | 4439 | (funcall |
| 4443 | this-shell-command-to-string | 4440 | this-shell-command-to-string |
| 4444 | (format "echo -n ${%s:?bla}" envvar)))) | 4441 | (format "echo -n ${%s:-bla}" envvar)))) |
| 4445 | (let ((process-environment | 4442 | (let ((process-environment |
| 4446 | (cons envvar process-environment))) | 4443 | (cons envvar process-environment))) |
| 4447 | ;; Variable is unset. | 4444 | ;; Variable is unset. |
| @@ -4450,12 +4447,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4450 | "bla" | 4447 | "bla" |
| 4451 | (funcall | 4448 | (funcall |
| 4452 | this-shell-command-to-string | 4449 | this-shell-command-to-string |
| 4453 | (format "echo -n ${%s:?bla}" envvar)))) | 4450 | (format "echo -n ${%s:-bla}" envvar)))) |
| 4454 | ;; Variable is unset. | 4451 | ;; Variable is unset. |
| 4455 | (should-not | 4452 | (should-not |
| 4456 | (string-match | 4453 | (string-match |
| 4457 | (regexp-quote envvar) | 4454 | (regexp-quote envvar) |
| 4458 | (funcall this-shell-command-to-string "env"))))))))) | 4455 | ;; We must remove PS1, the output is truncated otherwise. |
| 4456 | (funcall | ||
| 4457 | this-shell-command-to-string "printenv | grep -v PS1"))))))))) | ||
| 4459 | 4458 | ||
| 4460 | ;; This test is inspired by Bug#27009. | 4459 | ;; This test is inspired by Bug#27009. |
| 4461 | (ert-deftest tramp-test33-environment-variables-and-port-numbers () | 4460 | (ert-deftest tramp-test33-environment-variables-and-port-numbers () |
| @@ -5303,7 +5302,7 @@ This requires restrictions of file name syntax." | |||
| 5303 | ;; of process output. So we unset it temporarily. | 5302 | ;; of process output. So we unset it temporarily. |
| 5304 | (setenv "PS1") | 5303 | (setenv "PS1") |
| 5305 | (with-temp-buffer | 5304 | (with-temp-buffer |
| 5306 | (should (zerop (process-file "env" nil t nil))) | 5305 | (should (zerop (process-file "printenv" nil t nil))) |
| 5307 | (goto-char (point-min)) | 5306 | (goto-char (point-min)) |
| 5308 | (should | 5307 | (should |
| 5309 | (re-search-forward | 5308 | (re-search-forward |
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index b1cf7e8806a..c5ad1dfb862 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el | |||
| @@ -1351,7 +1351,7 @@ this is an arbitrarily | |||
| 1351 | expected))))) | 1351 | expected))))) |
| 1352 | 1352 | ||
| 1353 | 1353 | ||
| 1354 | ;;; Autofill | 1354 | ;;; Filling |
| 1355 | 1355 | ||
| 1356 | (ert-deftest python-auto-fill-docstring () | 1356 | (ert-deftest python-auto-fill-docstring () |
| 1357 | (python-tests-with-temp-buffer | 1357 | (python-tests-with-temp-buffer |
| @@ -1368,6 +1368,17 @@ def some_function(arg1, | |||
| 1368 | (forward-line 1) | 1368 | (forward-line 1) |
| 1369 | (should (= docindent (current-indentation)))))) | 1369 | (should (= docindent (current-indentation)))))) |
| 1370 | 1370 | ||
| 1371 | (ert-deftest python-fill-docstring () | ||
| 1372 | (python-tests-with-temp-buffer | ||
| 1373 | "\ | ||
| 1374 | r'''aaa | ||
| 1375 | |||
| 1376 | this is a test this is a test this is a test this is a test this is a test this is a test. | ||
| 1377 | '''" | ||
| 1378 | (search-forward "test.") | ||
| 1379 | (fill-paragraph) | ||
| 1380 | (should (= (current-indentation) 0)))) | ||
| 1381 | |||
| 1371 | 1382 | ||
| 1372 | ;;; Mark | 1383 | ;;; Mark |
| 1373 | 1384 | ||
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el index f7bf2d93658..f42d47c2bfb 100644 --- a/test/lisp/replace-tests.el +++ b/test/lisp/replace-tests.el | |||
| @@ -514,7 +514,9 @@ Return the last evalled form in BODY." | |||
| 514 | (should | 514 | (should |
| 515 | (replace-tests-with-undo | 515 | (replace-tests-with-undo |
| 516 | input "theorem \\([0-9]+\\)" | 516 | input "theorem \\([0-9]+\\)" |
| 517 | "theorem \\\\ref{theo_\\1}" | 517 | '(replace-eval-replacement |
| 518 | replace-quote | ||
| 519 | (format "theorem \\\\ref{theo_%d}" (1+ (string-to-number (match-string 1))))) | ||
| 518 | ((?\s . (1 2)) (?U . (3))) | 520 | ((?\s . (1 2)) (?U . (3))) |
| 519 | ?q | 521 | ?q |
| 520 | (string= input (buffer-string))))) | 522 | (string= input (buffer-string))))) |
| @@ -530,4 +532,18 @@ Return the last evalled form in BODY." | |||
| 530 | ?q | 532 | ?q |
| 531 | (string= expected (buffer-string)))))) | 533 | (string= expected (buffer-string)))))) |
| 532 | 534 | ||
| 535 | (ert-deftest query-replace-undo-bug37287 () | ||
| 536 | "Test for https://debbugs.gnu.org/37287 ." | ||
| 537 | (let ((input "foo-1\nfoo-2\nfoo-3") | ||
| 538 | (expected "foo-2\nfoo-2\nfoo-3")) | ||
| 539 | (should | ||
| 540 | (replace-tests-with-undo | ||
| 541 | input "\\([0-9]\\)" | ||
| 542 | '(replace-eval-replacement | ||
| 543 | replace-quote | ||
| 544 | (format "%d" (1+ (string-to-number (match-string 1))))) | ||
| 545 | ((?\s . (1 2 4)) (?U . (3))) | ||
| 546 | ?q | ||
| 547 | (string= expected (buffer-string)))))) | ||
| 548 | |||
| 533 | ;;; replace-tests.el ends here | 549 | ;;; replace-tests.el ends here |
diff --git a/test/lisp/shadowfile-tests.el b/test/lisp/shadowfile-tests.el index a93664f6536..7caddc53d75 100644 --- a/test/lisp/shadowfile-tests.el +++ b/test/lisp/shadowfile-tests.el | |||
| @@ -64,9 +64,14 @@ | |||
| 64 | "Temporary directory for Tramp tests.") | 64 | "Temporary directory for Tramp tests.") |
| 65 | 65 | ||
| 66 | (setq password-cache-expiry nil | 66 | (setq password-cache-expiry nil |
| 67 | shadow-debug t | 67 | shadow-debug nil |
| 68 | tramp-verbose 0 | 68 | tramp-verbose 0 |
| 69 | tramp-message-show-message nil) | 69 | tramp-message-show-message nil |
| 70 | ;; On macOS, `temporary-file-directory' is a symlinked directory. | ||
| 71 | temporary-file-directory (file-truename temporary-file-directory) | ||
| 72 | shadow-test-remote-temporary-file-directory | ||
| 73 | (ignore-errors | ||
| 74 | (file-truename shadow-test-remote-temporary-file-directory))) | ||
| 70 | 75 | ||
| 71 | ;; This should happen on hydra only. | 76 | ;; This should happen on hydra only. |
| 72 | (when (getenv "EMACS_HYDRA_CI") | 77 | (when (getenv "EMACS_HYDRA_CI") |
| @@ -718,8 +723,6 @@ guaranteed by the originator of a cluster definition." | |||
| 718 | (shadow-info-file shadow-test-info-file) | 723 | (shadow-info-file shadow-test-info-file) |
| 719 | (shadow-todo-file shadow-test-todo-file) | 724 | (shadow-todo-file shadow-test-todo-file) |
| 720 | (shadow-inhibit-message t) | 725 | (shadow-inhibit-message t) |
| 721 | (shadow-test-remote-temporary-file-directory | ||
| 722 | (file-truename shadow-test-remote-temporary-file-directory)) | ||
| 723 | shadow-clusters shadow-literal-groups shadow-regexp-groups | 726 | shadow-clusters shadow-literal-groups shadow-regexp-groups |
| 724 | shadow-files-to-copy | 727 | shadow-files-to-copy |
| 725 | cluster1 cluster2 primary regexp file) | 728 | cluster1 cluster2 primary regexp file) |
| @@ -858,8 +861,6 @@ guaranteed by the originator of a cluster definition." | |||
| 858 | (shadow-info-file shadow-test-info-file) | 861 | (shadow-info-file shadow-test-info-file) |
| 859 | (shadow-todo-file shadow-test-todo-file) | 862 | (shadow-todo-file shadow-test-todo-file) |
| 860 | (shadow-inhibit-message t) | 863 | (shadow-inhibit-message t) |
| 861 | (shadow-test-remote-temporary-file-directory | ||
| 862 | (file-truename shadow-test-remote-temporary-file-directory)) | ||
| 863 | (shadow-noquery t) | 864 | (shadow-noquery t) |
| 864 | shadow-clusters shadow-files-to-copy | 865 | shadow-clusters shadow-files-to-copy |
| 865 | cluster1 cluster2 primary regexp file mocked-input) | 866 | cluster1 cluster2 primary regexp file mocked-input) |
diff --git a/test/src/print-tests.el b/test/src/print-tests.el index 8e377d71808..26d49a5ffba 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el | |||
| @@ -21,42 +21,86 @@ | |||
| 21 | 21 | ||
| 22 | (require 'ert) | 22 | (require 'ert) |
| 23 | 23 | ||
| 24 | (ert-deftest print-hex-backslash () | 24 | ;; Support sharing test code with cl-print-tests. |
| 25 | |||
| 26 | (defalias 'print-tests--prin1-to-string #'identity | ||
| 27 | "The function to print to a string which is under test.") | ||
| 28 | |||
| 29 | (defmacro print-tests--deftest (name arg &rest docstring-keys-and-body) | ||
| 30 | "Test both print.c and cl-print.el at once." | ||
| 31 | (declare (debug ert-deftest) | ||
| 32 | (doc-string 3) | ||
| 33 | (indent 2)) | ||
| 34 | (let ((clname (intern (concat (symbol-name name) "-cl-print"))) | ||
| 35 | (doc (when (stringp (car-safe docstring-keys-and-body)) | ||
| 36 | (list (pop docstring-keys-and-body)))) | ||
| 37 | (keys-and-values nil)) | ||
| 38 | (while (keywordp (car-safe docstring-keys-and-body)) | ||
| 39 | (let ((key (pop docstring-keys-and-body)) | ||
| 40 | (val (pop docstring-keys-and-body))) | ||
| 41 | (push val keys-and-values) | ||
| 42 | (push key keys-and-values))) | ||
| 43 | `(progn | ||
| 44 | ;; Set print-tests--prin1-to-string at both declaration and | ||
| 45 | ;; runtime, so that it can be used by the :expected-result | ||
| 46 | ;; keyword. | ||
| 47 | (cl-letf (((symbol-function #'print-tests--prin1-to-string) | ||
| 48 | #'prin1-to-string)) | ||
| 49 | (ert-deftest ,name ,arg | ||
| 50 | ,@doc | ||
| 51 | ,@keys-and-values | ||
| 52 | (cl-letf (((symbol-function #'print-tests--prin1-to-string) | ||
| 53 | #'prin1-to-string)) | ||
| 54 | ,@docstring-keys-and-body))) | ||
| 55 | (cl-letf (((symbol-function #'print-tests--prin1-to-string) | ||
| 56 | #'cl-prin1-to-string)) | ||
| 57 | (ert-deftest ,clname ,arg | ||
| 58 | ,@doc | ||
| 59 | ,@keys-and-values | ||
| 60 | (cl-letf (((symbol-function #'print-tests--prin1-to-string) | ||
| 61 | #'cl-prin1-to-string)) | ||
| 62 | ,@docstring-keys-and-body)))))) | ||
| 63 | |||
| 64 | (print-tests--deftest print-hex-backslash () | ||
| 25 | (should (string= (let ((print-escape-multibyte t) | 65 | (should (string= (let ((print-escape-multibyte t) |
| 26 | (print-escape-newlines t)) | 66 | (print-escape-newlines t)) |
| 27 | (prin1-to-string "\u00A2\ff")) | 67 | (print-tests--prin1-to-string "\u00A2\ff")) |
| 28 | "\"\\x00a2\\ff\""))) | 68 | "\"\\x00a2\\ff\""))) |
| 29 | 69 | ||
| 30 | (defun print-tests--prints-with-charset-p (ch odd-charset) | 70 | (defun print-tests--prints-with-charset-p (ch odd-charset) |
| 31 | "Return t if `prin1-to-string' prints CH with the `charset' property. | 71 | "Return t if print function being tested prints CH with the `charset' property. |
| 32 | CH is propertized with a `charset' value according to | 72 | CH is propertized with a `charset' value according to |
| 33 | ODD-CHARSET: if nil, then use the one returned by `char-charset', | 73 | ODD-CHARSET: if nil, then use the one returned by `char-charset', |
| 34 | otherwise, use a different charset." | 74 | otherwise, use a different charset." |
| 35 | (integerp | 75 | (integerp |
| 36 | (string-match | 76 | (string-match |
| 37 | "charset" | 77 | "charset" |
| 38 | (prin1-to-string | 78 | (print-tests--prin1-to-string |
| 39 | (propertize (string ch) | 79 | (propertize (string ch) |
| 40 | 'charset | 80 | 'charset |
| 41 | (if odd-charset | 81 | (if odd-charset |
| 42 | (cl-find (char-charset ch) charset-list :test-not #'eq) | 82 | (cl-find (char-charset ch) charset-list :test-not #'eq) |
| 43 | (char-charset ch))))))) | 83 | (char-charset ch))))))) |
| 44 | 84 | ||
| 45 | (ert-deftest print-charset-text-property-nil () | 85 | (print-tests--deftest print-charset-text-property-nil () |
| 86 | :expected-result (if (eq (symbol-function #'print-tests--prin1-to-string) | ||
| 87 | #'cl-prin1-to-string) :failed :passed) | ||
| 46 | (let ((print-charset-text-property nil)) | 88 | (let ((print-charset-text-property nil)) |
| 47 | (should-not (print-tests--prints-with-charset-p ?\xf6 t)) ; Bug#31376. | 89 | (should-not (print-tests--prints-with-charset-p ?\xf6 t)) ; Bug#31376. |
| 48 | (should-not (print-tests--prints-with-charset-p ?a t)) | 90 | (should-not (print-tests--prints-with-charset-p ?a t)) |
| 49 | (should-not (print-tests--prints-with-charset-p ?\xf6 nil)) | 91 | (should-not (print-tests--prints-with-charset-p ?\xf6 nil)) |
| 50 | (should-not (print-tests--prints-with-charset-p ?a nil)))) | 92 | (should-not (print-tests--prints-with-charset-p ?a nil)))) |
| 51 | 93 | ||
| 52 | (ert-deftest print-charset-text-property-default () | 94 | (print-tests--deftest print-charset-text-property-default () |
| 95 | :expected-result (if (eq (symbol-function #'print-tests--prin1-to-string) | ||
| 96 | #'cl-prin1-to-string) :failed :passed) | ||
| 53 | (let ((print-charset-text-property 'default)) | 97 | (let ((print-charset-text-property 'default)) |
| 54 | (should (print-tests--prints-with-charset-p ?\xf6 t)) | 98 | (should (print-tests--prints-with-charset-p ?\xf6 t)) |
| 55 | (should-not (print-tests--prints-with-charset-p ?a t)) | 99 | (should-not (print-tests--prints-with-charset-p ?a t)) |
| 56 | (should-not (print-tests--prints-with-charset-p ?\xf6 nil)) | 100 | (should-not (print-tests--prints-with-charset-p ?\xf6 nil)) |
| 57 | (should-not (print-tests--prints-with-charset-p ?a nil)))) | 101 | (should-not (print-tests--prints-with-charset-p ?a nil)))) |
| 58 | 102 | ||
| 59 | (ert-deftest print-charset-text-property-t () | 103 | (print-tests--deftest print-charset-text-property-t () |
| 60 | (let ((print-charset-text-property t)) | 104 | (let ((print-charset-text-property t)) |
| 61 | (should (print-tests--prints-with-charset-p ?\xf6 t)) | 105 | (should (print-tests--prints-with-charset-p ?\xf6 t)) |
| 62 | (should (print-tests--prints-with-charset-p ?a t)) | 106 | (should (print-tests--prints-with-charset-p ?a t)) |
| @@ -94,7 +138,7 @@ otherwise, use a different charset." | |||
| 94 | (buffer-string)) | 138 | (buffer-string)) |
| 95 | "--------\n")))) | 139 | "--------\n")))) |
| 96 | 140 | ||
| 97 | (ert-deftest print-read-roundtrip () | 141 | (print-tests--deftest print-read-roundtrip () |
| 98 | (let ((syms (list '## '& '* '+ '- '/ '0E '0e '< '= '> 'E 'E0 'NaN '\" | 142 | (let ((syms (list '## '& '* '+ '- '/ '0E '0e '< '= '> 'E 'E0 'NaN '\" |
| 99 | '\# '\#x0 '\' '\'\' '\( '\) '\+00 '\, '\-0 '\. '\.0 | 143 | '\# '\#x0 '\' '\'\' '\( '\) '\+00 '\, '\-0 '\. '\.0 |
| 100 | '\0 '\0.0 '\0E0 '\0e0 '\1E+ '\1E+NaN '\1e+ '\1e+NaN | 144 | '\0 '\0.0 '\0E0 '\0e0 '\1E+ '\1E+NaN '\1e+ '\1e+NaN |
| @@ -105,16 +149,207 @@ otherwise, use a different charset." | |||
| 105 | (intern "\N{ZERO WIDTH SPACE}") | 149 | (intern "\N{ZERO WIDTH SPACE}") |
| 106 | (intern "\0")))) | 150 | (intern "\0")))) |
| 107 | (dolist (sym syms) | 151 | (dolist (sym syms) |
| 108 | (should (eq (read (prin1-to-string sym)) sym)) | 152 | (should (eq (read (print-tests--prin1-to-string sym)) sym)) |
| 109 | (dolist (sym1 syms) | 153 | (dolist (sym1 syms) |
| 110 | (let ((sym2 (intern (concat (symbol-name sym) (symbol-name sym1))))) | 154 | (let ((sym2 (intern (concat (symbol-name sym) (symbol-name sym1))))) |
| 111 | (should (eq (read (prin1-to-string sym2)) sym2))))))) | 155 | (should (eq (read (print-tests--prin1-to-string sym2)) sym2))))))) |
| 112 | 156 | ||
| 113 | (ert-deftest print-bignum () | 157 | (print-tests--deftest print-bignum () |
| 114 | (let* ((str "999999999999999999999999999999999") | 158 | (let* ((str "999999999999999999999999999999999") |
| 115 | (val (read str))) | 159 | (val (read str))) |
| 116 | (should (> val most-positive-fixnum)) | 160 | (should (> val most-positive-fixnum)) |
| 117 | (should (equal (prin1-to-string val) str)))) | 161 | (should (equal (print-tests--prin1-to-string val) str)))) |
| 162 | |||
| 163 | (print-tests--deftest print-tests-print-gensym () | ||
| 164 | "Printing observes `print-gensym'." | ||
| 165 | (let* ((sym1 (gensym)) | ||
| 166 | (syms (list sym1 (gensym "x") (make-symbol "y") sym1))) | ||
| 167 | (let* ((print-circle nil) | ||
| 168 | (printed-with (let ((print-gensym t)) | ||
| 169 | (print-tests--prin1-to-string syms))) | ||
| 170 | (printed-without (let ((print-gensym nil)) | ||
| 171 | (print-tests--prin1-to-string syms)))) | ||
| 172 | (should (string-match | ||
| 173 | "(#:\\(g[[:digit:]]+\\) #:x[[:digit:]]+ #:y #:\\(g[[:digit:]]+\\))$" | ||
| 174 | printed-with)) | ||
| 175 | (should (string= (match-string 1 printed-with) | ||
| 176 | (match-string 2 printed-with))) | ||
| 177 | (should (string-match "(g[[:digit:]]+ x[[:digit:]]+ y g[[:digit:]]+)$" | ||
| 178 | printed-without))) | ||
| 179 | (let* ((print-circle t) | ||
| 180 | (printed-with (let ((print-gensym t)) | ||
| 181 | (print-tests--prin1-to-string syms))) | ||
| 182 | (printed-without (let ((print-gensym nil)) | ||
| 183 | (print-tests--prin1-to-string syms)))) | ||
| 184 | (should (string-match "(#1=#:g[[:digit:]]+ #:x[[:digit:]]+ #:y #1#)$" | ||
| 185 | printed-with)) | ||
| 186 | (should (string-match "(g[[:digit:]]+ x[[:digit:]]+ y g[[:digit:]]+)$" | ||
| 187 | printed-without))))) | ||
| 188 | |||
| 189 | (print-tests--deftest print-tests-continuous-numbering () | ||
| 190 | "Printing observes `print-continuous-numbering'." | ||
| 191 | ;; cl-print does not support print-continuous-numbering. | ||
| 192 | :expected-result (if (eq (symbol-function #'print-tests--prin1-to-string) | ||
| 193 | #'cl-prin1-to-string) :failed :passed) | ||
| 194 | (let* ((x (list 1)) | ||
| 195 | (y "hello") | ||
| 196 | (g (gensym)) | ||
| 197 | (g2 (gensym)) | ||
| 198 | (print-circle t) | ||
| 199 | (print-gensym t)) | ||
| 200 | (let ((print-continuous-numbering t) | ||
| 201 | (print-number-table nil)) | ||
| 202 | (should (string-match | ||
| 203 | "(#1=(1) #1# #2=\"hello\" #2#)(#3=#:g[[:digit:]]+ #3#)(#1# #2# #3#)#2#$" | ||
| 204 | (mapconcat #'print-tests--prin1-to-string `((,x ,x ,y ,y) (,g ,g) (,x ,y ,g) ,y) "")))) | ||
| 205 | |||
| 206 | ;; This is the special case for byte-compile-output-docform | ||
| 207 | ;; mentioned in a comment in print_preprocess. When | ||
| 208 | ;; print-continuous-numbering and print-circle and print-gensym | ||
| 209 | ;; are all non-nil, print all gensyms with numbers even if they | ||
| 210 | ;; only occur once. | ||
| 211 | (let ((print-continuous-numbering t) | ||
| 212 | (print-number-table nil)) | ||
| 213 | (should (string-match | ||
| 214 | "(#1=#:g[[:digit:]]+ #2=#:g[[:digit:]]+)$" | ||
| 215 | (print-tests--prin1-to-string (list g g2))))))) | ||
| 216 | |||
| 217 | (cl-defstruct print--test a b) | ||
| 218 | |||
| 219 | (print-tests--deftest print-tests-1 () | ||
| 220 | "Test print code." | ||
| 221 | (let ((x (make-print--test :a 1 :b 2)) | ||
| 222 | (rec (cond | ||
| 223 | ((eq (symbol-function #'print-tests--prin1-to-string) 'prin1-to-string) | ||
| 224 | "#s(print--test 1 2)") | ||
| 225 | ((eq (symbol-function #'print-tests--prin1-to-string) 'cl-prin1-to-string) | ||
| 226 | "#s(print--test :a 1 :b 2)") | ||
| 227 | (t (cl-assert nil))))) | ||
| 228 | |||
| 229 | (let ((print-circle nil)) | ||
| 230 | (should (equal (print-tests--prin1-to-string `((x . ,x) (y . ,x))) | ||
| 231 | (format "((x . %s) (y . %s))" rec rec)))) | ||
| 232 | (let ((print-circle t)) | ||
| 233 | (should (equal (print-tests--prin1-to-string `((x . ,x) (y . ,x))) | ||
| 234 | (format "((x . #1=%s) (y . #1#))" rec)))))) | ||
| 235 | |||
| 236 | (print-tests--deftest print-tests-2 () | ||
| 237 | (let ((x (record 'foo 1 2 3))) | ||
| 238 | (should (equal | ||
| 239 | x | ||
| 240 | (car (read-from-string (with-output-to-string (prin1 x)))))) | ||
| 241 | (let ((print-circle t)) | ||
| 242 | (should (string-match | ||
| 243 | "\\`(#1=#s(foo 1 2 3) #1#)\\'" | ||
| 244 | (print-tests--prin1-to-string (list x x))))))) | ||
| 245 | |||
| 246 | (cl-defstruct (print-tests-struct | ||
| 247 | (:constructor print-tests-con)) | ||
| 248 | a b c d e) | ||
| 249 | |||
| 250 | (print-tests--deftest print-tests-3 () | ||
| 251 | "Printing observes `print-length'." | ||
| 252 | (let ((long-list (make-list 5 'a)) | ||
| 253 | (long-vec (make-vector 5 'b)) | ||
| 254 | ;; (long-struct (print-tests-con)) | ||
| 255 | ;; (long-string (make-string 5 ?a)) | ||
| 256 | (print-length 4)) | ||
| 257 | (should (equal "(a a a a ...)" (print-tests--prin1-to-string long-list))) | ||
| 258 | (should (equal "[b b b b ...]" (print-tests--prin1-to-string long-vec))) | ||
| 259 | ;; This one only prints 3 nils. Should it print 4? | ||
| 260 | ;; (should (equal "#s(print-tests-struct nil nil nil nil ...)" | ||
| 261 | ;; (print-tests--prin1-to-string long-struct))) | ||
| 262 | ;; This one is only supported by cl-print | ||
| 263 | ;; (should (equal "\"aaaa...\"" (cl-print-tests--prin1-to-string long-string))) | ||
| 264 | )) | ||
| 265 | |||
| 266 | (print-tests--deftest print-tests-4 () | ||
| 267 | "Printing observes `print-level'." | ||
| 268 | (let* ((deep-list '(a (b (c (d (e)))))) | ||
| 269 | (buried-vector '(a (b (c (d [e]))))) | ||
| 270 | (deep-struct (print-tests-con)) | ||
| 271 | (buried-struct `(a (b (c (d ,deep-struct))))) | ||
| 272 | (buried-string '(a (b (c (d #("hello" 0 5 (print-test t))))))) | ||
| 273 | (buried-simple-string '(a (b (c (d "hello"))))) | ||
| 274 | (print-level 4)) | ||
| 275 | (setf (print-tests-struct-a deep-struct) deep-list) | ||
| 276 | (should (equal "(a (b (c (d ...))))" (print-tests--prin1-to-string deep-list))) | ||
| 277 | (should (equal "(a (b (c (d \"hello\"))))" | ||
| 278 | (print-tests--prin1-to-string buried-simple-string))) | ||
| 279 | (cond | ||
| 280 | ((eq (symbol-function #'print-tests--prin1-to-string) #'prin1-to-string) | ||
| 281 | (should (equal "(a (b (c (d [e]))))" (print-tests--prin1-to-string buried-vector))) | ||
| 282 | (should (equal "(a (b (c (d #s(print-tests-struct ... nil nil nil nil)))))" | ||
| 283 | (print-tests--prin1-to-string buried-struct))) | ||
| 284 | (should (equal "(a (b (c (d #(\"hello\" 0 5 ...)))))" | ||
| 285 | (print-tests--prin1-to-string buried-string))) | ||
| 286 | (should (equal "#s(print-tests-struct (a (b (c ...))) nil nil nil nil)" | ||
| 287 | (print-tests--prin1-to-string deep-struct)))) | ||
| 288 | |||
| 289 | ((eq (symbol-function #'print-tests--prin1-to-string) #'cl-prin1-to-string) | ||
| 290 | (should (equal "(a (b (c (d ...))))" (print-tests--prin1-to-string buried-vector))) | ||
| 291 | (should (equal "(a (b (c (d ...))))" (print-tests--prin1-to-string buried-struct))) | ||
| 292 | (should (equal "(a (b (c (d ...))))" (print-tests--prin1-to-string buried-string))) | ||
| 293 | (should (equal "#s(print-tests-struct :a (a (b (c ...))) :b nil :c nil :d nil :e nil)" | ||
| 294 | (print-tests--prin1-to-string deep-struct)))) | ||
| 295 | (t (cl-assert nil))))) | ||
| 296 | |||
| 297 | (print-tests--deftest print-tests-5 () | ||
| 298 | "Printing observes `print-quoted'." | ||
| 299 | (let ((quoted-stuff '('a #'b `(,c ,@d)))) | ||
| 300 | (let ((print-quoted t)) | ||
| 301 | (should (equal "('a #'b `(,c ,@d))" | ||
| 302 | (print-tests--prin1-to-string quoted-stuff)))) | ||
| 303 | (let ((print-quoted nil)) | ||
| 304 | (should (equal "((quote a) (function b) (\\` ((\\, c) (\\,@ d))))" | ||
| 305 | (print-tests--prin1-to-string quoted-stuff)))))) | ||
| 306 | |||
| 307 | (print-tests--deftest print-tests-strings () | ||
| 308 | "Can print strings and propertized strings." | ||
| 309 | (let* ((str1 "abcdefghij") | ||
| 310 | (str2 #("abcdefghij" 3 6 (bold t) 7 9 (italic t))) | ||
| 311 | (str3 #("abcdefghij" 0 10 (test t))) | ||
| 312 | (obj '(a b)) | ||
| 313 | ;; Since the byte compiler reuses string literals, | ||
| 314 | ;; and the put-text-property call is destructive, use | ||
| 315 | ;; copy-sequence to make a new string. | ||
| 316 | (str4 (copy-sequence "abcdefghij"))) | ||
| 317 | (put-text-property 0 5 'test obj str4) | ||
| 318 | (put-text-property 7 10 'test obj str4) | ||
| 319 | |||
| 320 | (should (equal "\"abcdefghij\"" (print-tests--prin1-to-string str1))) | ||
| 321 | (should (equal "#(\"abcdefghij\" 3 6 (bold t) 7 9 (italic t))" | ||
| 322 | (print-tests--prin1-to-string str2))) | ||
| 323 | (should (equal "#(\"abcdefghij\" 0 10 (test t))" | ||
| 324 | (print-tests--prin1-to-string str3))) | ||
| 325 | (let ((print-circle nil)) | ||
| 326 | (should | ||
| 327 | (equal | ||
| 328 | "#(\"abcdefghij\" 0 5 (test (a b)) 7 10 (test (a b)))" | ||
| 329 | (print-tests--prin1-to-string str4)))) | ||
| 330 | (let ((print-circle t)) | ||
| 331 | (should | ||
| 332 | (equal | ||
| 333 | "#(\"abcdefghij\" 0 5 (test #1=(a b)) 7 10 (test #1#))" | ||
| 334 | (print-tests--prin1-to-string str4)))))) | ||
| 335 | |||
| 336 | (print-tests--deftest print-circle () | ||
| 337 | (let ((x '(#1=(a . #1#) #1#))) | ||
| 338 | (let ((print-circle nil)) | ||
| 339 | (should (string-match "\\`((a . #[0-9]) (a . #[0-9]))\\'" | ||
| 340 | (print-tests--prin1-to-string x)))) | ||
| 341 | (let ((print-circle t)) | ||
| 342 | (should (equal "(#1=(a . #1#) #1#)" (print-tests--prin1-to-string x)))))) | ||
| 343 | |||
| 344 | (print-tests--deftest print-circle-2 () | ||
| 345 | ;; Bug#31146. | ||
| 346 | (let ((x '(0 . #1=(0 . #1#)))) | ||
| 347 | (let ((print-circle nil)) | ||
| 348 | (should (string-match "\\`(0 0 . #[0-9])\\'" | ||
| 349 | (print-tests--prin1-to-string x)))) | ||
| 350 | (let ((print-circle t)) | ||
| 351 | (should (equal "(0 . #1=(0 . #1#))" (print-tests--prin1-to-string x)))))) | ||
| 352 | |||
| 118 | 353 | ||
| 119 | (provide 'print-tests) | 354 | (provide 'print-tests) |
| 120 | ;;; print-tests.el ends here | 355 | ;;; print-tests.el ends here |