diff options
| author | Yuan Fu | 2022-08-29 11:41:10 -0700 |
|---|---|---|
| committer | Yuan Fu | 2022-08-29 11:41:10 -0700 |
| commit | 77d5a0cf9fc4a6dc44f0c6ee5e3295e0eea08273 (patch) | |
| tree | 969937ec44ce5ddf9447b074aa15314e0b9e8e95 /test/src | |
| parent | e98b4715bb986524bde9356b62429af9786ae716 (diff) | |
| parent | df2f6fb7fc4b79834ae40db8be2ccdc1e4a273f1 (diff) | |
| download | emacs-77d5a0cf9fc4a6dc44f0c6ee5e3295e0eea08273.tar.gz emacs-77d5a0cf9fc4a6dc44f0c6ee5e3295e0eea08273.zip | |
Merge remote-tracking branch 'origin/master' into feature/tree-sitter
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/buffer-tests.el | 28 | ||||
| -rw-r--r-- | test/src/callint-tests.el | 13 | ||||
| -rw-r--r-- | test/src/coding-tests.el | 25 | ||||
| -rw-r--r-- | test/src/comp-resources/comp-test-funcs.el | 2 | ||||
| -rw-r--r-- | test/src/comp-tests.el | 10 | ||||
| -rw-r--r-- | test/src/data-tests.el | 17 | ||||
| -rw-r--r-- | test/src/fileio-tests.el | 16 | ||||
| -rw-r--r-- | test/src/fns-tests.el | 137 | ||||
| -rw-r--r-- | test/src/font-tests.el | 7 | ||||
| -rw-r--r-- | test/src/image-tests.el | 2 | ||||
| -rw-r--r-- | test/src/json-tests.el | 7 | ||||
| -rw-r--r-- | test/src/keymap-tests.el | 34 | ||||
| -rw-r--r-- | test/src/lread-resources/lazydoc.el | bin | 0 -> 171 bytes | |||
| -rw-r--r-- | test/src/lread-tests.el | 19 | ||||
| -rw-r--r-- | test/src/print-tests.el | 14 | ||||
| -rw-r--r-- | test/src/process-tests.el | 211 | ||||
| -rw-r--r-- | test/src/timefns-tests.el | 6 | ||||
| -rw-r--r-- | test/src/undo-tests.el | 5 |
18 files changed, 384 insertions, 169 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index 13d48b31a4f..3c6a9208ffa 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el | |||
| @@ -1503,9 +1503,12 @@ with parameters from the *Messages* buffer modification." | |||
| 1503 | 1503 | ||
| 1504 | (ert-deftest test-restore-buffer-modified-p () | 1504 | (ert-deftest test-restore-buffer-modified-p () |
| 1505 | (ert-with-temp-file file | 1505 | (ert-with-temp-file file |
| 1506 | ;; This avoids the annoying "foo and bar are the same file" on | ||
| 1507 | ;; MS-Windows. | ||
| 1508 | (setq file (file-truename file)) | ||
| 1506 | (with-current-buffer (find-file file) | 1509 | (with-current-buffer (find-file file) |
| 1507 | (auto-save-mode 1) | 1510 | (auto-save-mode 1) |
| 1508 | (should-not (buffer-modified-p)) | 1511 | (should-not (eq (buffer-modified-p) t)) |
| 1509 | (insert "foo") | 1512 | (insert "foo") |
| 1510 | (should (buffer-modified-p)) | 1513 | (should (buffer-modified-p)) |
| 1511 | (restore-buffer-modified-p nil) | 1514 | (restore-buffer-modified-p nil) |
| @@ -1522,13 +1525,34 @@ with parameters from the *Messages* buffer modification." | |||
| 1522 | (delete-file buffer-auto-save-file-name)))) | 1525 | (delete-file buffer-auto-save-file-name)))) |
| 1523 | 1526 | ||
| 1524 | (ert-with-temp-file file | 1527 | (ert-with-temp-file file |
| 1528 | (setq file (file-truename file)) | ||
| 1525 | (with-current-buffer (find-file file) | 1529 | (with-current-buffer (find-file file) |
| 1526 | (auto-save-mode 1) | 1530 | (auto-save-mode 1) |
| 1527 | (should-not (buffer-modified-p)) | 1531 | (should-not (eq (buffer-modified-p) t)) |
| 1528 | (insert "foo") | 1532 | (insert "foo") |
| 1529 | (should (buffer-modified-p)) | 1533 | (should (buffer-modified-p)) |
| 1530 | (should-not (eq (buffer-modified-p) 'autosaved)) | 1534 | (should-not (eq (buffer-modified-p) 'autosaved)) |
| 1531 | (restore-buffer-modified-p 'autosaved) | 1535 | (restore-buffer-modified-p 'autosaved) |
| 1532 | (should (eq (buffer-modified-p) 'autosaved))))) | 1536 | (should (eq (buffer-modified-p) 'autosaved))))) |
| 1533 | 1537 | ||
| 1538 | (ert-deftest test-buffer-chars-modified-ticks () | ||
| 1539 | "Test `buffer-chars-modified-tick'." | ||
| 1540 | (setq temporary-file-directory (file-truename temporary-file-directory)) | ||
| 1541 | (let ((text "foobar") | ||
| 1542 | f1 f2) | ||
| 1543 | (unwind-protect | ||
| 1544 | (progn | ||
| 1545 | (setq f1 (make-temp-file "buf-modiff-tests") | ||
| 1546 | f2 (make-temp-file "buf-modiff-tests")) | ||
| 1547 | (with-current-buffer (find-file f1) | ||
| 1548 | (should (= (buffer-chars-modified-tick) 1)) | ||
| 1549 | (should (= (buffer-chars-modified-tick) (buffer-modified-tick))) | ||
| 1550 | (write-region text nil f2 nil 'silent) | ||
| 1551 | (insert-file-contents f2) | ||
| 1552 | (should (= (buffer-chars-modified-tick) (buffer-modified-tick))) | ||
| 1553 | (should (> (buffer-chars-modified-tick) 1)))) | ||
| 1554 | (if f1 (delete-file f1)) | ||
| 1555 | (if f2 (delete-file f2)) | ||
| 1556 | ))) | ||
| 1557 | |||
| 1534 | ;;; buffer-tests.el ends here | 1558 | ;;; buffer-tests.el ends here |
diff --git a/test/src/callint-tests.el b/test/src/callint-tests.el index d964fc3c1f3..5a633fdc2bd 100644 --- a/test/src/callint-tests.el +++ b/test/src/callint-tests.el | |||
| @@ -52,4 +52,17 @@ | |||
| 52 | (call-interactively #'ignore t)) | 52 | (call-interactively #'ignore t)) |
| 53 | (should (= (length command-history) history-length)))) | 53 | (should (= (length command-history) history-length)))) |
| 54 | 54 | ||
| 55 | (defun callint-test-int-args (foo bar &optional zot) | ||
| 56 | (declare (interactive-args | ||
| 57 | (bar 10) | ||
| 58 | (zot 11))) | ||
| 59 | (interactive (list 1 1 1)) | ||
| 60 | (+ foo bar zot)) | ||
| 61 | |||
| 62 | (ert-deftest test-interactive-args () | ||
| 63 | (let ((history-length 1) | ||
| 64 | (command-history ())) | ||
| 65 | (should (= (call-interactively 'callint-test-int-args t) 3)) | ||
| 66 | (should (equal command-history '((callint-test-int-args 1 10 11)))))) | ||
| 67 | |||
| 55 | ;;; callint-tests.el ends here | 68 | ;;; callint-tests.el ends here |
diff --git a/test/src/coding-tests.el b/test/src/coding-tests.el index de4ddb546df..f65d575d0c2 100644 --- a/test/src/coding-tests.el +++ b/test/src/coding-tests.el | |||
| @@ -61,16 +61,17 @@ | |||
| 61 | ;; Return the contents (specified by CONTENT-TYPE; ascii, latin, or | 61 | ;; Return the contents (specified by CONTENT-TYPE; ascii, latin, or |
| 62 | ;; binary) of a test file. | 62 | ;; binary) of a test file. |
| 63 | (defun coding-tests-file-contents (content-type) | 63 | (defun coding-tests-file-contents (content-type) |
| 64 | (let* ((ascii "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n") | 64 | (with-suppressed-warnings ((obsolete string-as-unibyte)) |
| 65 | (latin (concat ascii "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ\n")) | 65 | (let* ((ascii "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n") |
| 66 | (binary (string-to-multibyte | 66 | (latin (concat ascii "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ\n")) |
| 67 | (concat (string-as-unibyte latin) | 67 | (binary (string-to-multibyte |
| 68 | (unibyte-string #xC0 #xC1 ?\n))))) | 68 | (concat (string-as-unibyte latin) |
| 69 | (cond ((eq content-type 'ascii) ascii) | 69 | (unibyte-string #xC0 #xC1 ?\n))))) |
| 70 | ((eq content-type 'latin) latin) | 70 | (cond ((eq content-type 'ascii) ascii) |
| 71 | ((eq content-type 'binary) binary) | 71 | ((eq content-type 'latin) latin) |
| 72 | (t | 72 | ((eq content-type 'binary) binary) |
| 73 | (error "Invalid file content type: %s" content-type))))) | 73 | (t |
| 74 | (error "Invalid file content type: %s" content-type)))))) | ||
| 74 | 75 | ||
| 75 | ;; Generate FILE with CONTENTS encoded by CODING-SYSTEM. | 76 | ;; Generate FILE with CONTENTS encoded by CODING-SYSTEM. |
| 76 | ;; whose encoding specified by CODING-SYSTEM. | 77 | ;; whose encoding specified by CODING-SYSTEM. |
| @@ -429,9 +430,5 @@ | |||
| 429 | '((iso-latin-1 3) (us-ascii 1 3)))) | 430 | '((iso-latin-1 3) (us-ascii 1 3)))) |
| 430 | (should-error (check-coding-systems-region "å" nil '(bad-coding-system)))) | 431 | (should-error (check-coding-systems-region "å" nil '(bad-coding-system)))) |
| 431 | 432 | ||
| 432 | ;; Local Variables: | ||
| 433 | ;; byte-compile-warnings: (not obsolete) | ||
| 434 | ;; End: | ||
| 435 | |||
| 436 | (provide 'coding-tests) | 433 | (provide 'coding-tests) |
| 437 | ;;; coding-tests.el ends here | 434 | ;;; coding-tests.el ends here |
diff --git a/test/src/comp-resources/comp-test-funcs.el b/test/src/comp-resources/comp-test-funcs.el index 0a60f4d6cc4..9092f040c80 100644 --- a/test/src/comp-resources/comp-test-funcs.el +++ b/test/src/comp-resources/comp-test-funcs.el | |||
| @@ -515,6 +515,8 @@ | |||
| 515 | (defun comp-test-47868-4-f () | 515 | (defun comp-test-47868-4-f () |
| 516 | #(" " 0 1 (face font-lock-keyword-face))) | 516 | #(" " 0 1 (face font-lock-keyword-face))) |
| 517 | 517 | ||
| 518 | (defun comp-test-48029-nonascii-žžž-f (arg) | ||
| 519 | (when arg t)) | ||
| 518 | 520 | ||
| 519 | 521 | ||
| 520 | ;;;;;;;;;;;;;;;;;;;; | 522 | ;;;;;;;;;;;;;;;;;;;; |
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index e7b534d00ec..1b239cec795 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el | |||
| @@ -508,11 +508,6 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html." | |||
| 508 | (should (string= (comp-test-45635-f :height 180 :family "PragmataPro Liga") | 508 | (should (string= (comp-test-45635-f :height 180 :family "PragmataPro Liga") |
| 509 | "PragmataPro Liga"))) | 509 | "PragmataPro Liga"))) |
| 510 | 510 | ||
| 511 | (comp-deftest 45603-1 () | ||
| 512 | "<https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-12/msg01994.html>" | ||
| 513 | (load (native-compile (ert-resource-file "comp-test-45603.el"))) | ||
| 514 | (should (fboundp 'comp-test-45603--file-local-name))) | ||
| 515 | |||
| 516 | (comp-deftest 46670-1 () | 511 | (comp-deftest 46670-1 () |
| 517 | "<https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-02/msg01413.html>" | 512 | "<https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-02/msg01413.html>" |
| 518 | (should (string= (comp-test-46670-2-f "foo") "foo")) | 513 | (should (string= (comp-test-46670-2-f "foo") "foo")) |
| @@ -532,6 +527,11 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html." | |||
| 532 | (should (eq (comp-test-47868-1-f) (comp-test-47868-3-f))) | 527 | (should (eq (comp-test-47868-1-f) (comp-test-47868-3-f))) |
| 533 | (should (eq (comp-test-47868-2-f) (comp-test-47868-4-f)))) | 528 | (should (eq (comp-test-47868-2-f) (comp-test-47868-4-f)))) |
| 534 | 529 | ||
| 530 | (comp-deftest 48029-1 () | ||
| 531 | "<https://lists.gnu.org/archive/html/bug-gnu-emacs/2022-07/msg00666.html>" | ||
| 532 | (should (subr-native-elisp-p | ||
| 533 | (symbol-function 'comp-test-48029-nonascii-žžž-f)))) | ||
| 534 | |||
| 535 | 535 | ||
| 536 | ;;;;;;;;;;;;;;;;;;;;; | 536 | ;;;;;;;;;;;;;;;;;;;;; |
| 537 | ;; Tromey's tests. ;; | 537 | ;; Tromey's tests. ;; |
diff --git a/test/src/data-tests.el b/test/src/data-tests.el index 7d8535f5f37..0f84b2fb776 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el | |||
| @@ -741,14 +741,15 @@ comparing the subr with a much slower Lisp implementation." | |||
| 741 | (should (= (ash 1000 (* 2 most-negative-fixnum)) 0)) | 741 | (should (= (ash 1000 (* 2 most-negative-fixnum)) 0)) |
| 742 | (should (= (ash -1000 (* 2 most-negative-fixnum)) -1)) | 742 | (should (= (ash -1000 (* 2 most-negative-fixnum)) -1)) |
| 743 | (should (= (ash (* 2 most-negative-fixnum) (* 2 most-negative-fixnum)) -1)) | 743 | (should (= (ash (* 2 most-negative-fixnum) (* 2 most-negative-fixnum)) -1)) |
| 744 | (should (= (lsh most-negative-fixnum 1) | ||
| 745 | (* most-negative-fixnum 2))) | ||
| 746 | (should (= (ash (* 2 most-negative-fixnum) -1) | 744 | (should (= (ash (* 2 most-negative-fixnum) -1) |
| 747 | most-negative-fixnum)) | 745 | most-negative-fixnum)) |
| 748 | (should (= (lsh most-positive-fixnum -1) (/ most-positive-fixnum 2))) | 746 | (with-suppressed-warnings ((suspicious lsh)) |
| 749 | (should (= (lsh most-negative-fixnum -1) (lsh (- most-negative-fixnum) -1))) | 747 | (should (= (lsh most-negative-fixnum 1) |
| 750 | (should (= (lsh -1 -1) most-positive-fixnum)) | 748 | (* most-negative-fixnum 2))) |
| 751 | (should-error (lsh (1- most-negative-fixnum) -1))) | 749 | (should (= (lsh most-positive-fixnum -1) (/ most-positive-fixnum 2))) |
| 750 | (should (= (lsh most-negative-fixnum -1) (lsh (- most-negative-fixnum) -1))) | ||
| 751 | (should (= (lsh -1 -1) most-positive-fixnum)) | ||
| 752 | (should-error (lsh (1- most-negative-fixnum) -1)))) | ||
| 752 | 753 | ||
| 753 | (ert-deftest data-tests-make-local-forwarded-var () ;bug#34318 | 754 | (ert-deftest data-tests-make-local-forwarded-var () ;bug#34318 |
| 754 | ;; Boy, this bug is tricky to trigger. You need to: | 755 | ;; Boy, this bug is tricky to trigger. You need to: |
| @@ -768,4 +769,8 @@ comparing the subr with a much slower Lisp implementation." | |||
| 768 | (default-value 'last-coding-system-used)) | 769 | (default-value 'last-coding-system-used)) |
| 769 | '(no-conversion bug34318))))) | 770 | '(no-conversion bug34318))))) |
| 770 | 771 | ||
| 772 | (ert-deftest data-tests-make_symbol_constant () | ||
| 773 | "Can't set variable marked with 'make_symbol_constant'." | ||
| 774 | (should-error (setq most-positive-fixnum 1) :type 'setting-constant)) | ||
| 775 | |||
| 771 | ;;; data-tests.el ends here | 776 | ;;; data-tests.el ends here |
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index c137ce06f1a..08582c8a862 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el | |||
| @@ -201,4 +201,20 @@ Also check that an encoding error can appear in a symlink." | |||
| 201 | (insert-file-contents "/dev/urandom" nil nil 10) | 201 | (insert-file-contents "/dev/urandom" nil nil 10) |
| 202 | (should (= (buffer-size) 10)))) | 202 | (should (= (buffer-size) 10)))) |
| 203 | 203 | ||
| 204 | (defun fileio-tests--identity-expand-handler (_ file &rest _) | ||
| 205 | file) | ||
| 206 | (put 'fileio-tests--identity-expand-handler 'operations '(expand-file-name)) | ||
| 207 | |||
| 208 | (ert-deftest fileio--file-name-case-insensitive-p () | ||
| 209 | ;; Check that we at least don't crash if given nonexisting files | ||
| 210 | ;; without a directory (bug#56443). | ||
| 211 | |||
| 212 | ;; Use an identity file-name handler, as if called by `ffap'. | ||
| 213 | (let* ((file-name-handler-alist | ||
| 214 | '(("^mailto:" . fileio-tests--identity-expand-handler))) | ||
| 215 | (file "mailto:snowball@hell.com")) | ||
| 216 | ;; Check that `expand-file-name' is identity for this name. | ||
| 217 | (should (equal (expand-file-name file nil) file)) | ||
| 218 | (file-name-case-insensitive-p file))) | ||
| 219 | |||
| 204 | ;;; fileio-tests.el ends here | 220 | ;;; fileio-tests.el ends here |
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index c080c483927..a84cce3ad4e 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -852,24 +852,6 @@ | |||
| 852 | (should-not (plist-get d1 3)) | 852 | (should-not (plist-get d1 3)) |
| 853 | (should-not (plist-get d2 3)))) | 853 | (should-not (plist-get d2 3)))) |
| 854 | 854 | ||
| 855 | (ert-deftest test-cycle-lax-plist-get () | ||
| 856 | (let ((c1 (cyc1 1)) | ||
| 857 | (c2 (cyc2 1 2)) | ||
| 858 | (d1 (dot1 1)) | ||
| 859 | (d2 (dot2 1 2))) | ||
| 860 | (should (lax-plist-get c1 1)) | ||
| 861 | (should (lax-plist-get c2 1)) | ||
| 862 | (should (lax-plist-get d1 1)) | ||
| 863 | (should (lax-plist-get d2 1)) | ||
| 864 | (should-error (lax-plist-get c1 2) :type 'circular-list) | ||
| 865 | (should (lax-plist-get c2 2)) | ||
| 866 | (should-error (lax-plist-get d1 2) :type 'wrong-type-argument) | ||
| 867 | (should (lax-plist-get d2 2)) | ||
| 868 | (should-error (lax-plist-get c1 3) :type 'circular-list) | ||
| 869 | (should-error (lax-plist-get c2 3) :type 'circular-list) | ||
| 870 | (should-error (lax-plist-get d1 3) :type 'wrong-type-argument) | ||
| 871 | (should-error (lax-plist-get d2 3) :type 'wrong-type-argument))) | ||
| 872 | |||
| 873 | (ert-deftest test-cycle-plist-member () | 855 | (ert-deftest test-cycle-plist-member () |
| 874 | (let ((c1 (cyc1 1)) | 856 | (let ((c1 (cyc1 1)) |
| 875 | (c2 (cyc2 1 2)) | 857 | (c2 (cyc2 1 2)) |
| @@ -906,24 +888,6 @@ | |||
| 906 | (should-error (plist-put d1 3 3) :type 'wrong-type-argument) | 888 | (should-error (plist-put d1 3 3) :type 'wrong-type-argument) |
| 907 | (should-error (plist-put d2 3 3) :type 'wrong-type-argument))) | 889 | (should-error (plist-put d2 3 3) :type 'wrong-type-argument))) |
| 908 | 890 | ||
| 909 | (ert-deftest test-cycle-lax-plist-put () | ||
| 910 | (let ((c1 (cyc1 1)) | ||
| 911 | (c2 (cyc2 1 2)) | ||
| 912 | (d1 (dot1 1)) | ||
| 913 | (d2 (dot2 1 2))) | ||
| 914 | (should (lax-plist-put c1 1 1)) | ||
| 915 | (should (lax-plist-put c2 1 1)) | ||
| 916 | (should (lax-plist-put d1 1 1)) | ||
| 917 | (should (lax-plist-put d2 1 1)) | ||
| 918 | (should-error (lax-plist-put c1 2 2) :type 'circular-list) | ||
| 919 | (should (lax-plist-put c2 2 2)) | ||
| 920 | (should-error (lax-plist-put d1 2 2) :type 'wrong-type-argument) | ||
| 921 | (should (lax-plist-put d2 2 2)) | ||
| 922 | (should-error (lax-plist-put c1 3 3) :type 'circular-list) | ||
| 923 | (should-error (lax-plist-put c2 3 3) :type 'circular-list) | ||
| 924 | (should-error (lax-plist-put d1 3 3) :type 'wrong-type-argument) | ||
| 925 | (should-error (lax-plist-put d2 3 3) :type 'wrong-type-argument))) | ||
| 926 | |||
| 927 | (ert-deftest test-cycle-equal () | 891 | (ert-deftest test-cycle-equal () |
| 928 | (should-error (equal (cyc1 1) (cyc1 1))) | 892 | (should-error (equal (cyc1 1) (cyc1 1))) |
| 929 | (should-error (equal (cyc2 1 2) (cyc2 1 2)))) | 893 | (should-error (equal (cyc2 1 2) (cyc2 1 2)))) |
| @@ -936,24 +900,12 @@ | |||
| 936 | "Test that `plist-get' doesn't signal an error on degenerate plists." | 900 | "Test that `plist-get' doesn't signal an error on degenerate plists." |
| 937 | (should-not (plist-get '(:foo 1 :bar) :bar))) | 901 | (should-not (plist-get '(:foo 1 :bar) :bar))) |
| 938 | 902 | ||
| 939 | (ert-deftest lax-plist-get/odd-number-of-elements () | ||
| 940 | "Check for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27726." | ||
| 941 | (should (equal (should-error (lax-plist-get '(:foo 1 :bar) :bar) | ||
| 942 | :type 'wrong-type-argument) | ||
| 943 | '(wrong-type-argument plistp (:foo 1 :bar))))) | ||
| 944 | |||
| 945 | (ert-deftest plist-put/odd-number-of-elements () | 903 | (ert-deftest plist-put/odd-number-of-elements () |
| 946 | "Check for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27726." | 904 | "Check for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27726." |
| 947 | (should (equal (should-error (plist-put '(:foo 1 :bar) :zot 2) | 905 | (should (equal (should-error (plist-put '(:foo 1 :bar) :zot 2) |
| 948 | :type 'wrong-type-argument) | 906 | :type 'wrong-type-argument) |
| 949 | '(wrong-type-argument plistp (:foo 1 :bar))))) | 907 | '(wrong-type-argument plistp (:foo 1 :bar))))) |
| 950 | 908 | ||
| 951 | (ert-deftest lax-plist-put/odd-number-of-elements () | ||
| 952 | "Check for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27726." | ||
| 953 | (should (equal (should-error (lax-plist-put '(:foo 1 :bar) :zot 2) | ||
| 954 | :type 'wrong-type-argument) | ||
| 955 | '(wrong-type-argument plistp (:foo 1 :bar))))) | ||
| 956 | |||
| 957 | (ert-deftest plist-member/improper-list () | 909 | (ert-deftest plist-member/improper-list () |
| 958 | "Check for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27726." | 910 | "Check for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27726." |
| 959 | (should (equal (should-error (plist-member '(:foo 1 . :bar) :qux) | 911 | (should (equal (should-error (plist-member '(:foo 1 . :bar) :qux) |
| @@ -978,7 +930,7 @@ | |||
| 978 | (should (equal 1 (string-distance "ab" "a我b"))) | 930 | (should (equal 1 (string-distance "ab" "a我b"))) |
| 979 | (should (equal 1 (string-distance "我" "她"))) | 931 | (should (equal 1 (string-distance "我" "她"))) |
| 980 | 932 | ||
| 981 | ;; correct behaviour with empty strings | 933 | ;; correct behavior with empty strings |
| 982 | (should (equal 0 (string-distance "" ""))) | 934 | (should (equal 0 (string-distance "" ""))) |
| 983 | (should (equal 0 (string-distance "" "" t))) | 935 | (should (equal 0 (string-distance "" "" t))) |
| 984 | (should (equal 1 (string-distance "x" ""))) | 936 | (should (equal 1 (string-distance "x" ""))) |
| @@ -1375,4 +1327,91 @@ | |||
| 1375 | (should-error (append loop '(end)) | 1327 | (should-error (append loop '(end)) |
| 1376 | :type 'circular-list))) | 1328 | :type 'circular-list))) |
| 1377 | 1329 | ||
| 1330 | (ert-deftest test-plist () | ||
| 1331 | (let ((plist '(:a "b"))) | ||
| 1332 | (setq plist (plist-put plist :b "c")) | ||
| 1333 | (should (equal (plist-get plist :b) "c")) | ||
| 1334 | (should (equal (plist-member plist :b) '(:b "c")))) | ||
| 1335 | |||
| 1336 | (let ((plist '("1" "2" "a" "b"))) | ||
| 1337 | (setq plist (plist-put plist (copy-sequence "a") "c")) | ||
| 1338 | (should-not (equal (plist-get plist (copy-sequence "a")) "c")) | ||
| 1339 | (should-not (equal (plist-member plist (copy-sequence "a")) '("a" "c")))) | ||
| 1340 | |||
| 1341 | (let ((plist '("1" "2" "a" "b"))) | ||
| 1342 | (setq plist (plist-put plist (copy-sequence "a") "c" #'equal)) | ||
| 1343 | (should (equal (plist-get plist (copy-sequence "a") #'equal) "c")) | ||
| 1344 | (should (equal (plist-member plist (copy-sequence "a") #'equal) | ||
| 1345 | '("a" "c"))))) | ||
| 1346 | |||
| 1347 | (ert-deftest fns--string-to-unibyte-multibyte () | ||
| 1348 | (dolist (str (list "" "a" "abc" "a\x00\x7fz" "a\xaa\xbbz" "\x80\xdd\xff" | ||
| 1349 | (apply #'unibyte-string (number-sequence 0 255)))) | ||
| 1350 | (ert-info ((prin1-to-string str) :prefix "str: ") | ||
| 1351 | (should-not (multibyte-string-p str)) | ||
| 1352 | (let* ((u (string-to-unibyte str)) ; should be identity | ||
| 1353 | (m (string-to-multibyte u)) ; lossless conversion | ||
| 1354 | (mm (string-to-multibyte m)) ; should be identity | ||
| 1355 | (uu (string-to-unibyte m)) ; also lossless | ||
| 1356 | (ml (mapcar (lambda (c) (if (<= c #x7f) c (+ c #x3fff00))) u))) | ||
| 1357 | (should-not (multibyte-string-p u)) | ||
| 1358 | (should (multibyte-string-p m)) | ||
| 1359 | (should (multibyte-string-p mm)) | ||
| 1360 | (should-not (multibyte-string-p uu)) | ||
| 1361 | (should (equal str u)) | ||
| 1362 | (should (equal m mm)) | ||
| 1363 | (should (equal str uu)) | ||
| 1364 | (should (equal (append m nil) ml))))) | ||
| 1365 | (should-error (string-to-unibyte "å")) | ||
| 1366 | (should-error (string-to-unibyte "ABC∀BC"))) | ||
| 1367 | |||
| 1368 | (defun fns-tests--take-ref (n list) | ||
| 1369 | "Reference implementation of `take'." | ||
| 1370 | (named-let loop ((m n) (tail list) (ac nil)) | ||
| 1371 | (if (and (> m 0) tail) | ||
| 1372 | (loop (1- m) (cdr tail) (cons (car tail) ac)) | ||
| 1373 | (nreverse ac)))) | ||
| 1374 | |||
| 1375 | (ert-deftest fns--take-ntake () | ||
| 1376 | "Test `take' and `ntake'." | ||
| 1377 | ;; Check errors and edge cases. | ||
| 1378 | (should-error (take 'x '(a))) | ||
| 1379 | (should-error (ntake 'x '(a))) | ||
| 1380 | (should-error (take 1 'a)) | ||
| 1381 | (should-error (ntake 1 'a)) | ||
| 1382 | (should-error (take 2 '(a . b))) | ||
| 1383 | (should-error (ntake 2 '(a . b))) | ||
| 1384 | ;; Tolerate non-lists for a count of zero. | ||
| 1385 | (should (equal (take 0 'a) nil)) | ||
| 1386 | (should (equal (ntake 0 'a) nil)) | ||
| 1387 | ;; But not non-numbers for empty lists. | ||
| 1388 | (should-error (take 'x nil)) | ||
| 1389 | (should-error (ntake 'x nil)) | ||
| 1390 | |||
| 1391 | (dolist (list '(nil (a) (a b) (a b c) (a b c d) (a . b) (a b . c))) | ||
| 1392 | (ert-info ((prin1-to-string list) :prefix "list: ") | ||
| 1393 | (let ((max (if (proper-list-p list) | ||
| 1394 | (+ 2 (length list)) | ||
| 1395 | (safe-length list)))) | ||
| 1396 | (dolist (n (number-sequence -1 max)) | ||
| 1397 | (ert-info ((prin1-to-string n) :prefix "n: ") | ||
| 1398 | (let* ((l (copy-tree list)) | ||
| 1399 | (ref (fns-tests--take-ref n l))) | ||
| 1400 | (should (equal (take n l) ref)) | ||
| 1401 | (should (equal l list)) | ||
| 1402 | (should (equal (ntake n l) ref)))))))) | ||
| 1403 | |||
| 1404 | ;; Circular list. | ||
| 1405 | (let ((list (list 'a 'b 'c))) | ||
| 1406 | (setcdr (nthcdr 2 list) (cdr list)) ; list now (a b c b c b c ...) | ||
| 1407 | (should (equal (take 0 list) nil)) | ||
| 1408 | (should (equal (take 1 list) '(a))) | ||
| 1409 | (should (equal (take 2 list) '(a b))) | ||
| 1410 | (should (equal (take 3 list) '(a b c))) | ||
| 1411 | (should (equal (take 4 list) '(a b c b))) | ||
| 1412 | (should (equal (take 5 list) '(a b c b c))) | ||
| 1413 | (should (equal (take 10 list) '(a b c b c b c b c b))) | ||
| 1414 | |||
| 1415 | (should (equal (ntake 10 list) '(a b))))) | ||
| 1416 | |||
| 1378 | ;;; fns-tests.el ends here | 1417 | ;;; fns-tests.el ends here |
diff --git a/test/src/font-tests.el b/test/src/font-tests.el index d99b0be89e1..7e9669c6513 100644 --- a/test/src/font-tests.el +++ b/test/src/font-tests.el | |||
| @@ -96,8 +96,7 @@ expected font properties from parsing NAME.") | |||
| 96 | (put 'font-parse-check 'ert-explainer 'font-parse-explain) | 96 | (put 'font-parse-check 'ert-explainer 'font-parse-explain) |
| 97 | 97 | ||
| 98 | (defun font-parse-explain (name prop expected) | 98 | (defun font-parse-explain (name prop expected) |
| 99 | (let ((result (font-get (font-spec :name name) prop)) | 99 | (let ((propname (symbol-name prop))) |
| 100 | (propname (symbol-name prop))) | ||
| 101 | (format "Parsing `%s': expected %s `%s', got `%s'." | 100 | (format "Parsing `%s': expected %s `%s', got `%s'." |
| 102 | name (substring propname 1) expected | 101 | name (substring propname 1) expected |
| 103 | (font-get (font-spec :name name) prop)))) | 102 | (font-get (font-spec :name name) prop)))) |
| @@ -184,9 +183,5 @@ expected font properties from parsing NAME.") | |||
| 184 | :family) | 183 | :family) |
| 185 | 'name-with-lots-of-dashes))) | 184 | 'name-with-lots-of-dashes))) |
| 186 | 185 | ||
| 187 | ;; Local Variables: | ||
| 188 | ;; no-byte-compile: t | ||
| 189 | ;; End: | ||
| 190 | |||
| 191 | (provide 'font-tests) | 186 | (provide 'font-tests) |
| 192 | ;;; font-tests.el ends here. | 187 | ;;; font-tests.el ends here. |
diff --git a/test/src/image-tests.el b/test/src/image-tests.el index f710aadea74..36278f4b9fa 100644 --- a/test/src/image-tests.el +++ b/test/src/image-tests.el | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2021-2022 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2021-2022 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Stefan Kangas <stefan@marxist.se> | 5 | ;; Author: Stefan Kangas <stefankangas@gmail.com> |
| 6 | 6 | ||
| 7 | ;; This file is part of GNU Emacs. | 7 | ;; This file is part of GNU Emacs. |
| 8 | 8 | ||
diff --git a/test/src/json-tests.el b/test/src/json-tests.el index f3dfeea30b4..3560e1abc96 100644 --- a/test/src/json-tests.el +++ b/test/src/json-tests.el | |||
| @@ -187,8 +187,11 @@ | |||
| 187 | (ert-deftest json-parse-string/null () | 187 | (ert-deftest json-parse-string/null () |
| 188 | (skip-unless (fboundp 'json-parse-string)) | 188 | (skip-unless (fboundp 'json-parse-string)) |
| 189 | (should-error (json-parse-string "\x00") :type 'wrong-type-argument) | 189 | (should-error (json-parse-string "\x00") :type 'wrong-type-argument) |
| 190 | ;; FIXME: Reconsider whether this is the right behavior. | 190 | (should (json-parse-string "[\"a\\u0000b\"]")) |
| 191 | (should-error (json-parse-string "[\"a\\u0000b\"]") :type 'json-parse-error)) | 191 | (let* ((string "{\"foo\":\"this is a string including a literal \\u0000\"}") |
| 192 | (data (json-parse-string string))) | ||
| 193 | (should (hash-table-p data)) | ||
| 194 | (should (equal string (json-serialize data))))) | ||
| 192 | 195 | ||
| 193 | (ert-deftest json-parse-string/invalid-unicode () | 196 | (ert-deftest json-parse-string/invalid-unicode () |
| 194 | "Some examples from | 197 | "Some examples from |
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el index 69aa7238493..ce96be6869e 100644 --- a/test/src/keymap-tests.el +++ b/test/src/keymap-tests.el | |||
| @@ -125,7 +125,7 @@ | |||
| 125 | ;; ...) | 125 | ;; ...) |
| 126 | 126 | ||
| 127 | (ert-deftest keymap-lookup-key/mixed-case () | 127 | (ert-deftest keymap-lookup-key/mixed-case () |
| 128 | "Backwards compatibility behaviour (Bug#50752)." | 128 | "Backwards compatibility behavior (Bug#50752)." |
| 129 | (let ((map (make-keymap))) | 129 | (let ((map (make-keymap))) |
| 130 | (define-key map [menu-bar foo bar] 'foo) | 130 | (define-key map [menu-bar foo bar] 'foo) |
| 131 | (should (eq (lookup-key map [menu-bar foo bar]) 'foo)) | 131 | (should (eq (lookup-key map [menu-bar foo bar]) 'foo)) |
| @@ -135,7 +135,7 @@ | |||
| 135 | (should (eq (lookup-key map [menu-bar I-bar]) 'foo)))) | 135 | (should (eq (lookup-key map [menu-bar I-bar]) 'foo)))) |
| 136 | 136 | ||
| 137 | (ert-deftest keymap-lookup-key/mixed-case-multibyte () | 137 | (ert-deftest keymap-lookup-key/mixed-case-multibyte () |
| 138 | "Backwards compatibility behaviour (Bug#50752)." | 138 | "Backwards compatibility behavior (Bug#50752)." |
| 139 | (let ((map (make-keymap))) | 139 | (let ((map (make-keymap))) |
| 140 | ;; (downcase "Åäö") => "åäö" | 140 | ;; (downcase "Åäö") => "åäö" |
| 141 | (define-key map [menu-bar åäö bar] 'foo) | 141 | (define-key map [menu-bar åäö bar] 'foo) |
| @@ -153,19 +153,19 @@ | |||
| 153 | (should (eq (lookup-key map [menu-bar buffer 1]) 'foo)))) | 153 | (should (eq (lookup-key map [menu-bar buffer 1]) 'foo)))) |
| 154 | 154 | ||
| 155 | (ert-deftest keymap-lookup-keymap/with-spaces () | 155 | (ert-deftest keymap-lookup-keymap/with-spaces () |
| 156 | "Backwards compatibility behaviour (Bug#50752)." | 156 | "Backwards compatibility behavior (Bug#50752)." |
| 157 | (let ((map (make-keymap))) | 157 | (let ((map (make-keymap))) |
| 158 | (define-key map [menu-bar foo-bar] 'foo) | 158 | (define-key map [menu-bar foo-bar] 'foo) |
| 159 | (should (eq (lookup-key map [menu-bar Foo\ Bar]) 'foo)))) | 159 | (should (eq (lookup-key map [menu-bar Foo\ Bar]) 'foo)))) |
| 160 | 160 | ||
| 161 | (ert-deftest keymap-lookup-keymap/with-spaces-multibyte () | 161 | (ert-deftest keymap-lookup-keymap/with-spaces-multibyte () |
| 162 | "Backwards compatibility behaviour (Bug#50752)." | 162 | "Backwards compatibility behavior (Bug#50752)." |
| 163 | (let ((map (make-keymap))) | 163 | (let ((map (make-keymap))) |
| 164 | (define-key map [menu-bar åäö-bar] 'foo) | 164 | (define-key map [menu-bar åäö-bar] 'foo) |
| 165 | (should (eq (lookup-key map [menu-bar Åäö\ Bar]) 'foo)))) | 165 | (should (eq (lookup-key map [menu-bar Åäö\ Bar]) 'foo)))) |
| 166 | 166 | ||
| 167 | (ert-deftest keymap-lookup-keymap/with-spaces-multibyte-lang-env () | 167 | (ert-deftest keymap-lookup-keymap/with-spaces-multibyte-lang-env () |
| 168 | "Backwards compatibility behaviour (Bug#50752)." | 168 | "Backwards compatibility behavior (Bug#50752)." |
| 169 | (let ((lang-env current-language-environment)) | 169 | (let ((lang-env current-language-environment)) |
| 170 | (set-language-environment "Turkish") | 170 | (set-language-environment "Turkish") |
| 171 | (let ((map (make-keymap))) | 171 | (let ((map (make-keymap))) |
| @@ -418,6 +418,30 @@ g .. h foo | |||
| 418 | (should-error (text-char-description ?\M-c)) | 418 | (should-error (text-char-description ?\M-c)) |
| 419 | (should-error (text-char-description ?\s-c))) | 419 | (should-error (text-char-description ?\s-c))) |
| 420 | 420 | ||
| 421 | (ert-deftest test-non-key-events () | ||
| 422 | ;; Dummy command. | ||
| 423 | (declare-function keymap-tests-command nil) | ||
| 424 | (should (null (where-is-internal 'keymap-tests-command))) | ||
| 425 | (keymap-set global-map "C-c g" #'keymap-tests-command) | ||
| 426 | (should (equal (where-is-internal 'keymap-tests-command) '([3 103]))) | ||
| 427 | (keymap-set global-map "<keymap-tests-event>" #'keymap-tests-command) | ||
| 428 | (should (equal (where-is-internal 'keymap-tests-command) | ||
| 429 | '([keymap-tests-event] [3 103]))) | ||
| 430 | (make-non-key-event 'keymap-tests-event) | ||
| 431 | (should (equal (where-is-internal 'keymap-tests-command) '([3 103])))) | ||
| 432 | |||
| 433 | (ert-deftest keymap-test-duplicate-definitions () | ||
| 434 | "Check that defvar-keymap rejects duplicate key definitions." | ||
| 435 | (should-error | ||
| 436 | (defvar-keymap | ||
| 437 | ert-keymap-duplicate | ||
| 438 | "a" #'next-line | ||
| 439 | "a" #'previous-line)) | ||
| 440 | (should-error | ||
| 441 | (define-keymap | ||
| 442 | "a" #'next-line | ||
| 443 | "a" #'previous-line))) | ||
| 444 | |||
| 421 | (provide 'keymap-tests) | 445 | (provide 'keymap-tests) |
| 422 | 446 | ||
| 423 | ;;; keymap-tests.el ends here | 447 | ;;; keymap-tests.el ends here |
diff --git a/test/src/lread-resources/lazydoc.el b/test/src/lread-resources/lazydoc.el new file mode 100644 index 00000000000..cb434c239b5 --- /dev/null +++ b/test/src/lread-resources/lazydoc.el | |||
| Binary files differ | |||
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index f190f14781e..57143dd81e5 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el | |||
| @@ -128,7 +128,7 @@ | |||
| 128 | (save-excursion | 128 | (save-excursion |
| 129 | (goto-char (point-max)) | 129 | (goto-char (point-max)) |
| 130 | (skip-chars-backward "\n") | 130 | (skip-chars-backward "\n") |
| 131 | (buffer-substring (line-beginning-position) (point))))) | 131 | (buffer-substring (pos-bol) (point))))) |
| 132 | 132 | ||
| 133 | (ert-deftest lread-tests--unescaped-char-literals () | 133 | (ert-deftest lread-tests--unescaped-char-literals () |
| 134 | "Check that loading warns about unescaped character | 134 | "Check that loading warns about unescaped character |
| @@ -322,4 +322,21 @@ literals (Bug#20852)." | |||
| 322 | (should-error (read-from-string "?\\\n x")) | 322 | (should-error (read-from-string "?\\\n x")) |
| 323 | (should (equal (read-from-string "\"a\\\nb\"") '("ab" . 6)))) | 323 | (should (equal (read-from-string "\"a\\\nb\"") '("ab" . 6)))) |
| 324 | 324 | ||
| 325 | (ert-deftest lread-force-load-doc-strings () | ||
| 326 | ;; Verify that lazy doc strings are loaded lazily by default, | ||
| 327 | ;; but eagerly with `force-load-doc-strings' set. | ||
| 328 | (let ((file (expand-file-name "lazydoc.el" (ert-resource-directory)))) | ||
| 329 | (fmakunbound 'lazydoc-fun) | ||
| 330 | (load file) | ||
| 331 | (let ((f (symbol-function 'lazydoc-fun))) | ||
| 332 | (should (byte-code-function-p f)) | ||
| 333 | (should (equal (aref f 4) (cons file 87)))) | ||
| 334 | |||
| 335 | (fmakunbound 'lazydoc-fun) | ||
| 336 | (let ((load-force-doc-strings t)) | ||
| 337 | (load file) | ||
| 338 | (let ((f (symbol-function 'lazydoc-fun))) | ||
| 339 | (should (byte-code-function-p f)) | ||
| 340 | (should (equal (aref f 4) "My little\ndoc string\nhere")))))) | ||
| 341 | |||
| 325 | ;;; lread-tests.el ends here | 342 | ;;; lread-tests.el ends here |
diff --git a/test/src/print-tests.el b/test/src/print-tests.el index 6ff7e997837..5c349342eb3 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el | |||
| @@ -514,7 +514,7 @@ otherwise, use a different charset." | |||
| 514 | (should (< lead (length numbers))) | 514 | (should (< lead (length numbers))) |
| 515 | (should (<= lead loopback-index)) | 515 | (should (<= lead loopback-index)) |
| 516 | (should (< loopback-index (length numbers))) | 516 | (should (< loopback-index (length numbers))) |
| 517 | (let ((lead-part (butlast numbers (- (length numbers) lead))) | 517 | (let ((lead-part (take lead numbers)) |
| 518 | (loop-part (nthcdr lead numbers))) | 518 | (loop-part (nthcdr lead numbers))) |
| 519 | ;; The lead part must match exactly. | 519 | ;; The lead part must match exactly. |
| 520 | (should (equal lead-part (number-sequence 1 lead))) | 520 | (should (equal lead-part (number-sequence 1 lead))) |
| @@ -529,6 +529,18 @@ otherwise, use a different charset." | |||
| 529 | (should (equal (% (- (length numbers) loopback-index) loop) | 529 | (should (equal (% (- (length numbers) loopback-index) loop) |
| 530 | 0))))))))))) | 530 | 0))))))))))) |
| 531 | 531 | ||
| 532 | (ert-deftest test-print-unreadable-function-buffer () | ||
| 533 | (let* ((buffer nil) | ||
| 534 | (callback-buffer nil) | ||
| 535 | (str (with-temp-buffer | ||
| 536 | (setq buffer (current-buffer)) | ||
| 537 | (let ((print-unreadable-function | ||
| 538 | (lambda (_object _escape) | ||
| 539 | (setq callback-buffer (current-buffer)) | ||
| 540 | "tata"))) | ||
| 541 | (prin1-to-string (make-marker)))))) | ||
| 542 | (should (eq callback-buffer buffer)) | ||
| 543 | (should (equal str "tata")))) | ||
| 532 | 544 | ||
| 533 | (provide 'print-tests) | 545 | (provide 'print-tests) |
| 534 | ;;; print-tests.el ends here | 546 | ;;; print-tests.el ends here |
diff --git a/test/src/process-tests.el b/test/src/process-tests.el index 824c6da1191..6e1e148332c 100644 --- a/test/src/process-tests.el +++ b/test/src/process-tests.el | |||
| @@ -38,10 +38,11 @@ | |||
| 38 | ;; Timeout in seconds; the test fails if the timeout is reached. | 38 | ;; Timeout in seconds; the test fails if the timeout is reached. |
| 39 | (defvar process-test-sentinel-wait-timeout 2.0) | 39 | (defvar process-test-sentinel-wait-timeout 2.0) |
| 40 | 40 | ||
| 41 | ;; Start a process that exits immediately. Call WAIT-FUNCTION, | 41 | (defun process-test-wait-for-sentinel (proc exit-status &optional wait-function) |
| 42 | ;; possibly multiple times, to wait for the process to complete. | 42 | "Set a sentinel on PROC and wait for it to be called with EXIT-STATUS. |
| 43 | (defun process-test-sentinel-wait-function-working-p (wait-function) | 43 | Call WAIT-FUNCTION, possibly multiple times, to wait for the |
| 44 | (let ((proc (start-process "test" nil "bash" "-c" "exit 20")) | 44 | process to complete." |
| 45 | (let ((wait-function (or wait-function #'accept-process-output)) | ||
| 45 | (sentinel-called nil) | 46 | (sentinel-called nil) |
| 46 | (start-time (float-time))) | 47 | (start-time (float-time))) |
| 47 | (set-process-sentinel proc (lambda (_proc _msg) | 48 | (set-process-sentinel proc (lambda (_proc _msg) |
| @@ -50,21 +51,22 @@ | |||
| 50 | (> (- (float-time) start-time) | 51 | (> (- (float-time) start-time) |
| 51 | process-test-sentinel-wait-timeout))) | 52 | process-test-sentinel-wait-timeout))) |
| 52 | (funcall wait-function)) | 53 | (funcall wait-function)) |
| 53 | (cl-assert (eq (process-status proc) 'exit)) | 54 | (should sentinel-called) |
| 54 | (cl-assert (= (process-exit-status proc) 20)) | 55 | (should (eq (process-status proc) 'exit)) |
| 55 | sentinel-called)) | 56 | (should (= (process-exit-status proc) exit-status)))) |
| 56 | 57 | ||
| 57 | (ert-deftest process-test-sentinel-accept-process-output () | 58 | (ert-deftest process-test-sentinel-accept-process-output () |
| 58 | (skip-unless (executable-find "bash")) | 59 | (skip-unless (executable-find "bash")) |
| 59 | (with-timeout (60 (ert-fail "Test timed out")) | 60 | (with-timeout (60 (ert-fail "Test timed out")) |
| 60 | (should (process-test-sentinel-wait-function-working-p | 61 | (let ((proc (start-process "test" nil "bash" "-c" "exit 20"))) |
| 61 | #'accept-process-output)))) | 62 | (should (process-test-wait-for-sentinel proc 20))))) |
| 62 | 63 | ||
| 63 | (ert-deftest process-test-sentinel-sit-for () | 64 | (ert-deftest process-test-sentinel-sit-for () |
| 64 | (skip-unless (executable-find "bash")) | 65 | (skip-unless (executable-find "bash")) |
| 65 | (with-timeout (60 (ert-fail "Test timed out")) | 66 | (with-timeout (60 (ert-fail "Test timed out")) |
| 66 | (should | 67 | (let ((proc (start-process "test" nil "bash" "-c" "exit 20"))) |
| 67 | (process-test-sentinel-wait-function-working-p (lambda () (sit-for 0.01 t)))))) | 68 | (should (process-test-wait-for-sentinel |
| 69 | proc 20 (lambda () (sit-for 0.01 t))))))) | ||
| 68 | 70 | ||
| 69 | (when (eq system-type 'windows-nt) | 71 | (when (eq system-type 'windows-nt) |
| 70 | (ert-deftest process-test-quoted-batfile () | 72 | (ert-deftest process-test-quoted-batfile () |
| @@ -97,17 +99,8 @@ | |||
| 97 | "echo hello stderr! >&2; " | 99 | "echo hello stderr! >&2; " |
| 98 | "exit 20")) | 100 | "exit 20")) |
| 99 | :buffer stdout-buffer | 101 | :buffer stdout-buffer |
| 100 | :stderr stderr-buffer)) | 102 | :stderr stderr-buffer))) |
| 101 | (sentinel-called nil) | 103 | (process-test-wait-for-sentinel proc 20) |
| 102 | (start-time (float-time))) | ||
| 103 | (set-process-sentinel proc (lambda (_proc _msg) | ||
| 104 | (setq sentinel-called t))) | ||
| 105 | (while (not (or sentinel-called | ||
| 106 | (> (- (float-time) start-time) | ||
| 107 | process-test-sentinel-wait-timeout))) | ||
| 108 | (accept-process-output)) | ||
| 109 | (cl-assert (eq (process-status proc) 'exit)) | ||
| 110 | (cl-assert (= (process-exit-status proc) 20)) | ||
| 111 | (should (with-current-buffer stdout-buffer | 104 | (should (with-current-buffer stdout-buffer |
| 112 | (goto-char (point-min)) | 105 | (goto-char (point-min)) |
| 113 | (looking-at "hello stdout!"))) | 106 | (looking-at "hello stdout!"))) |
| @@ -118,8 +111,7 @@ | |||
| 118 | (ert-deftest process-test-stderr-filter () | 111 | (ert-deftest process-test-stderr-filter () |
| 119 | (skip-unless (executable-find "bash")) | 112 | (skip-unless (executable-find "bash")) |
| 120 | (with-timeout (60 (ert-fail "Test timed out")) | 113 | (with-timeout (60 (ert-fail "Test timed out")) |
| 121 | (let* ((sentinel-called nil) | 114 | (let* ((stderr-sentinel-called nil) |
| 122 | (stderr-sentinel-called nil) | ||
| 123 | (stdout-output nil) | 115 | (stdout-output nil) |
| 124 | (stderr-output nil) | 116 | (stderr-output nil) |
| 125 | (stdout-buffer (generate-new-buffer "*stdout*")) | 117 | (stdout-buffer (generate-new-buffer "*stdout*")) |
| @@ -131,23 +123,14 @@ | |||
| 131 | (concat "echo hello stdout!; " | 123 | (concat "echo hello stdout!; " |
| 132 | "echo hello stderr! >&2; " | 124 | "echo hello stderr! >&2; " |
| 133 | "exit 20")) | 125 | "exit 20")) |
| 134 | :stderr stderr-proc)) | 126 | :stderr stderr-proc))) |
| 135 | (start-time (float-time))) | ||
| 136 | (set-process-filter proc (lambda (_proc input) | 127 | (set-process-filter proc (lambda (_proc input) |
| 137 | (push input stdout-output))) | 128 | (push input stdout-output))) |
| 138 | (set-process-sentinel proc (lambda (_proc _msg) | ||
| 139 | (setq sentinel-called t))) | ||
| 140 | (set-process-filter stderr-proc (lambda (_proc input) | 129 | (set-process-filter stderr-proc (lambda (_proc input) |
| 141 | (push input stderr-output))) | 130 | (push input stderr-output))) |
| 142 | (set-process-sentinel stderr-proc (lambda (_proc _input) | 131 | (set-process-sentinel stderr-proc (lambda (_proc _input) |
| 143 | (setq stderr-sentinel-called t))) | 132 | (setq stderr-sentinel-called t))) |
| 144 | (while (not (or sentinel-called | 133 | (process-test-wait-for-sentinel proc 20) |
| 145 | (> (- (float-time) start-time) | ||
| 146 | process-test-sentinel-wait-timeout))) | ||
| 147 | (accept-process-output)) | ||
| 148 | (cl-assert (eq (process-status proc) 'exit)) | ||
| 149 | (cl-assert (= (process-exit-status proc) 20)) | ||
| 150 | (should sentinel-called) | ||
| 151 | (should (equal 1 (with-current-buffer stdout-buffer | 134 | (should (equal 1 (with-current-buffer stdout-buffer |
| 152 | (point-max)))) | 135 | (point-max)))) |
| 153 | (should (equal "hello stdout!\n" | 136 | (should (equal "hello stdout!\n" |
| @@ -177,8 +160,7 @@ | |||
| 177 | (setq count (1+ count)))))))) | 160 | (setq count (1+ count)))))))) |
| 178 | (set-process-query-on-exit-flag proc nil) | 161 | (set-process-query-on-exit-flag proc nil) |
| 179 | (send-string proc "one\n") | 162 | (send-string proc "one\n") |
| 180 | (while (not (equal (buffer-substring | 163 | (while (not (equal (buffer-substring (pos-bol) (point-max)) |
| 181 | (line-beginning-position) (point-max)) | ||
| 182 | "1> ")) | 164 | "1> ")) |
| 183 | (accept-process-output proc)) ; Read "one". | 165 | (accept-process-output proc)) ; Read "one". |
| 184 | (should (equal (buffer-string) "0> one\n1> ")) | 166 | (should (equal (buffer-string) "0> one\n1> ")) |
| @@ -188,8 +170,7 @@ | |||
| 188 | (accept-process-output proc 1)) ; Can't read "two" yet. | 170 | (accept-process-output proc 1)) ; Can't read "two" yet. |
| 189 | (should (equal (buffer-string) "0> one\n1> ")) | 171 | (should (equal (buffer-string) "0> one\n1> ")) |
| 190 | (set-process-filter proc nil) ; Resume reading from proc. | 172 | (set-process-filter proc nil) ; Resume reading from proc. |
| 191 | (while (not (equal (buffer-substring | 173 | (while (not (equal (buffer-substring (pos-bol) (point-max)) |
| 192 | (line-beginning-position) (point-max)) | ||
| 193 | "2> ")) | 174 | "2> ")) |
| 194 | (accept-process-output proc)) ; Read "Two". | 175 | (accept-process-output proc)) ; Read "Two". |
| 195 | (should (equal (buffer-string) "0> one\n1> two\n2> ")))))) | 176 | (should (equal (buffer-string) "0> one\n1> two\n2> ")))))) |
| @@ -289,6 +270,77 @@ | |||
| 289 | (error :got-error)))) | 270 | (error :got-error)))) |
| 290 | (should have-called-debugger)))) | 271 | (should have-called-debugger)))) |
| 291 | 272 | ||
| 273 | (defun make-process/test-connection-type (ttys &rest args) | ||
| 274 | "Make a process and check whether its standard streams match TTYS. | ||
| 275 | This calls `make-process', passing ARGS to adjust how the process | ||
| 276 | is created. TTYS should be a list of 3 boolean values, | ||
| 277 | indicating whether the subprocess's stdin, stdout, and stderr | ||
| 278 | should be a TTY, respectively." | ||
| 279 | (declare (indent 1)) | ||
| 280 | (let* (;; MS-Windows doesn't support communicating via pty. | ||
| 281 | (ttys (if (eq system-type 'windows-nt) '(nil nil nil) ttys)) | ||
| 282 | (expected-output (concat (and (nth 0 ttys) "stdin\n") | ||
| 283 | (and (nth 1 ttys) "stdout\n") | ||
| 284 | (and (nth 2 ttys) "stderr\n"))) | ||
| 285 | (stdout-buffer (generate-new-buffer "*stdout*")) | ||
| 286 | (proc (apply | ||
| 287 | #'make-process | ||
| 288 | :name "test" | ||
| 289 | :command (list "sh" "-c" | ||
| 290 | (concat "if [ -t 0 ]; then echo stdin; fi; " | ||
| 291 | "if [ -t 1 ]; then echo stdout; fi; " | ||
| 292 | "if [ -t 2 ]; then echo stderr; fi")) | ||
| 293 | :buffer stdout-buffer | ||
| 294 | args))) | ||
| 295 | (should (eq (and (process-tty-name proc 'stdin) t) (nth 0 ttys))) | ||
| 296 | (should (eq (and (process-tty-name proc 'stdout) t) (nth 1 ttys))) | ||
| 297 | (should (eq (and (process-tty-name proc 'stderr) t) (nth 2 ttys))) | ||
| 298 | (process-test-wait-for-sentinel proc 0) | ||
| 299 | (should (equal (with-current-buffer stdout-buffer (buffer-string)) | ||
| 300 | expected-output)))) | ||
| 301 | |||
| 302 | (ert-deftest make-process/connection-type/pty () | ||
| 303 | (skip-unless (executable-find "sh")) | ||
| 304 | (make-process/test-connection-type '(t t t) | ||
| 305 | :connection-type 'pty)) | ||
| 306 | |||
| 307 | (ert-deftest make-process/connection-type/pty-2 () | ||
| 308 | (skip-unless (executable-find "sh")) | ||
| 309 | (make-process/test-connection-type '(t t t) | ||
| 310 | :connection-type '(pty . pty))) | ||
| 311 | |||
| 312 | (ert-deftest make-process/connection-type/pipe () | ||
| 313 | (skip-unless (executable-find "sh")) | ||
| 314 | (make-process/test-connection-type '(nil nil nil) | ||
| 315 | :connection-type 'pipe)) | ||
| 316 | |||
| 317 | (ert-deftest make-process/connection-type/pipe-2 () | ||
| 318 | (skip-unless (executable-find "sh")) | ||
| 319 | (make-process/test-connection-type '(nil nil nil) | ||
| 320 | :connection-type '(pipe . pipe))) | ||
| 321 | |||
| 322 | (ert-deftest make-process/connection-type/in-pty () | ||
| 323 | (skip-unless (executable-find "sh")) | ||
| 324 | (make-process/test-connection-type '(t nil nil) | ||
| 325 | :connection-type '(pty . pipe))) | ||
| 326 | |||
| 327 | (ert-deftest make-process/connection-type/out-pty () | ||
| 328 | (skip-unless (executable-find "sh")) | ||
| 329 | (make-process/test-connection-type '(nil t t) | ||
| 330 | :connection-type '(pipe . pty))) | ||
| 331 | |||
| 332 | (ert-deftest make-process/connection-type/pty-with-stderr-buffer () | ||
| 333 | (skip-unless (executable-find "sh")) | ||
| 334 | (let ((stderr-buffer (generate-new-buffer "*stderr*"))) | ||
| 335 | (make-process/test-connection-type '(t t nil) | ||
| 336 | :connection-type 'pty :stderr stderr-buffer))) | ||
| 337 | |||
| 338 | (ert-deftest make-process/connection-type/out-pty-with-stderr-buffer () | ||
| 339 | (skip-unless (executable-find "sh")) | ||
| 340 | (let ((stderr-buffer (generate-new-buffer "*stderr*"))) | ||
| 341 | (make-process/test-connection-type '(nil t nil) | ||
| 342 | :connection-type '(pipe . pty) :stderr stderr-buffer))) | ||
| 343 | |||
| 292 | (ert-deftest make-process/file-handler/found () | 344 | (ert-deftest make-process/file-handler/found () |
| 293 | "Check that the `:file-handler’ argument of `make-process’ | 345 | "Check that the `:file-handler’ argument of `make-process’ |
| 294 | works as expected if a file name handler is found." | 346 | works as expected if a file name handler is found." |
| @@ -378,6 +430,58 @@ See Bug#30460." | |||
| 378 | (when (ipv6-is-available) | 430 | (when (ipv6-is-available) |
| 379 | (should (network-lookup-address-info "localhost" 'ipv6))))) | 431 | (should (network-lookup-address-info "localhost" 'ipv6))))) |
| 380 | 432 | ||
| 433 | (ert-deftest lookup-hints-specification () | ||
| 434 | "`network-lookup-address-info' should only accept valid hints arg." | ||
| 435 | (should-error (network-lookup-address-info "1.1.1.1" nil t)) | ||
| 436 | (should-error (network-lookup-address-info "1.1.1.1" 'ipv4 t)) | ||
| 437 | (should (network-lookup-address-info "1.1.1.1" nil 'numeric)) | ||
| 438 | (should (network-lookup-address-info "1.1.1.1" 'ipv4 'numeric)) | ||
| 439 | (when (ipv6-is-available) | ||
| 440 | (should-error (network-lookup-address-info "::1" nil t)) | ||
| 441 | (should-error (network-lookup-address-info "::1" 'ipv6 't)) | ||
| 442 | (should (network-lookup-address-info "::1" nil 'numeric)) | ||
| 443 | (should (network-lookup-address-info "::1" 'ipv6 'numeric)))) | ||
| 444 | |||
| 445 | (ert-deftest lookup-hints-values () | ||
| 446 | "`network-lookup-address-info' should succeed/fail in looking up various numeric IP addresses." | ||
| 447 | (let ((ipv4-invalid-addrs | ||
| 448 | '("localhost" "343.1.2.3" "1.2.3.4.5")) | ||
| 449 | ;; These are valid for IPv4 but invalid for IPv6 | ||
| 450 | (ipv4-addrs | ||
| 451 | '("127.0.0.1" "127.0.1" "127.1" "127" "1" "0" | ||
| 452 | "0xe3010203" "0xe3.1.2.3" "227.0x1.2.3" | ||
| 453 | "034300201003" "0343.1.2.3" "227.001.2.3")) | ||
| 454 | (ipv6-only-invalid-addrs | ||
| 455 | '("fe80:1" "e301:203:1" "e301::203::1" | ||
| 456 | "1:2:3:4:5:6:7:8:9" "0xe301:203::1" | ||
| 457 | "343:10001:2::3" | ||
| 458 | ;; "00343:1:2::3" is invalid on GNU/Linux and FreeBSD, but | ||
| 459 | ;; valid on macOS. macOS is wrong here, but such is life. | ||
| 460 | )) | ||
| 461 | ;; These are valid for IPv6 but invalid for IPv4 | ||
| 462 | (ipv6-addrs | ||
| 463 | '("fe80::1" "e301::203:1" "e301:203::1" | ||
| 464 | "e301:0203::1" "::1" "::0" | ||
| 465 | "0343:1:2::3" "343:001:2::3"))) | ||
| 466 | (dolist (a ipv4-invalid-addrs) | ||
| 467 | (should-not (network-lookup-address-info a nil 'numeric)) | ||
| 468 | (should-not (network-lookup-address-info a 'ipv4 'numeric))) | ||
| 469 | (dolist (a ipv6-addrs) | ||
| 470 | (should-not (network-lookup-address-info a 'ipv4 'numeric))) | ||
| 471 | (dolist (a ipv4-addrs) | ||
| 472 | (should (network-lookup-address-info a nil 'numeric)) | ||
| 473 | (should (network-lookup-address-info a 'ipv4 'numeric))) | ||
| 474 | (when (ipv6-is-available) | ||
| 475 | (dolist (a ipv4-addrs) | ||
| 476 | (should-not (network-lookup-address-info a 'ipv6 'numeric))) | ||
| 477 | (dolist (a ipv6-only-invalid-addrs) | ||
| 478 | (should-not (network-lookup-address-info a 'ipv6 'numeric))) | ||
| 479 | (dolist (a ipv6-addrs) | ||
| 480 | (should (network-lookup-address-info a nil 'numeric)) | ||
| 481 | (should (network-lookup-address-info a 'ipv6 'numeric)) | ||
| 482 | (should (network-lookup-address-info (upcase a) nil 'numeric)) | ||
| 483 | (should (network-lookup-address-info (upcase a) 'ipv6 'numeric)))))) | ||
| 484 | |||
| 381 | (ert-deftest lookup-unicode-domains () | 485 | (ert-deftest lookup-unicode-domains () |
| 382 | "Unicode domains should fail." | 486 | "Unicode domains should fail." |
| 383 | (skip-unless internet-is-working) | 487 | (skip-unless internet-is-working) |
| @@ -909,35 +1013,6 @@ Return nil if FILENAME doesn't exist." | |||
| 909 | ;; ...and the change description should be "interrupt". | 1013 | ;; ...and the change description should be "interrupt". |
| 910 | (should (equal '("interrupt\n") events))))) | 1014 | (should (equal '("interrupt\n") events))))) |
| 911 | 1015 | ||
| 912 | (ert-deftest process-async-https-with-delay () | ||
| 913 | "Bug#49449: asynchronous TLS connection with delayed completion." | ||
| 914 | (skip-unless (and internet-is-working (gnutls-available-p))) | ||
| 915 | (let* ((status nil) | ||
| 916 | (buf (url-http | ||
| 917 | #s(url "https" nil nil "elpa.gnu.org" nil | ||
| 918 | "/packages/archive-contents" nil nil t silent t t) | ||
| 919 | (lambda (s) (setq status s)) | ||
| 920 | '(nil) nil 'tls))) | ||
| 921 | (unwind-protect | ||
| 922 | (progn | ||
| 923 | ;; Busy-wait for 1 s to allow for the TCP connection to complete. | ||
| 924 | (let ((delay 1.0) | ||
| 925 | (t0 (float-time))) | ||
| 926 | (while (< (float-time) (+ t0 delay)))) | ||
| 927 | ;; Wait for the entire operation to finish. | ||
| 928 | (let ((limit 4.0) | ||
| 929 | (t0 (float-time))) | ||
| 930 | (while (and (null status) | ||
| 931 | (< (float-time) (+ t0 limit))) | ||
| 932 | (sit-for 0.1))) | ||
| 933 | (should status) | ||
| 934 | (should-not (plist-get status ':error)) | ||
| 935 | (should buf) | ||
| 936 | (should (> (buffer-size buf) 0)) | ||
| 937 | ) | ||
| 938 | (when buf | ||
| 939 | (kill-buffer buf))))) | ||
| 940 | |||
| 941 | (ert-deftest process-num-processors () | 1016 | (ert-deftest process-num-processors () |
| 942 | "Sanity checks for num-processors." | 1017 | "Sanity checks for num-processors." |
| 943 | (should (equal (num-processors) (num-processors))) | 1018 | (should (equal (num-processors) (num-processors))) |
diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el index 08d06f27d9e..24f9000ffbd 100644 --- a/test/src/timefns-tests.el +++ b/test/src/timefns-tests.el | |||
| @@ -93,7 +93,6 @@ | |||
| 93 | most-negative-fixnum most-positive-fixnum | 93 | most-negative-fixnum most-positive-fixnum |
| 94 | (1- most-negative-fixnum) | 94 | (1- most-negative-fixnum) |
| 95 | (1+ most-positive-fixnum) | 95 | (1+ most-positive-fixnum) |
| 96 | 1e+INF -1e+INF 1e+NaN -1e+NaN | ||
| 97 | '(0 1 0 0) '(1 0 0 0) '(-1 0 0 0) | 96 | '(0 1 0 0) '(1 0 0 0) '(-1 0 0 0) |
| 98 | '(123456789000000 . 1000000) | 97 | '(123456789000000 . 1000000) |
| 99 | (cons (1+ most-positive-fixnum) 1000000000000) | 98 | (cons (1+ most-positive-fixnum) 1000000000000) |
| @@ -169,10 +168,6 @@ a fixed place on the right and are padded on the left." | |||
| 169 | (ert-deftest time-equal-p-nil-nil () | 168 | (ert-deftest time-equal-p-nil-nil () |
| 170 | (should (time-equal-p nil nil))) | 169 | (should (time-equal-p nil nil))) |
| 171 | 170 | ||
| 172 | (ert-deftest time-equal-p-NaN-NaN () | ||
| 173 | (let ((x 0.0e+NaN)) | ||
| 174 | (should (not (time-equal-p x x))))) | ||
| 175 | |||
| 176 | (ert-deftest time-arith-tests () | 171 | (ert-deftest time-arith-tests () |
| 177 | (let ((time-values (list 0 -1 1 0.0 -0.0 -1.0 1.0 | 172 | (let ((time-values (list 0 -1 1 0.0 -0.0 -1.0 1.0 |
| 178 | most-negative-fixnum most-positive-fixnum | 173 | most-negative-fixnum most-positive-fixnum |
| @@ -184,7 +179,6 @@ a fixed place on the right and are padded on the left." | |||
| 184 | 1e10 -1e10 1e-10 -1e-10 | 179 | 1e10 -1e10 1e-10 -1e-10 |
| 185 | 1e16 -1e16 1e-16 -1e-16 | 180 | 1e16 -1e16 1e-16 -1e-16 |
| 186 | 1e37 -1e37 1e-37 -1e-37 | 181 | 1e37 -1e37 1e-37 -1e-37 |
| 187 | 1e+INF -1e+INF 1e+NaN -1e+NaN | ||
| 188 | '(0 0 0 1) '(0 0 1 0) '(0 1 0 0) '(1 0 0 0) | 182 | '(0 0 0 1) '(0 0 1 0) '(0 1 0 0) '(1 0 0 0) |
| 189 | '(-1 0 0 0) '(1 2 3 4) '(-1 2 3 4) | 183 | '(-1 0 0 0) '(1 2 3 4) '(-1 2 3 4) |
| 190 | '(-123456789 . 100000) '(123456789 . 1000000) | 184 | '(-123456789 . 100000) '(123456789 . 1000000) |
diff --git a/test/src/undo-tests.el b/test/src/undo-tests.el index c84ed74f0b1..cb0822fb1b9 100644 --- a/test/src/undo-tests.el +++ b/test/src/undo-tests.el | |||
| @@ -460,11 +460,10 @@ Demonstrates bug 25599." | |||
| 460 | (delete-overlay ov)))))) | 460 | (delete-overlay ov)))))) |
| 461 | (save-excursion | 461 | (save-excursion |
| 462 | (goto-char (point-min)) | 462 | (goto-char (point-min)) |
| 463 | (let ((ov (make-overlay (line-beginning-position 2) | 463 | (let ((ov (make-overlay (pos-bol 2) (pos-eol 2)))) |
| 464 | (line-end-position 2)))) | ||
| 465 | (overlay-put ov 'insert-in-front-hooks | 464 | (overlay-put ov 'insert-in-front-hooks |
| 466 | (list overlay-modified))))) | 465 | (list overlay-modified))))) |
| 467 | (kill-region (point-min) (line-beginning-position 2)) | 466 | (kill-region (point-min) (pos-bol 2)) |
| 468 | (undo-boundary) | 467 | (undo-boundary) |
| 469 | (undo))) | 468 | (undo))) |
| 470 | 469 | ||