diff options
| author | Tom Tromey | 2013-07-12 18:44:13 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-07-12 18:44:13 -0600 |
| commit | b34a529f177a6ea32da5cb1254f91bf9d71838db (patch) | |
| tree | 477131abc15d3107b30b635223d87a22550b480b /test | |
| parent | e6f63071a3f7721f55220514b6d9a8ee8c1232d8 (diff) | |
| parent | 5e301d7651c0691bb2bc7f3fbe711fdbe26ac471 (diff) | |
| download | emacs-b34a529f177a6ea32da5cb1254f91bf9d71838db.tar.gz emacs-b34a529f177a6ea32da5cb1254f91bf9d71838db.zip | |
Merge from trunk
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 67 | ||||
| -rw-r--r-- | test/automated/add-log-tests.el | 1 | ||||
| -rw-r--r-- | test/automated/advice-tests.el | 2 | ||||
| -rw-r--r-- | test/automated/cl-lib.el | 198 | ||||
| -rw-r--r-- | test/automated/decoder-tests.el | 5 | ||||
| -rw-r--r-- | test/automated/ert-tests.el | 171 | ||||
| -rw-r--r-- | test/automated/file-notify-tests.el | 151 | ||||
| -rw-r--r-- | test/automated/files.el | 3 | ||||
| -rw-r--r-- | test/automated/flymake-tests.el | 3 | ||||
| -rw-r--r-- | test/automated/icalendar-tests.el | 3 | ||||
| -rw-r--r-- | test/automated/imenu-test.el | 1 | ||||
| -rw-r--r-- | test/automated/inotify-test.el | 5 | ||||
| -rwxr-xr-x | test/automated/package-test.el | 7 | ||||
| -rwxr-xr-x | test/automated/package-x-test.el | 1 | ||||
| -rw-r--r-- | test/automated/python-tests.el | 5 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 24 | ||||
| -rw-r--r-- | test/automated/undo-tests.el | 26 | ||||
| -rw-r--r-- | test/automated/xml-parse-tests.el | 1 |
18 files changed, 411 insertions, 263 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index aded5473304..d3d8db6b501 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,68 @@ | |||
| 1 | 2013-07-11 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * automated/ert-tests.el: Require cl-lib at runtime too. | ||
| 4 | (ert-test-special-operator-p): Use cl-gensym rather than ert-- version. | ||
| 5 | (ert-test-remprop, ert-test-remove-if-not, ert-test-remove*) | ||
| 6 | (ert-test-set-functions, ert-test-gensym) | ||
| 7 | (ert-test-coerce-to-vector, ert-test-string-position) | ||
| 8 | (ert-test-mismatch): Remove tests. | ||
| 9 | * automated/cl-lib.el: New, split from ert-tests.el. | ||
| 10 | |||
| 11 | * automated/ruby-mode-tests.el (ruby-deftest-move-to-block): | ||
| 12 | Goto point-min. | ||
| 13 | (works-on-do, zero-is-noop, ok-with-three, ok-with-minus-two) | ||
| 14 | (ruby-move-to-block-skips-percent-literal) | ||
| 15 | (ruby-move-to-block-skips-heredoc) | ||
| 16 | (ruby-move-to-block-moves-from-else-to-if) | ||
| 17 | (ruby-beginning-of-defun-does-not-fold-case) | ||
| 18 | (ruby-end-of-defun-skips-to-next-line-after-the-method): | ||
| 19 | Replace goto-line with forward-line/goto-char. | ||
| 20 | (ruby-move-to-block-does-not-fold-case): Remove unneeded end-of-buffer. | ||
| 21 | |||
| 22 | * automated/package-test.el (makeinfo-buffer): Autoload. | ||
| 23 | (compilation-in-progress, tar-parse-info, tar-header-name): Declare. | ||
| 24 | (package-test-install-texinfo): Don't require makeinfo. | ||
| 25 | |||
| 26 | * automated/files.el: Stop "local variables" confusion. | ||
| 27 | |||
| 28 | * automated/flymake-tests.el (flymake-tests): Remove unused group. | ||
| 29 | |||
| 30 | * automated/icalendar-tests.el (icalendar-tests--do-test-cycle): | ||
| 31 | Use with-current-buffer. | ||
| 32 | |||
| 33 | * automated/undo-tests.el (undo-test-buffer-modified) | ||
| 34 | (undo-test-file-modified): New tests. | ||
| 35 | |||
| 36 | 2013-07-09 Michael Albinus <michael.albinus@gmx.de> | ||
| 37 | |||
| 38 | * automated/file-notify-tests.el (file-notify-test00-availability): | ||
| 39 | Set :expected-result. | ||
| 40 | (file-notify-test01-add-watch, file-notify-test01-add-watch-remote) | ||
| 41 | (file-notify-test02-events, file-notify-test02-events-remote) | ||
| 42 | (file-notify-test03-autorevert, file-notify-test03-autorevert-remote): | ||
| 43 | Skip when `file-notify-support' is nil. (Bug#14823) | ||
| 44 | |||
| 45 | 2013-07-09 Glenn Morris <rgm@gnu.org> | ||
| 46 | |||
| 47 | * automated/inotify-test.el (inotify-add-watch, inotify-rm-watch): | ||
| 48 | Declare. | ||
| 49 | (inotify-file-watch-simple): Silence compiler. | ||
| 50 | |||
| 51 | * automated/python-tests.el (python-indent-block-enders): | ||
| 52 | Make it actually test something. | ||
| 53 | |||
| 54 | * automated/package-x-test.el: Require package-test when compiling. | ||
| 55 | |||
| 56 | * automated/add-log-tests.el, automated/advice-tests.el: | ||
| 57 | * automated/imenu-test.el, automated/package-x-test.el: | ||
| 58 | * automated/python-tests.el, automated/ruby-mode-tests.el: | ||
| 59 | * automated/xml-parse-tests.el: Explictly require ert. | ||
| 60 | |||
| 61 | 2013-07-08 Kenichi Handa <handa@gnu.org> | ||
| 62 | |||
| 63 | * automated/decoder-tests.el (decoder-tests-prefer-utf-8-read): | ||
| 64 | Use with-ccoding-priority to avoid side-effect (Bug#14781). | ||
| 65 | |||
| 1 | 2013-07-05 Michael Albinus <michael.albinus@gmx.de> | 66 | 2013-07-05 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 67 | ||
| 3 | * automated/file-notify-tests.el | 68 | * automated/file-notify-tests.el |
| @@ -71,7 +136,7 @@ | |||
| 71 | Use it to create separate tests for each element, so we run them | 136 | Use it to create separate tests for each element, so we run them |
| 72 | all rather than stopping at the first error. | 137 | all rather than stopping at the first error. |
| 73 | 138 | ||
| 74 | 2013-06-24 Glenn Morris <rgm@fencepost.gnu.org> | 139 | 2013-06-24 Glenn Morris <rgm@gnu.org> |
| 75 | 140 | ||
| 76 | * automated/occur-tests.el (occur-tests): | 141 | * automated/occur-tests.el (occur-tests): |
| 77 | Update for 2013-05-29 change to occur header line. | 142 | Update for 2013-05-29 change to occur header line. |
diff --git a/test/automated/add-log-tests.el b/test/automated/add-log-tests.el index f6e803cd317..bd073016505 100644 --- a/test/automated/add-log-tests.el +++ b/test/automated/add-log-tests.el | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | ;;; Code: | 23 | ;;; Code: |
| 24 | 24 | ||
| 25 | (require 'ert) | ||
| 25 | (require 'add-log) | 26 | (require 'add-log) |
| 26 | 27 | ||
| 27 | (defmacro add-log-current-defun-deftest (name doc major-mode | 28 | (defmacro add-log-current-defun-deftest (name doc major-mode |
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el index 8beaea64cd9..69c15e34ed0 100644 --- a/test/automated/advice-tests.el +++ b/test/automated/advice-tests.el | |||
| @@ -21,6 +21,8 @@ | |||
| 21 | 21 | ||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (require 'ert) | ||
| 25 | |||
| 24 | (ert-deftest advice-tests-nadvice () | 26 | (ert-deftest advice-tests-nadvice () |
| 25 | "Test nadvice code." | 27 | "Test nadvice code." |
| 26 | (defun sm-test1 (x) (+ x 4)) | 28 | (defun sm-test1 (x) (+ x 4)) |
diff --git a/test/automated/cl-lib.el b/test/automated/cl-lib.el new file mode 100644 index 00000000000..3a339e01734 --- /dev/null +++ b/test/automated/cl-lib.el | |||
| @@ -0,0 +1,198 @@ | |||
| 1 | ;;; cl-lib.el --- tests for emacs-lisp/cl-lib.el | ||
| 2 | |||
| 3 | ;; Copyright (C) 2013 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; This program is free software: you can redistribute it and/or | ||
| 8 | ;; modify it under the terms of the GNU General Public License as | ||
| 9 | ;; published by the Free Software Foundation, either version 3 of the | ||
| 10 | ;; License, or (at your option) any later version. | ||
| 11 | ;; | ||
| 12 | ;; This program is distributed in the hope that it will be useful, but | ||
| 13 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | ;; General Public License for more details. | ||
| 16 | ;; | ||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with this program. If not, see `http://www.gnu.org/licenses/'. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;; Extracted from ert-tests.el, back when ert used to reimplement some | ||
| 23 | ;; cl functions. | ||
| 24 | |||
| 25 | ;;; Code: | ||
| 26 | |||
| 27 | (require 'cl-lib) | ||
| 28 | (require 'ert) | ||
| 29 | |||
| 30 | (ert-deftest cl-lib-test-remprop () | ||
| 31 | (let ((x (cl-gensym))) | ||
| 32 | (should (equal (symbol-plist x) '())) | ||
| 33 | ;; Remove nonexistent property on empty plist. | ||
| 34 | (cl-remprop x 'b) | ||
| 35 | (should (equal (symbol-plist x) '())) | ||
| 36 | (put x 'a 1) | ||
| 37 | (should (equal (symbol-plist x) '(a 1))) | ||
| 38 | ;; Remove nonexistent property on nonempty plist. | ||
| 39 | (cl-remprop x 'b) | ||
| 40 | (should (equal (symbol-plist x) '(a 1))) | ||
| 41 | (put x 'b 2) | ||
| 42 | (put x 'c 3) | ||
| 43 | (put x 'd 4) | ||
| 44 | (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4))) | ||
| 45 | ;; Remove property that is neither first nor last. | ||
| 46 | (cl-remprop x 'c) | ||
| 47 | (should (equal (symbol-plist x) '(a 1 b 2 d 4))) | ||
| 48 | ;; Remove last property from a plist of length >1. | ||
| 49 | (cl-remprop x 'd) | ||
| 50 | (should (equal (symbol-plist x) '(a 1 b 2))) | ||
| 51 | ;; Remove first property from a plist of length >1. | ||
| 52 | (cl-remprop x 'a) | ||
| 53 | (should (equal (symbol-plist x) '(b 2))) | ||
| 54 | ;; Remove property when there is only one. | ||
| 55 | (cl-remprop x 'b) | ||
| 56 | (should (equal (symbol-plist x) '())))) | ||
| 57 | |||
| 58 | (ert-deftest cl-lib-test-remove-if-not () | ||
| 59 | (let ((list (list 'a 'b 'c 'd)) | ||
| 60 | (i 0)) | ||
| 61 | (let ((result (cl-remove-if-not (lambda (x) | ||
| 62 | (should (eql x (nth i list))) | ||
| 63 | (cl-incf i) | ||
| 64 | (member i '(2 3))) | ||
| 65 | list))) | ||
| 66 | (should (equal i 4)) | ||
| 67 | (should (equal result '(b c))) | ||
| 68 | (should (equal list '(a b c d))))) | ||
| 69 | (should (equal '() | ||
| 70 | (cl-remove-if-not (lambda (_x) (should nil)) '())))) | ||
| 71 | |||
| 72 | (ert-deftest cl-lib-test-remove () | ||
| 73 | (let ((list (list 'a 'b 'c 'd)) | ||
| 74 | (key-index 0) | ||
| 75 | (test-index 0)) | ||
| 76 | (let ((result | ||
| 77 | (cl-remove 'foo list | ||
| 78 | :key (lambda (x) | ||
| 79 | (should (eql x (nth key-index list))) | ||
| 80 | (prog1 | ||
| 81 | (list key-index x) | ||
| 82 | (cl-incf key-index))) | ||
| 83 | :test | ||
| 84 | (lambda (a b) | ||
| 85 | (should (eql a 'foo)) | ||
| 86 | (should (equal b (list test-index | ||
| 87 | (nth test-index list)))) | ||
| 88 | (cl-incf test-index) | ||
| 89 | (member test-index '(2 3)))))) | ||
| 90 | (should (equal key-index 4)) | ||
| 91 | (should (equal test-index 4)) | ||
| 92 | (should (equal result '(a d))) | ||
| 93 | (should (equal list '(a b c d))))) | ||
| 94 | (let ((x (cons nil nil)) | ||
| 95 | (y (cons nil nil))) | ||
| 96 | (should (equal (cl-remove x (list x y)) | ||
| 97 | ;; or (list x), since we use `equal' -- the | ||
| 98 | ;; important thing is that only one element got | ||
| 99 | ;; removed, this proves that the default test is | ||
| 100 | ;; `eql', not `equal' | ||
| 101 | (list y))))) | ||
| 102 | |||
| 103 | |||
| 104 | (ert-deftest cl-lib-test-set-functions () | ||
| 105 | (let ((c1 (cons nil nil)) | ||
| 106 | (c2 (cons nil nil)) | ||
| 107 | (sym (make-symbol "a"))) | ||
| 108 | (let ((e '()) | ||
| 109 | (a (list 'a 'b sym nil "" "x" c1 c2)) | ||
| 110 | (b (list c1 'y 'b sym 'x))) | ||
| 111 | (should (equal (cl-set-difference e e) e)) | ||
| 112 | (should (equal (cl-set-difference a e) a)) | ||
| 113 | (should (equal (cl-set-difference e a) e)) | ||
| 114 | (should (equal (cl-set-difference a a) e)) | ||
| 115 | (should (equal (cl-set-difference b e) b)) | ||
| 116 | (should (equal (cl-set-difference e b) e)) | ||
| 117 | (should (equal (cl-set-difference b b) e)) | ||
| 118 | ;; Note: this test (and others) is sensitive to the order of the | ||
| 119 | ;; result, which is not documented. | ||
| 120 | (should (equal (cl-set-difference a b) (list c2 "x" "" nil 'a))) | ||
| 121 | (should (equal (cl-set-difference b a) (list 'x 'y))) | ||
| 122 | |||
| 123 | ;; We aren't testing whether this is really using `eq' rather than `eql'. | ||
| 124 | (should (equal (cl-set-difference e e :test 'eq) e)) | ||
| 125 | (should (equal (cl-set-difference a e :test 'eq) a)) | ||
| 126 | (should (equal (cl-set-difference e a :test 'eq) e)) | ||
| 127 | (should (equal (cl-set-difference a a :test 'eq) e)) | ||
| 128 | (should (equal (cl-set-difference b e :test 'eq) b)) | ||
| 129 | (should (equal (cl-set-difference e b :test 'eq) e)) | ||
| 130 | (should (equal (cl-set-difference b b :test 'eq) e)) | ||
| 131 | (should (equal (cl-set-difference a b :test 'eq) (list c2 "x" "" nil 'a))) | ||
| 132 | (should (equal (cl-set-difference b a :test 'eq) (list 'x 'y))) | ||
| 133 | |||
| 134 | (should (equal (cl-union e e) e)) | ||
| 135 | (should (equal (cl-union a e) a)) | ||
| 136 | (should (equal (cl-union e a) a)) | ||
| 137 | (should (equal (cl-union a a) a)) | ||
| 138 | (should (equal (cl-union b e) b)) | ||
| 139 | (should (equal (cl-union e b) b)) | ||
| 140 | (should (equal (cl-union b b) b)) | ||
| 141 | (should (equal (cl-union a b) (list 'x 'y 'a 'b sym nil "" "x" c1 c2))) | ||
| 142 | |||
| 143 | (should (equal (cl-union b a) (list 'x 'y 'a 'b sym nil "" "x" c1 c2))) | ||
| 144 | |||
| 145 | (should (equal (cl-intersection e e) e)) | ||
| 146 | (should (equal (cl-intersection a e) e)) | ||
| 147 | (should (equal (cl-intersection e a) e)) | ||
| 148 | (should (equal (cl-intersection a a) a)) | ||
| 149 | (should (equal (cl-intersection b e) e)) | ||
| 150 | (should (equal (cl-intersection e b) e)) | ||
| 151 | (should (equal (cl-intersection b b) b)) | ||
| 152 | (should (equal (cl-intersection a b) (list sym 'b c1))) | ||
| 153 | (should (equal (cl-intersection b a) (list sym 'b c1)))))) | ||
| 154 | |||
| 155 | (ert-deftest cl-lib-test-gensym () | ||
| 156 | ;; Since the expansion of `should' calls `cl-gensym' and thus has a | ||
| 157 | ;; side-effect on `cl--gensym-counter', we have to make sure all | ||
| 158 | ;; macros in our test body are expanded before we rebind | ||
| 159 | ;; `cl--gensym-counter' and run the body. Otherwise, the test would | ||
| 160 | ;; fail if run interpreted. | ||
| 161 | (let ((body (byte-compile | ||
| 162 | '(lambda () | ||
| 163 | (should (equal (symbol-name (cl-gensym)) "G0")) | ||
| 164 | (should (equal (symbol-name (cl-gensym)) "G1")) | ||
| 165 | (should (equal (symbol-name (cl-gensym)) "G2")) | ||
| 166 | (should (equal (symbol-name (cl-gensym "foo")) "foo3")) | ||
| 167 | (should (equal (symbol-name (cl-gensym "bar")) "bar4")) | ||
| 168 | (should (equal cl--gensym-counter 5)))))) | ||
| 169 | (let ((cl--gensym-counter 0)) | ||
| 170 | (funcall body)))) | ||
| 171 | |||
| 172 | (ert-deftest cl-lib-test-coerce-to-vector () | ||
| 173 | (let* ((a (vector)) | ||
| 174 | (b (vector 1 a 3)) | ||
| 175 | (c (list)) | ||
| 176 | (d (list b a))) | ||
| 177 | (should (eql (cl-coerce a 'vector) a)) | ||
| 178 | (should (eql (cl-coerce b 'vector) b)) | ||
| 179 | (should (equal (cl-coerce c 'vector) (vector))) | ||
| 180 | (should (equal (cl-coerce d 'vector) (vector b a))))) | ||
| 181 | |||
| 182 | (ert-deftest cl-lib-test-string-position () | ||
| 183 | (should (eql (cl-position ?x "") nil)) | ||
| 184 | (should (eql (cl-position ?a "abc") 0)) | ||
| 185 | (should (eql (cl-position ?b "abc") 1)) | ||
| 186 | (should (eql (cl-position ?c "abc") 2)) | ||
| 187 | (should (eql (cl-position ?d "abc") nil)) | ||
| 188 | (should (eql (cl-position ?A "abc") nil))) | ||
| 189 | |||
| 190 | (ert-deftest cl-lib-test-mismatch () | ||
| 191 | (should (eql (cl-mismatch "" "") nil)) | ||
| 192 | (should (eql (cl-mismatch "" "a") 0)) | ||
| 193 | (should (eql (cl-mismatch "a" "a") nil)) | ||
| 194 | (should (eql (cl-mismatch "ab" "a") 1)) | ||
| 195 | (should (eql (cl-mismatch "Aa" "aA") 0)) | ||
| 196 | (should (eql (cl-mismatch '(a b c) '(a b d)) 2))) | ||
| 197 | |||
| 198 | ;;; cl-lib.el ends here | ||
diff --git a/test/automated/decoder-tests.el b/test/automated/decoder-tests.el index e1b05faf3c0..2e99fd7f115 100644 --- a/test/automated/decoder-tests.el +++ b/test/automated/decoder-tests.el | |||
| @@ -213,10 +213,9 @@ | |||
| 213 | ;; PREFER is non-nil, prefer that coding system before reading. | 213 | ;; PREFER is non-nil, prefer that coding system before reading. |
| 214 | 214 | ||
| 215 | (defun decoder-tests-prefer-utf-8-read (file detect prefer) | 215 | (defun decoder-tests-prefer-utf-8-read (file detect prefer) |
| 216 | (if prefer | ||
| 217 | (prefer-coding-system prefer)) | ||
| 218 | (with-temp-buffer | 216 | (with-temp-buffer |
| 219 | (insert-file-contents file) | 217 | (with-coding-priority (if prefer (list prefer)) |
| 218 | (insert-file-contents file)) | ||
| 220 | (if (eq buffer-file-coding-system detect) | 219 | (if (eq buffer-file-coding-system detect) |
| 221 | nil | 220 | nil |
| 222 | (format "Invalid detection: %s" buffer-file-coding-system)))) | 221 | (format "Invalid detection: %s" buffer-file-coding-system)))) |
diff --git a/test/automated/ert-tests.el b/test/automated/ert-tests.el index 0c3c3692c1d..36864377ec9 100644 --- a/test/automated/ert-tests.el +++ b/test/automated/ert-tests.el | |||
| @@ -26,11 +26,9 @@ | |||
| 26 | 26 | ||
| 27 | ;;; Code: | 27 | ;;; Code: |
| 28 | 28 | ||
| 29 | (eval-when-compile | 29 | (require 'cl-lib) |
| 30 | (require 'cl-lib)) | ||
| 31 | (require 'ert) | 30 | (require 'ert) |
| 32 | 31 | ||
| 33 | |||
| 34 | ;;; Self-test that doesn't rely on ERT, for bootstrapping. | 32 | ;;; Self-test that doesn't rely on ERT, for bootstrapping. |
| 35 | 33 | ||
| 36 | ;; This is used to test that bodies actually run. | 34 | ;; This is used to test that bodies actually run. |
| @@ -578,7 +576,7 @@ This macro is used to test if macroexpansion in `should' works." | |||
| 578 | (should (ert--special-operator-p 'if)) | 576 | (should (ert--special-operator-p 'if)) |
| 579 | (should-not (ert--special-operator-p 'car)) | 577 | (should-not (ert--special-operator-p 'car)) |
| 580 | (should-not (ert--special-operator-p 'ert--special-operator-p)) | 578 | (should-not (ert--special-operator-p 'ert--special-operator-p)) |
| 581 | (let ((b (ert--gensym))) | 579 | (let ((b (cl-gensym))) |
| 582 | (should-not (ert--special-operator-p b)) | 580 | (should-not (ert--special-operator-p b)) |
| 583 | (fset b 'if) | 581 | (fset b 'if) |
| 584 | (should (ert--special-operator-p b)))) | 582 | (should (ert--special-operator-p b)))) |
| @@ -626,171 +624,6 @@ This macro is used to test if macroexpansion in `should' works." | |||
| 626 | :explanation nil) | 624 | :explanation nil) |
| 627 | )))))) | 625 | )))))) |
| 628 | 626 | ||
| 629 | (ert-deftest ert-test-remprop () | ||
| 630 | (let ((x (ert--gensym))) | ||
| 631 | (should (equal (symbol-plist x) '())) | ||
| 632 | ;; Remove nonexistent property on empty plist. | ||
| 633 | (ert--remprop x 'b) | ||
| 634 | (should (equal (symbol-plist x) '())) | ||
| 635 | (put x 'a 1) | ||
| 636 | (should (equal (symbol-plist x) '(a 1))) | ||
| 637 | ;; Remove nonexistent property on nonempty plist. | ||
| 638 | (ert--remprop x 'b) | ||
| 639 | (should (equal (symbol-plist x) '(a 1))) | ||
| 640 | (put x 'b 2) | ||
| 641 | (put x 'c 3) | ||
| 642 | (put x 'd 4) | ||
| 643 | (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4))) | ||
| 644 | ;; Remove property that is neither first nor last. | ||
| 645 | (ert--remprop x 'c) | ||
| 646 | (should (equal (symbol-plist x) '(a 1 b 2 d 4))) | ||
| 647 | ;; Remove last property from a plist of length >1. | ||
| 648 | (ert--remprop x 'd) | ||
| 649 | (should (equal (symbol-plist x) '(a 1 b 2))) | ||
| 650 | ;; Remove first property from a plist of length >1. | ||
| 651 | (ert--remprop x 'a) | ||
| 652 | (should (equal (symbol-plist x) '(b 2))) | ||
| 653 | ;; Remove property when there is only one. | ||
| 654 | (ert--remprop x 'b) | ||
| 655 | (should (equal (symbol-plist x) '())))) | ||
| 656 | |||
| 657 | (ert-deftest ert-test-remove-if-not () | ||
| 658 | (let ((list (list 'a 'b 'c 'd)) | ||
| 659 | (i 0)) | ||
| 660 | (let ((result (ert--remove-if-not (lambda (x) | ||
| 661 | (should (eql x (nth i list))) | ||
| 662 | (cl-incf i) | ||
| 663 | (member i '(2 3))) | ||
| 664 | list))) | ||
| 665 | (should (equal i 4)) | ||
| 666 | (should (equal result '(b c))) | ||
| 667 | (should (equal list '(a b c d))))) | ||
| 668 | (should (equal '() | ||
| 669 | (ert--remove-if-not (lambda (_x) (should nil)) '())))) | ||
| 670 | |||
| 671 | (ert-deftest ert-test-remove* () | ||
| 672 | (let ((list (list 'a 'b 'c 'd)) | ||
| 673 | (key-index 0) | ||
| 674 | (test-index 0)) | ||
| 675 | (let ((result | ||
| 676 | (ert--remove* 'foo list | ||
| 677 | :key (lambda (x) | ||
| 678 | (should (eql x (nth key-index list))) | ||
| 679 | (prog1 | ||
| 680 | (list key-index x) | ||
| 681 | (cl-incf key-index))) | ||
| 682 | :test | ||
| 683 | (lambda (a b) | ||
| 684 | (should (eql a 'foo)) | ||
| 685 | (should (equal b (list test-index | ||
| 686 | (nth test-index list)))) | ||
| 687 | (cl-incf test-index) | ||
| 688 | (member test-index '(2 3)))))) | ||
| 689 | (should (equal key-index 4)) | ||
| 690 | (should (equal test-index 4)) | ||
| 691 | (should (equal result '(a d))) | ||
| 692 | (should (equal list '(a b c d))))) | ||
| 693 | (let ((x (cons nil nil)) | ||
| 694 | (y (cons nil nil))) | ||
| 695 | (should (equal (ert--remove* x (list x y)) | ||
| 696 | ;; or (list x), since we use `equal' -- the | ||
| 697 | ;; important thing is that only one element got | ||
| 698 | ;; removed, this proves that the default test is | ||
| 699 | ;; `eql', not `equal' | ||
| 700 | (list y))))) | ||
| 701 | |||
| 702 | |||
| 703 | (ert-deftest ert-test-set-functions () | ||
| 704 | (let ((c1 (cons nil nil)) | ||
| 705 | (c2 (cons nil nil)) | ||
| 706 | (sym (make-symbol "a"))) | ||
| 707 | (let ((e '()) | ||
| 708 | (a (list 'a 'b sym nil "" "x" c1 c2)) | ||
| 709 | (b (list c1 'y 'b sym 'x))) | ||
| 710 | (should (equal (ert--set-difference e e) e)) | ||
| 711 | (should (equal (ert--set-difference a e) a)) | ||
| 712 | (should (equal (ert--set-difference e a) e)) | ||
| 713 | (should (equal (ert--set-difference a a) e)) | ||
| 714 | (should (equal (ert--set-difference b e) b)) | ||
| 715 | (should (equal (ert--set-difference e b) e)) | ||
| 716 | (should (equal (ert--set-difference b b) e)) | ||
| 717 | (should (equal (ert--set-difference a b) (list 'a nil "" "x" c2))) | ||
| 718 | (should (equal (ert--set-difference b a) (list 'y 'x))) | ||
| 719 | |||
| 720 | ;; We aren't testing whether this is really using `eq' rather than `eql'. | ||
| 721 | (should (equal (ert--set-difference-eq e e) e)) | ||
| 722 | (should (equal (ert--set-difference-eq a e) a)) | ||
| 723 | (should (equal (ert--set-difference-eq e a) e)) | ||
| 724 | (should (equal (ert--set-difference-eq a a) e)) | ||
| 725 | (should (equal (ert--set-difference-eq b e) b)) | ||
| 726 | (should (equal (ert--set-difference-eq e b) e)) | ||
| 727 | (should (equal (ert--set-difference-eq b b) e)) | ||
| 728 | (should (equal (ert--set-difference-eq a b) (list 'a nil "" "x" c2))) | ||
| 729 | (should (equal (ert--set-difference-eq b a) (list 'y 'x))) | ||
| 730 | |||
| 731 | (should (equal (ert--union e e) e)) | ||
| 732 | (should (equal (ert--union a e) a)) | ||
| 733 | (should (equal (ert--union e a) a)) | ||
| 734 | (should (equal (ert--union a a) a)) | ||
| 735 | (should (equal (ert--union b e) b)) | ||
| 736 | (should (equal (ert--union e b) b)) | ||
| 737 | (should (equal (ert--union b b) b)) | ||
| 738 | (should (equal (ert--union a b) (list 'a 'b sym nil "" "x" c1 c2 'y 'x))) | ||
| 739 | (should (equal (ert--union b a) (list c1 'y 'b sym 'x 'a nil "" "x" c2))) | ||
| 740 | |||
| 741 | (should (equal (ert--intersection e e) e)) | ||
| 742 | (should (equal (ert--intersection a e) e)) | ||
| 743 | (should (equal (ert--intersection e a) e)) | ||
| 744 | (should (equal (ert--intersection a a) a)) | ||
| 745 | (should (equal (ert--intersection b e) e)) | ||
| 746 | (should (equal (ert--intersection e b) e)) | ||
| 747 | (should (equal (ert--intersection b b) b)) | ||
| 748 | (should (equal (ert--intersection a b) (list 'b sym c1))) | ||
| 749 | (should (equal (ert--intersection b a) (list c1 'b sym)))))) | ||
| 750 | |||
| 751 | (ert-deftest ert-test-gensym () | ||
| 752 | ;; Since the expansion of `should' calls `ert--gensym' and thus has a | ||
| 753 | ;; side-effect on `ert--gensym-counter', we have to make sure all | ||
| 754 | ;; macros in our test body are expanded before we rebind | ||
| 755 | ;; `ert--gensym-counter' and run the body. Otherwise, the test would | ||
| 756 | ;; fail if run interpreted. | ||
| 757 | (let ((body (byte-compile | ||
| 758 | '(lambda () | ||
| 759 | (should (equal (symbol-name (ert--gensym)) "G0")) | ||
| 760 | (should (equal (symbol-name (ert--gensym)) "G1")) | ||
| 761 | (should (equal (symbol-name (ert--gensym)) "G2")) | ||
| 762 | (should (equal (symbol-name (ert--gensym "foo")) "foo3")) | ||
| 763 | (should (equal (symbol-name (ert--gensym "bar")) "bar4")) | ||
| 764 | (should (equal ert--gensym-counter 5)))))) | ||
| 765 | (let ((ert--gensym-counter 0)) | ||
| 766 | (funcall body)))) | ||
| 767 | |||
| 768 | (ert-deftest ert-test-coerce-to-vector () | ||
| 769 | (let* ((a (vector)) | ||
| 770 | (b (vector 1 a 3)) | ||
| 771 | (c (list)) | ||
| 772 | (d (list b a))) | ||
| 773 | (should (eql (ert--coerce-to-vector a) a)) | ||
| 774 | (should (eql (ert--coerce-to-vector b) b)) | ||
| 775 | (should (equal (ert--coerce-to-vector c) (vector))) | ||
| 776 | (should (equal (ert--coerce-to-vector d) (vector b a))))) | ||
| 777 | |||
| 778 | (ert-deftest ert-test-string-position () | ||
| 779 | (should (eql (ert--string-position ?x "") nil)) | ||
| 780 | (should (eql (ert--string-position ?a "abc") 0)) | ||
| 781 | (should (eql (ert--string-position ?b "abc") 1)) | ||
| 782 | (should (eql (ert--string-position ?c "abc") 2)) | ||
| 783 | (should (eql (ert--string-position ?d "abc") nil)) | ||
| 784 | (should (eql (ert--string-position ?A "abc") nil))) | ||
| 785 | |||
| 786 | (ert-deftest ert-test-mismatch () | ||
| 787 | (should (eql (ert--mismatch "" "") nil)) | ||
| 788 | (should (eql (ert--mismatch "" "a") 0)) | ||
| 789 | (should (eql (ert--mismatch "a" "a") nil)) | ||
| 790 | (should (eql (ert--mismatch "ab" "a") 1)) | ||
| 791 | (should (eql (ert--mismatch "Aa" "aA") 0)) | ||
| 792 | (should (eql (ert--mismatch '(a b c) '(a b d)) 2))) | ||
| 793 | |||
| 794 | (ert-deftest ert-test-string-first-line () | 627 | (ert-deftest ert-test-string-first-line () |
| 795 | (should (equal (ert--string-first-line "") "")) | 628 | (should (equal (ert--string-first-line "") "")) |
| 796 | (should (equal (ert--string-first-line "abc") "abc")) | 629 | (should (equal (ert--string-first-line "abc") "abc")) |
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index 8fcfbe548fc..0e9be33f157 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el | |||
| @@ -77,40 +77,46 @@ | |||
| 77 | 77 | ||
| 78 | (ert-deftest file-notify-test00-availability () | 78 | (ert-deftest file-notify-test00-availability () |
| 79 | "Test availability of `file-notify'." | 79 | "Test availability of `file-notify'." |
| 80 | :expected-result (if file-notify-support :passed :failed) | ||
| 80 | (should (memq file-notify-support '(gfilenotify inotify w32notify)))) | 81 | (should (memq file-notify-support '(gfilenotify inotify w32notify)))) |
| 81 | 82 | ||
| 82 | (ert-deftest file-notify-test01-add-watch () | 83 | (when file-notify-support |
| 83 | "Check `file-notify-add-watch'." | ||
| 84 | (let (desc) | ||
| 85 | ;; Check, that different valid parameters are accepted. | ||
| 86 | (should (setq desc (file-notify-add-watch | ||
| 87 | temporary-file-directory '(change) 'ignore))) | ||
| 88 | (file-notify-rm-watch desc) | ||
| 89 | (should (setq desc (file-notify-add-watch | ||
| 90 | temporary-file-directory '(attribute-change) 'ignore))) | ||
| 91 | (file-notify-rm-watch desc) | ||
| 92 | (should (setq desc (file-notify-add-watch | ||
| 93 | temporary-file-directory | ||
| 94 | '(change attribute-change) 'ignore))) | ||
| 95 | (file-notify-rm-watch desc) | ||
| 96 | |||
| 97 | ;; Check error handling. | ||
| 98 | (should | ||
| 99 | (equal (car (should-error (file-notify-add-watch 1 2 3 4))) | ||
| 100 | 'wrong-number-of-arguments)) | ||
| 101 | (should | ||
| 102 | (equal (should-error (file-notify-add-watch 1 2 3)) | ||
| 103 | '(wrong-type-argument 1))) | ||
| 104 | (should | ||
| 105 | (equal (should-error (file-notify-add-watch temporary-file-directory 2 3)) | ||
| 106 | '(wrong-type-argument 2))) | ||
| 107 | (should | ||
| 108 | (equal (should-error (file-notify-add-watch | ||
| 109 | temporary-file-directory '(change) 3)) | ||
| 110 | '(wrong-type-argument 3))))) | ||
| 111 | 84 | ||
| 112 | (file-notify--deftest-remote file-notify-test01-add-watch | 85 | (ert-deftest file-notify-test01-add-watch () |
| 113 | "Check `file-notify-add-watch' for remote files.") | 86 | "Check `file-notify-add-watch'." |
| 87 | (let (desc) | ||
| 88 | ;; Check, that different valid parameters are accepted. | ||
| 89 | (should (setq desc (file-notify-add-watch | ||
| 90 | temporary-file-directory '(change) 'ignore))) | ||
| 91 | (file-notify-rm-watch desc) | ||
| 92 | (should (setq desc (file-notify-add-watch | ||
| 93 | temporary-file-directory | ||
| 94 | '(attribute-change) 'ignore))) | ||
| 95 | (file-notify-rm-watch desc) | ||
| 96 | (should (setq desc (file-notify-add-watch | ||
| 97 | temporary-file-directory | ||
| 98 | '(change attribute-change) 'ignore))) | ||
| 99 | (file-notify-rm-watch desc) | ||
| 100 | |||
| 101 | ;; Check error handling. | ||
| 102 | (should | ||
| 103 | (equal (car (should-error (file-notify-add-watch 1 2 3 4))) | ||
| 104 | 'wrong-number-of-arguments)) | ||
| 105 | (should | ||
| 106 | (equal (should-error (file-notify-add-watch 1 2 3)) | ||
| 107 | '(wrong-type-argument 1))) | ||
| 108 | (should | ||
| 109 | (equal (should-error (file-notify-add-watch | ||
| 110 | temporary-file-directory 2 3)) | ||
| 111 | '(wrong-type-argument 2))) | ||
| 112 | (should | ||
| 113 | (equal (should-error (file-notify-add-watch | ||
| 114 | temporary-file-directory '(change) 3)) | ||
| 115 | '(wrong-type-argument 3))))) | ||
| 116 | |||
| 117 | (file-notify--deftest-remote file-notify-test01-add-watch | ||
| 118 | "Check `file-notify-add-watch' for remote files.") | ||
| 119 | ) ;; file-notify-support | ||
| 114 | 120 | ||
| 115 | (defun file-notify--test-event-test () | 121 | (defun file-notify--test-event-test () |
| 116 | "Ert test function to be called by `file-notify--test-event-handler'. | 122 | "Ert test function to be called by `file-notify--test-event-handler'. |
| @@ -141,52 +147,55 @@ Save the result in `file-notify--test-results', for later analysis." | |||
| 141 | (expand-file-name | 147 | (expand-file-name |
| 142 | (make-temp-name "file-notify-test") temporary-file-directory)) | 148 | (make-temp-name "file-notify-test") temporary-file-directory)) |
| 143 | 149 | ||
| 144 | (ert-deftest file-notify-test02-events () | 150 | (when file-notify-support |
| 145 | "Check file creation/removal notifications." | 151 | |
| 146 | (let (desc) | 152 | (ert-deftest file-notify-test02-events () |
| 147 | (unwind-protect | 153 | "Check file creation/removal notifications." |
| 148 | (progn | 154 | (let (desc) |
| 149 | (setq file-notify--test-results nil | 155 | (unwind-protect |
| 150 | file-notify--test-tmpfile (file-notify--test-make-temp-name) | 156 | (progn |
| 151 | file-notify--test-tmpfile1 (file-notify--test-make-temp-name) | 157 | (setq file-notify--test-results nil |
| 152 | desc | 158 | file-notify--test-tmpfile (file-notify--test-make-temp-name) |
| 153 | (file-notify-add-watch | 159 | file-notify--test-tmpfile1 (file-notify--test-make-temp-name) |
| 154 | file-notify--test-tmpfile | 160 | desc |
| 155 | '(change) 'file-notify--test-event-handler)) | 161 | (file-notify-add-watch |
| 156 | 162 | file-notify--test-tmpfile | |
| 157 | ;; Check creation and removal. | 163 | '(change) 'file-notify--test-event-handler)) |
| 158 | (write-region "any text" nil file-notify--test-tmpfile) | 164 | |
| 159 | (delete-file file-notify--test-tmpfile) | 165 | ;; Check creation and removal. |
| 160 | 166 | (write-region "any text" nil file-notify--test-tmpfile) | |
| 161 | ;; Check copy and rename. | 167 | (delete-file file-notify--test-tmpfile) |
| 162 | (write-region "any text" nil file-notify--test-tmpfile) | 168 | |
| 163 | (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) | 169 | ;; Check copy and rename. |
| 164 | (delete-file file-notify--test-tmpfile) | 170 | (write-region "any text" nil file-notify--test-tmpfile) |
| 165 | (delete-file file-notify--test-tmpfile1) | 171 | (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) |
| 166 | 172 | (delete-file file-notify--test-tmpfile) | |
| 167 | (write-region "any text" nil file-notify--test-tmpfile) | 173 | (delete-file file-notify--test-tmpfile1) |
| 168 | (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) | 174 | |
| 169 | (delete-file file-notify--test-tmpfile1)) | 175 | (write-region "any text" nil file-notify--test-tmpfile) |
| 170 | 176 | (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) | |
| 171 | ;; Wait for events, and exit. | 177 | (delete-file file-notify--test-tmpfile1)) |
| 172 | (sit-for 5 'nodisplay) | 178 | |
| 173 | (file-notify-rm-watch desc) | 179 | ;; Wait for events, and exit. |
| 174 | (ignore-errors (delete-file file-notify--test-tmpfile)) | 180 | (sit-for 5 'nodisplay) |
| 175 | (ignore-errors (delete-file file-notify--test-tmpfile1)))) | 181 | (file-notify-rm-watch desc) |
| 182 | (ignore-errors (delete-file file-notify--test-tmpfile)) | ||
| 183 | (ignore-errors (delete-file file-notify--test-tmpfile1)))) | ||
| 176 | 184 | ||
| 177 | (dolist (result file-notify--test-results) | 185 | (dolist (result file-notify--test-results) |
| 178 | ;(message "%s" (ert-test-result-messages result)) | 186 | ;(message "%s" (ert-test-result-messages result)) |
| 179 | (when (ert-test-failed-p result) | 187 | (when (ert-test-failed-p result) |
| 180 | (ert-fail (cadr (ert-test-result-with-condition-condition result)))))) | 188 | (ert-fail (cadr (ert-test-result-with-condition-condition result)))))) |
| 181 | 189 | ||
| 182 | (file-notify--deftest-remote file-notify-test02-events | 190 | (file-notify--deftest-remote file-notify-test02-events |
| 183 | "Check file creation/removal notifications for remote files.") | 191 | "Check file creation/removal notifications for remote files.") |
| 192 | ) ;; file-notify-support | ||
| 184 | 193 | ||
| 185 | ;; autorevert runs only in interactive mode. | 194 | ;; autorevert runs only in interactive mode. |
| 186 | (defvar auto-revert-remote-files) | 195 | (defvar auto-revert-remote-files) |
| 187 | (setq auto-revert-remote-files t) | 196 | (setq auto-revert-remote-files t) |
| 188 | (require 'autorevert) | 197 | (require 'autorevert) |
| 189 | (when (null noninteractive) | 198 | (when (and file-notify-support (null noninteractive)) |
| 190 | 199 | ||
| 191 | (ert-deftest file-notify-test03-autorevert () | 200 | (ert-deftest file-notify-test03-autorevert () |
| 192 | "Check autorevert via file notification. | 201 | "Check autorevert via file notification. |
| @@ -240,7 +249,7 @@ This test is skipped in batch mode." | |||
| 240 | (file-notify--deftest-remote file-notify-test03-autorevert | 249 | (file-notify--deftest-remote file-notify-test03-autorevert |
| 241 | "Check autorevert via file notification for remote files. | 250 | "Check autorevert via file notification for remote files. |
| 242 | This test is skipped in batch mode.") | 251 | This test is skipped in batch mode.") |
| 243 | ) ;; (null noninteractive) | 252 | ) ;; (and file-notify-support (null noninteractive)) |
| 244 | 253 | ||
| 245 | (defun file-notify-test-all (&optional interactive) | 254 | (defun file-notify-test-all (&optional interactive) |
| 246 | "Run all tests for \\[file-notify]." | 255 | "Run all tests for \\[file-notify]." |
diff --git a/test/automated/files.el b/test/automated/files.el index f2d2192a420..8ce2ed7230c 100644 --- a/test/automated/files.el +++ b/test/automated/files.el | |||
| @@ -146,4 +146,7 @@ form.") | |||
| 146 | (should (file-test--do-local-variables-test str subtest)))))) | 146 | (should (file-test--do-local-variables-test str subtest)))))) |
| 147 | (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test))) | 147 | (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test))) |
| 148 | 148 | ||
| 149 | ;; Stop the above "Local Var..." confusing Emacs. | ||
| 150 | |||
| 151 | |||
| 149 | ;;; files.el ends here | 152 | ;;; files.el ends here |
diff --git a/test/automated/flymake-tests.el b/test/automated/flymake-tests.el index 9cc87b608ad..03a8fb08bc5 100644 --- a/test/automated/flymake-tests.el +++ b/test/automated/flymake-tests.el | |||
| @@ -25,9 +25,6 @@ | |||
| 25 | (require 'ert) | 25 | (require 'ert) |
| 26 | (require 'flymake) | 26 | (require 'flymake) |
| 27 | 27 | ||
| 28 | (defgroup flymake-tests nil | ||
| 29 | "Test suite for flymake.") | ||
| 30 | |||
| 31 | 28 | ||
| 32 | ;; Warning predicate | 29 | ;; Warning predicate |
| 33 | (defun flymake-tests--current-face (file predicate) | 30 | (defun flymake-tests--current-face (file predicate) |
diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el index bca462da4d9..28fa47630a8 100644 --- a/test/automated/icalendar-tests.el +++ b/test/automated/icalendar-tests.el | |||
| @@ -1194,8 +1194,7 @@ Argument INPUT icalendar event string." | |||
| 1194 | (should (string= org-input cycled))))) | 1194 | (should (string= org-input cycled))))) |
| 1195 | ;; clean up | 1195 | ;; clean up |
| 1196 | (kill-buffer (find-buffer-visiting temp-diary)) | 1196 | (kill-buffer (find-buffer-visiting temp-diary)) |
| 1197 | (save-excursion | 1197 | (with-current-buffer (find-buffer-visiting temp-ics) |
| 1198 | (set-buffer (find-buffer-visiting temp-ics)) | ||
| 1199 | (set-buffer-modified-p nil) | 1198 | (set-buffer-modified-p nil) |
| 1200 | (kill-buffer (current-buffer))) | 1199 | (kill-buffer (current-buffer))) |
| 1201 | (delete-file temp-diary) | 1200 | (delete-file temp-diary) |
diff --git a/test/automated/imenu-test.el b/test/automated/imenu-test.el index 83e19ebd914..b2b0c6b5c31 100644 --- a/test/automated/imenu-test.el +++ b/test/automated/imenu-test.el | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | ;;; Code: | 23 | ;;; Code: |
| 24 | 24 | ||
| 25 | (require 'ert) | ||
| 25 | (require 'imenu) | 26 | (require 'imenu) |
| 26 | 27 | ||
| 27 | ;; (imenu-simple-scan-deftest-gather-strings-from-list | 28 | ;; (imenu-simple-scan-deftest-gather-strings-from-list |
diff --git a/test/automated/inotify-test.el b/test/automated/inotify-test.el index 175f262b282..b4d20cf4fb1 100644 --- a/test/automated/inotify-test.el +++ b/test/automated/inotify-test.el | |||
| @@ -25,6 +25,9 @@ | |||
| 25 | 25 | ||
| 26 | (require 'ert) | 26 | (require 'ert) |
| 27 | 27 | ||
| 28 | (declare-function inotify-add-watch "inotify.c" (file-name aspect callback)) | ||
| 29 | (declare-function inotify-rm-watch "inotify.c" (watch-descriptor)) | ||
| 30 | |||
| 28 | (when (featurep 'inotify) | 31 | (when (featurep 'inotify) |
| 29 | 32 | ||
| 30 | ;; (ert-deftest filewatch-file-watch-aspects-check () | 33 | ;; (ert-deftest filewatch-file-watch-aspects-check () |
| @@ -45,7 +48,7 @@ | |||
| 45 | (let ((temp-file (make-temp-file "inotify-simple")) | 48 | (let ((temp-file (make-temp-file "inotify-simple")) |
| 46 | (events 0)) | 49 | (events 0)) |
| 47 | (let ((wd | 50 | (let ((wd |
| 48 | (inotify-add-watch temp-file t (lambda (ev) | 51 | (inotify-add-watch temp-file t (lambda (_ev) |
| 49 | (setq events (1+ events)))))) | 52 | (setq events (1+ events)))))) |
| 50 | (unwind-protect | 53 | (unwind-protect |
| 51 | (progn | 54 | (progn |
diff --git a/test/automated/package-test.el b/test/automated/package-test.el index 706ba953d98..a5f0ebb1f94 100755 --- a/test/automated/package-test.el +++ b/test/automated/package-test.el | |||
| @@ -142,6 +142,9 @@ | |||
| 142 | (let ((help-xref-following t)) | 142 | (let ((help-xref-following t)) |
| 143 | ,@body))) | 143 | ,@body))) |
| 144 | 144 | ||
| 145 | (autoload 'makeinfo-buffer "makeinfo") | ||
| 146 | (defvar compilation-in-progress) | ||
| 147 | |||
| 145 | (defun package-test-install-texinfo (file) | 148 | (defun package-test-install-texinfo (file) |
| 146 | "Install from texinfo FILE. | 149 | "Install from texinfo FILE. |
| 147 | 150 | ||
| @@ -156,7 +159,6 @@ FILE should be a .texinfo file relative to the current | |||
| 156 | (with-current-buffer (find-file-literally full-file) | 159 | (with-current-buffer (find-file-literally full-file) |
| 157 | (unwind-protect | 160 | (unwind-protect |
| 158 | (progn | 161 | (progn |
| 159 | (require 'makeinfo) | ||
| 160 | (makeinfo-buffer) | 162 | (makeinfo-buffer) |
| 161 | ;; Give `makeinfo-buffer' a chance to finish | 163 | ;; Give `makeinfo-buffer' a chance to finish |
| 162 | (while compilation-in-progress | 164 | (while compilation-in-progress |
| @@ -184,6 +186,9 @@ DIR is the base name of the package directory, without the trailing slash" | |||
| 184 | (dolist (file (package-test-suffix-matches dir package-test-built-file-suffixes)) | 186 | (dolist (file (package-test-suffix-matches dir package-test-built-file-suffixes)) |
| 185 | (delete-file file)))) | 187 | (delete-file file)))) |
| 186 | 188 | ||
| 189 | (defvar tar-parse-info) | ||
| 190 | (declare-function tar-header-name "tar-mode" (cl-x) t) ; defstruct | ||
| 191 | |||
| 187 | (defun package-test-search-tar-file (filename) | 192 | (defun package-test-search-tar-file (filename) |
| 188 | "Search the current buffer's `tar-parse-info' variable for FILENAME. | 193 | "Search the current buffer's `tar-parse-info' variable for FILENAME. |
| 189 | 194 | ||
diff --git a/test/automated/package-x-test.el b/test/automated/package-x-test.el index b8f2a23f6d5..beb18358085 100755 --- a/test/automated/package-x-test.el +++ b/test/automated/package-x-test.el | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | (require 'package-x) | 35 | (require 'package-x) |
| 36 | (require 'ert) | 36 | (require 'ert) |
| 37 | (require 'cl-lib) | 37 | (require 'cl-lib) |
| 38 | (eval-when-compile (require 'package-test)) | ||
| 38 | 39 | ||
| 39 | ;; package-test is not normally in `load-path', so temporarily set | 40 | ;; package-test is not normally in `load-path', so temporarily set |
| 40 | ;; `load-path' to contain the current directory. | 41 | ;; `load-path' to contain the current directory. |
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 40505cc7953..1dffe9544fe 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (require 'ert) | ||
| 24 | (require 'python) | 25 | (require 'python) |
| 25 | 26 | ||
| 26 | (defmacro python-tests-with-temp-buffer (contents &rest body) | 27 | (defmacro python-tests-with-temp-buffer (contents &rest body) |
| @@ -463,10 +464,10 @@ Class foo(object): | |||
| 463 | " | 464 | " |
| 464 | (python-tests-look-at "3)") | 465 | (python-tests-look-at "3)") |
| 465 | (forward-line 1) | 466 | (forward-line 1) |
| 466 | (= (python-indent-calculate-indentation) 12) | 467 | (should (= (python-indent-calculate-indentation) 8)) |
| 467 | (python-tests-look-at "pass") | 468 | (python-tests-look-at "pass") |
| 468 | (forward-line 1) | 469 | (forward-line 1) |
| 469 | (= (python-indent-calculate-indentation) 8))) | 470 | (should (= (python-indent-calculate-indentation) 8)))) |
| 470 | 471 | ||
| 471 | 472 | ||
| 472 | ;;; Navigation | 473 | ;;; Navigation |
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index 02582e8ad2d..ad805f16777 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (require 'ert) | ||
| 24 | (require 'ruby-mode) | 25 | (require 'ruby-mode) |
| 25 | 26 | ||
| 26 | (defun ruby-should-indent (content column) | 27 | (defun ruby-should-indent (content column) |
| @@ -474,29 +475,30 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 474 | (with-temp-buffer | 475 | (with-temp-buffer |
| 475 | (insert ruby-block-test-example) | 476 | (insert ruby-block-test-example) |
| 476 | (ruby-mode) | 477 | (ruby-mode) |
| 478 | (goto-char (point-min)) | ||
| 477 | ,@body))) | 479 | ,@body))) |
| 478 | 480 | ||
| 479 | (put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun) | 481 | (put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun) |
| 480 | 482 | ||
| 481 | (ruby-deftest-move-to-block works-on-do | 483 | (ruby-deftest-move-to-block works-on-do |
| 482 | (goto-line 11) | 484 | (forward-line 10) |
| 483 | (ruby-end-of-block) | 485 | (ruby-end-of-block) |
| 484 | (should (= 13 (line-number-at-pos))) | 486 | (should (= 13 (line-number-at-pos))) |
| 485 | (ruby-beginning-of-block) | 487 | (ruby-beginning-of-block) |
| 486 | (should (= 11 (line-number-at-pos)))) | 488 | (should (= 11 (line-number-at-pos)))) |
| 487 | 489 | ||
| 488 | (ruby-deftest-move-to-block zero-is-noop | 490 | (ruby-deftest-move-to-block zero-is-noop |
| 489 | (goto-line 5) | 491 | (forward-line 4) |
| 490 | (ruby-move-to-block 0) | 492 | (ruby-move-to-block 0) |
| 491 | (should (= 5 (line-number-at-pos)))) | 493 | (should (= 5 (line-number-at-pos)))) |
| 492 | 494 | ||
| 493 | (ruby-deftest-move-to-block ok-with-three | 495 | (ruby-deftest-move-to-block ok-with-three |
| 494 | (goto-line 2) | 496 | (forward-line 1) |
| 495 | (ruby-move-to-block 3) | 497 | (ruby-move-to-block 3) |
| 496 | (should (= 14 (line-number-at-pos)))) | 498 | (should (= 14 (line-number-at-pos)))) |
| 497 | 499 | ||
| 498 | (ruby-deftest-move-to-block ok-with-minus-two | 500 | (ruby-deftest-move-to-block ok-with-minus-two |
| 499 | (goto-line 10) | 501 | (forward-line 9) |
| 500 | (ruby-move-to-block -2) | 502 | (ruby-move-to-block -2) |
| 501 | (should (= 2 (line-number-at-pos)))) | 503 | (should (= 2 (line-number-at-pos)))) |
| 502 | 504 | ||
| @@ -514,7 +516,7 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 514 | | | | 516 | | | |
| 515 | |end"))) | 517 | |end"))) |
| 516 | (ruby-with-temp-buffer s | 518 | (ruby-with-temp-buffer s |
| 517 | (goto-line 1) | 519 | (goto-char (point-min)) |
| 518 | (ruby-end-of-block) | 520 | (ruby-end-of-block) |
| 519 | (should (= 5 (line-number-at-pos))) | 521 | (should (= 5 (line-number-at-pos))) |
| 520 | (ruby-beginning-of-block) | 522 | (ruby-beginning-of-block) |
| @@ -529,7 +531,7 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 529 | | end | 531 | | end |
| 530 | | eowarn | 532 | | eowarn |
| 531 | |end") | 533 | |end") |
| 532 | (goto-line 1) | 534 | (goto-char (point-min)) |
| 533 | (ruby-end-of-block) | 535 | (ruby-end-of-block) |
| 534 | (should (= 6 (line-number-at-pos))) | 536 | (should (= 6 (line-number-at-pos))) |
| 535 | (ruby-beginning-of-block) | 537 | (ruby-beginning-of-block) |
| @@ -541,7 +543,6 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 541 | "foo do | 543 | "foo do |
| 542 | | Module.to_s | 544 | | Module.to_s |
| 543 | |end") | 545 | |end") |
| 544 | (end-of-buffer) | ||
| 545 | (let ((case-fold-search t)) | 546 | (let ((case-fold-search t)) |
| 546 | (ruby-beginning-of-block)) | 547 | (ruby-beginning-of-block)) |
| 547 | (should (= 1 (line-number-at-pos))))) | 548 | (should (= 1 (line-number-at-pos))))) |
| @@ -553,7 +554,8 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 553 | | end | 554 | | end |
| 554 | |else | 555 | |else |
| 555 | |end") | 556 | |end") |
| 556 | (goto-line 4) | 557 | (goto-char (point-min)) |
| 558 | (forward-line 3) | ||
| 557 | (ruby-beginning-of-block) | 559 | (ruby-beginning-of-block) |
| 558 | (should (= 1 (line-number-at-pos))))) | 560 | (should (= 1 (line-number-at-pos))))) |
| 559 | 561 | ||
| @@ -565,7 +567,8 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 565 | | Class.to_s | 567 | | Class.to_s |
| 566 | | end | 568 | | end |
| 567 | |end") | 569 | |end") |
| 568 | (goto-line 4) | 570 | (goto-char (point-min)) |
| 571 | (forward-line 3) | ||
| 569 | (let ((case-fold-search t)) | 572 | (let ((case-fold-search t)) |
| 570 | (beginning-of-defun)) | 573 | (beginning-of-defun)) |
| 571 | (should (= 2 (line-number-at-pos))))) | 574 | (should (= 2 (line-number-at-pos))))) |
| @@ -578,7 +581,8 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 578 | | 'ho hum' | 581 | | 'ho hum' |
| 579 | | end | 582 | | end |
| 580 | |end") | 583 | |end") |
| 581 | (goto-line 2) | 584 | (goto-char (point-min)) |
| 585 | (forward-line 1) | ||
| 582 | (end-of-defun) | 586 | (end-of-defun) |
| 583 | (should (= 5 (line-number-at-pos))))) | 587 | (should (= 5 (line-number-at-pos))))) |
| 584 | 588 | ||
diff --git a/test/automated/undo-tests.el b/test/automated/undo-tests.el index 98b0c52728b..87c55c5d374 100644 --- a/test/automated/undo-tests.el +++ b/test/automated/undo-tests.el | |||
| @@ -200,6 +200,32 @@ | |||
| 200 | '(error "Unrecognized entry in undo list \"bogus\"")))) | 200 | '(error "Unrecognized entry in undo list \"bogus\"")))) |
| 201 | (buffer-string)))))) | 201 | (buffer-string)))))) |
| 202 | 202 | ||
| 203 | ;; http://debbugs.gnu.org/14824 | ||
| 204 | (ert-deftest undo-test-buffer-modified () | ||
| 205 | "Test undoing marks buffer unmodified." | ||
| 206 | (with-temp-buffer | ||
| 207 | (buffer-enable-undo) | ||
| 208 | (insert "1") | ||
| 209 | (undo-boundary) | ||
| 210 | (set-buffer-modified-p nil) | ||
| 211 | (insert "2") | ||
| 212 | (undo) | ||
| 213 | (should-not (buffer-modified-p)))) | ||
| 214 | |||
| 215 | (ert-deftest undo-test-file-modified () | ||
| 216 | "Test undoing marks buffer visiting file unmodified." | ||
| 217 | (let ((tempfile (make-temp-file "undo-test"))) | ||
| 218 | (unwind-protect | ||
| 219 | (progn | ||
| 220 | (with-current-buffer (find-file-noselect tempfile) | ||
| 221 | (insert "1") | ||
| 222 | (undo-boundary) | ||
| 223 | (set-buffer-modified-p nil) | ||
| 224 | (insert "2") | ||
| 225 | (undo) | ||
| 226 | (should-not (buffer-modified-p)))) | ||
| 227 | (delete-file tempfile)))) | ||
| 228 | |||
| 203 | (defun undo-test-all (&optional interactive) | 229 | (defun undo-test-all (&optional interactive) |
| 204 | "Run all tests for \\[undo]." | 230 | "Run all tests for \\[undo]." |
| 205 | (interactive "p") | 231 | (interactive "p") |
diff --git a/test/automated/xml-parse-tests.el b/test/automated/xml-parse-tests.el index 874ae01affb..9157a0d3002 100644 --- a/test/automated/xml-parse-tests.el +++ b/test/automated/xml-parse-tests.el | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | ;;; Code: | 28 | ;;; Code: |
| 29 | 29 | ||
| 30 | (require 'ert) | ||
| 30 | (require 'xml) | 31 | (require 'xml) |
| 31 | 32 | ||
| 32 | (defvar xml-parse-tests--data | 33 | (defvar xml-parse-tests--data |