aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJoakim Verona2013-07-14 11:04:49 +0200
committerJoakim Verona2013-07-14 11:04:49 +0200
commit0bb9bb0841d89fff09820a57369df4cb01b16b43 (patch)
tree832bf9fa8415eef0ce464d22b3ee1300cfa90bb1 /test
parent3718127221fbbc31f8ebd027ab7c95403dbe9118 (diff)
parent3af1c8684ed6e48fbc21481d129e9aa164752c6e (diff)
downloademacs-0bb9bb0841d89fff09820a57369df4cb01b16b43.tar.gz
emacs-0bb9bb0841d89fff09820a57369df4cb01b16b43.zip
Merge branch 'trunk' into xwidget
Conflicts: src/xdisp.c
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog100
-rw-r--r--test/automated/add-log-tests.el1
-rw-r--r--test/automated/advice-tests.el2
-rw-r--r--test/automated/cl-lib.el198
-rw-r--r--test/automated/decoder-tests.el5
-rw-r--r--test/automated/ert-tests.el171
-rw-r--r--test/automated/file-notify-tests.el263
-rw-r--r--test/automated/files.el3
-rw-r--r--test/automated/flymake-tests.el3
-rw-r--r--test/automated/icalendar-tests.el3
-rw-r--r--test/automated/imenu-test.el1
-rw-r--r--test/automated/inotify-test.el5
-rwxr-xr-xtest/automated/package-test.el7
-rwxr-xr-xtest/automated/package-x-test.el1
-rw-r--r--test/automated/python-tests.el52
-rw-r--r--test/automated/ruby-mode-tests.el33
-rw-r--r--test/automated/undo-tests.el26
-rw-r--r--test/automated/xml-parse-tests.el1
18 files changed, 684 insertions, 191 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 9ccb1f4bc89..d69155a27ff 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,101 @@
12013-07-13 Fabián Ezequiel Gallina <fgallina@gnu.org>
2
3 * automated/python-tests.el (python-imenu-create-index-2)
4 (python-imenu-create-index-3): New tests.
5
62013-07-11 Glenn Morris <rgm@gnu.org>
7
8 * automated/ert-tests.el: Require cl-lib at runtime too.
9 (ert-test-special-operator-p): Use cl-gensym rather than ert-- version.
10 (ert-test-remprop, ert-test-remove-if-not, ert-test-remove*)
11 (ert-test-set-functions, ert-test-gensym)
12 (ert-test-coerce-to-vector, ert-test-string-position)
13 (ert-test-mismatch): Remove tests.
14 * automated/cl-lib.el: New, split from ert-tests.el.
15
16 * automated/ruby-mode-tests.el (ruby-deftest-move-to-block):
17 Goto point-min.
18 (works-on-do, zero-is-noop, ok-with-three, ok-with-minus-two)
19 (ruby-move-to-block-skips-percent-literal)
20 (ruby-move-to-block-skips-heredoc)
21 (ruby-move-to-block-moves-from-else-to-if)
22 (ruby-beginning-of-defun-does-not-fold-case)
23 (ruby-end-of-defun-skips-to-next-line-after-the-method):
24 Replace goto-line with forward-line/goto-char.
25 (ruby-move-to-block-does-not-fold-case): Remove unneeded end-of-buffer.
26
27 * automated/package-test.el (makeinfo-buffer): Autoload.
28 (compilation-in-progress, tar-parse-info, tar-header-name): Declare.
29 (package-test-install-texinfo): Don't require makeinfo.
30
31 * automated/files.el: Stop "local variables" confusion.
32
33 * automated/flymake-tests.el (flymake-tests): Remove unused group.
34
35 * automated/icalendar-tests.el (icalendar-tests--do-test-cycle):
36 Use with-current-buffer.
37
38 * automated/undo-tests.el (undo-test-buffer-modified)
39 (undo-test-file-modified): New tests.
40
412013-07-09 Michael Albinus <michael.albinus@gmx.de>
42
43 * automated/file-notify-tests.el (file-notify-test00-availability):
44 Set :expected-result.
45 (file-notify-test01-add-watch, file-notify-test01-add-watch-remote)
46 (file-notify-test02-events, file-notify-test02-events-remote)
47 (file-notify-test03-autorevert, file-notify-test03-autorevert-remote):
48 Skip when `file-notify-support' is nil. (Bug#14823)
49
502013-07-09 Glenn Morris <rgm@gnu.org>
51
52 * automated/inotify-test.el (inotify-add-watch, inotify-rm-watch):
53 Declare.
54 (inotify-file-watch-simple): Silence compiler.
55
56 * automated/python-tests.el (python-indent-block-enders):
57 Make it actually test something.
58
59 * automated/package-x-test.el: Require package-test when compiling.
60
61 * automated/add-log-tests.el, automated/advice-tests.el:
62 * automated/imenu-test.el, automated/package-x-test.el:
63 * automated/python-tests.el, automated/ruby-mode-tests.el:
64 * automated/xml-parse-tests.el: Explictly require ert.
65
662013-07-08 Kenichi Handa <handa@gnu.org>
67
68 * automated/decoder-tests.el (decoder-tests-prefer-utf-8-read):
69 Use with-ccoding-priority to avoid side-effect (Bug#14781).
70
712013-07-05 Michael Albinus <michael.albinus@gmx.de>
72
73 * automated/file-notify-tests.el
74 (file-notify-test-remote-temporary-file-directory): Use
75 `null-device' on w32.
76 (file-notify--test-tmpfile, file-notify--test-tmpfile1)
77 (file-notify--test-results, file-notify--test-event)
78 (file-notify--deftest-remote, file-notify--event-test)
79 (file-notify--test-event-handler)
80 (file-notify--test-make-temp-name): Renamed, in order to mark them
81 internal.
82 (tramp-message-show-message, tramp-read-passwd): Tweak them for
83 better fitting in noninteractive tests.
84 (file-notify-test00-availability): Renamed from `file-notify-test0'.
85 (file-notify-test01-add-watch): Renamed from `file-notify-test1'.
86 Use `temporary-file-directory '.
87 (file-notify-test01-add-watch-remote): New test.
88 (file-notify-test02-events): Renamed from `file-notify-test2'.
89 (file-notify-test02-events-remote): Renamed from `file-notify-test3'.
90 (file-notify-test03-autorevert): Renamed from
91 `file-notify-test4'. Use timeouts.
92 (file-notify-test03-autorevert-remote): Renamed from
93 `file-notify-test5'.
94
952013-07-04 Michael Albinus <michael.albinus@gmx.de>
96
97 * automated/file-notify-tests.el: New package.
98
12013-06-28 Kenichi Handa <handa@gnu.org> 992013-06-28 Kenichi Handa <handa@gnu.org>
2 100
3 * automated/decoder-tests.el (decoder-tests-gen-file): New arg FILE. 101 * automated/decoder-tests.el (decoder-tests-gen-file): New arg FILE.
@@ -43,7 +141,7 @@
43 Use it to create separate tests for each element, so we run them 141 Use it to create separate tests for each element, so we run them
44 all rather than stopping at the first error. 142 all rather than stopping at the first error.
45 143
462013-06-24 Glenn Morris <rgm@fencepost.gnu.org> 1442013-06-24 Glenn Morris <rgm@gnu.org>
47 145
48 * automated/occur-tests.el (occur-tests): 146 * automated/occur-tests.el (occur-tests):
49 Update for 2013-05-29 change to occur header line. 147 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
new file mode 100644
index 00000000000..0e9be33f157
--- /dev/null
+++ b/test/automated/file-notify-tests.el
@@ -0,0 +1,263 @@
1;;; file-notify-tests.el --- Tests of file notifications
2
3;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5;; Author: Michael Albinus <michael.albinus@gmx.de>
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;; Some of the tests are intended to run over remote files. Set
23;; `file-notify-test-remote-temporary-file-directory' to a suitable
24;; value. It must NOT require an interactive password prompt, when
25;; running the tests in batch mode.
26
27;; If you want to skip tests for remote files, set this variable to
28;; `null-device'.
29
30;;; Code:
31
32(require 'ert)
33(require 'filenotify)
34
35;; There is no default value on w32 systems, which could work out of the box.
36(defconst file-notify-test-remote-temporary-file-directory
37 (if (eq system-type 'windows-nt) null-device "/ssh::/tmp")
38 "Temporary directory for Tramp tests.")
39
40(defvar file-notify--test-tmpfile nil)
41(defvar file-notify--test-tmpfile1 nil)
42(defvar file-notify--test-results nil)
43(defvar file-notify--test-event nil)
44
45(require 'tramp)
46(setq tramp-verbose 0
47 tramp-message-show-message nil)
48(when noninteractive (defalias 'tramp-read-passwd 'ignore))
49
50(defmacro file-notify--deftest-remote (test docstring)
51 "Define ert `TEST-remote' for remote files."
52 `(when (ignore-errors
53 (and
54 (file-remote-p file-notify-test-remote-temporary-file-directory)
55 (file-directory-p file-notify-test-remote-temporary-file-directory)
56 (file-writable-p file-notify-test-remote-temporary-file-directory)))
57 ;; Define the test.
58 (ert-deftest ,(intern (concat (symbol-name test) "-remote")) ()
59 ,docstring
60 (let* ((temporary-file-directory
61 file-notify-test-remote-temporary-file-directory)
62 (ert-test (ert-get-test ',test))
63 (most-recent-result (ert-test-most-recent-result ert-test))
64 result)
65 (unwind-protect
66 (progn
67 (setq result
68 (condition-case err
69 (ert-run-test ert-test)
70 ((error quit)
71 (ert-fail err))))
72 (when (ert-test-failed-p result)
73 (ert-fail
74 (cadr (ert-test-result-with-condition-condition result)))))
75 ;; Reset status of TEST.
76 (setf (ert-test-most-recent-result ert-test) most-recent-result))))))
77
78(ert-deftest file-notify-test00-availability ()
79 "Test availability of `file-notify'."
80 :expected-result (if file-notify-support :passed :failed)
81 (should (memq file-notify-support '(gfilenotify inotify w32notify))))
82
83(when file-notify-support
84
85 (ert-deftest file-notify-test01-add-watch ()
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
120
121(defun file-notify--test-event-test ()
122 "Ert test function to be called by `file-notify--test-event-handler'.
123We cannot pass arguments, so we assume that `file-notify--test-event'
124is bound somewhere."
125 ;(message "Event %S" file-notify--test-event)
126 ;; Check the file name.
127 (should
128 (string-equal (file-notify--event-file-name file-notify--test-event)
129 file-notify--test-tmpfile))
130 ;; Check the second file name if exists.
131 (when (eq (nth 1 file-notify--test-event) 'renamed)
132 (should
133 (string-equal
134 (file-notify--event-file1-name file-notify--test-event)
135 file-notify--test-tmpfile1))))
136
137(defun file-notify--test-event-handler (file-notify--test-event)
138 "Run a test over FILE-NOTIFY--TEST-EVENT.
139Save the result in `file-notify--test-results', for later analysis."
140 (let ((result
141 (ert-run-test (make-ert-test :body 'file-notify--test-event-test))))
142 (setq file-notify--test-results
143 (append file-notify--test-results `(,result)))))
144
145(defun file-notify--test-make-temp-name ()
146 "Create a temporary file name for test."
147 (expand-file-name
148 (make-temp-name "file-notify-test") temporary-file-directory))
149
150(when file-notify-support
151
152 (ert-deftest file-notify-test02-events ()
153 "Check file creation/removal notifications."
154 (let (desc)
155 (unwind-protect
156 (progn
157 (setq file-notify--test-results nil
158 file-notify--test-tmpfile (file-notify--test-make-temp-name)
159 file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
160 desc
161 (file-notify-add-watch
162 file-notify--test-tmpfile
163 '(change) 'file-notify--test-event-handler))
164
165 ;; Check creation and removal.
166 (write-region "any text" nil file-notify--test-tmpfile)
167 (delete-file file-notify--test-tmpfile)
168
169 ;; Check copy and rename.
170 (write-region "any text" nil file-notify--test-tmpfile)
171 (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
172 (delete-file file-notify--test-tmpfile)
173 (delete-file file-notify--test-tmpfile1)
174
175 (write-region "any text" nil file-notify--test-tmpfile)
176 (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
177 (delete-file file-notify--test-tmpfile1))
178
179 ;; Wait for events, and exit.
180 (sit-for 5 'nodisplay)
181 (file-notify-rm-watch desc)
182 (ignore-errors (delete-file file-notify--test-tmpfile))
183 (ignore-errors (delete-file file-notify--test-tmpfile1))))
184
185 (dolist (result file-notify--test-results)
186 ;(message "%s" (ert-test-result-messages result))
187 (when (ert-test-failed-p result)
188 (ert-fail (cadr (ert-test-result-with-condition-condition result))))))
189
190 (file-notify--deftest-remote file-notify-test02-events
191 "Check file creation/removal notifications for remote files.")
192 ) ;; file-notify-support
193
194;; autorevert runs only in interactive mode.
195(defvar auto-revert-remote-files)
196(setq auto-revert-remote-files t)
197(require 'autorevert)
198(when (and file-notify-support (null noninteractive))
199
200 (ert-deftest file-notify-test03-autorevert ()
201 "Check autorevert via file notification.
202This test is skipped in batch mode."
203 ;; `auto-revert-buffers' runs every 5". And we must wait, until
204 ;; the file has been reverted.
205 (let ((timeout 10)
206 buf)
207 (unwind-protect
208 (progn
209 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
210
211 (write-region "any text" nil file-notify--test-tmpfile)
212 (setq buf (find-file-noselect file-notify--test-tmpfile))
213 (with-current-buffer buf
214 (should (string-equal (buffer-string) "any text"))
215 (auto-revert-mode 1)
216
217 ;; `auto-revert-buffers' runs every 5".
218 (with-timeout (timeout (ignore))
219 (while (null auto-revert-notify-watch-descriptor)
220 (sit-for 0.1 'nodisplay)))
221
222 ;; Check, that file notification has been used.
223 (should auto-revert-mode)
224 (should auto-revert-use-notify)
225 (should auto-revert-notify-watch-descriptor)
226
227 ;; Modify file. We wait for a second, in order to
228 ;; have another timestamp.
229 (sit-for 1)
230 (shell-command
231 (format "echo -n 'another text' >%s"
232 (or (file-remote-p file-notify--test-tmpfile 'localname)
233 file-notify--test-tmpfile)))
234
235 ;; Check, that the buffer has been reverted.
236 (with-current-buffer (get-buffer-create "*Messages*")
237 (with-timeout (timeout (ignore))
238 (while
239 (null (string-match
240 (format "Reverting buffer `%s'." (buffer-name buf))
241 (buffer-string)))
242 (sit-for 0.1 'nodisplay))))
243 (should (string-equal (buffer-string) "another text"))))
244
245 ;; Exit.
246 (ignore-errors (kill-buffer buf))
247 (ignore-errors (delete-file file-notify--test-tmpfile)))))
248
249 (file-notify--deftest-remote file-notify-test03-autorevert
250 "Check autorevert via file notification for remote files.
251This test is skipped in batch mode.")
252 ) ;; (and file-notify-support (null noninteractive))
253
254(defun file-notify-test-all (&optional interactive)
255 "Run all tests for \\[file-notify]."
256 (interactive "p")
257 (when file-notify-support
258 (if interactive
259 (ert-run-tests-interactively "^file-notify-")
260 (ert-run-tests-batch "^file-notify-"))))
261
262(provide 'file-notify-tests)
263;;; file-notify-tests.el ends here
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..fdae235ad38 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
@@ -1744,6 +1745,53 @@ class Baz(object):
1744 (cons "c (def)" (copy-marker 626))))) 1745 (cons "c (def)" (copy-marker 626)))))
1745 (python-imenu-create-index))))) 1746 (python-imenu-create-index)))))
1746 1747
1748(ert-deftest python-imenu-create-index-2 ()
1749 (python-tests-with-temp-buffer
1750 "
1751class Foo(object):
1752 def foo(self):
1753 def foo1():
1754 pass
1755
1756 def foobar(self):
1757 pass
1758"
1759 (goto-char (point-max))
1760 (should (equal
1761 (list
1762 (list
1763 "Foo (class)"
1764 (cons "*class definition*" (copy-marker 2))
1765 (list
1766 "foo (def)"
1767 (cons "*function definition*" (copy-marker 21))
1768 (cons "foo1 (def)" (copy-marker 40)))
1769 (cons "foobar (def)" (copy-marker 78))))
1770 (python-imenu-create-index)))))
1771
1772(ert-deftest python-imenu-create-index-3 ()
1773 (python-tests-with-temp-buffer
1774 "
1775class Foo(object):
1776 def foo(self):
1777 def foo1():
1778 pass
1779 def foo2():
1780 pass
1781"
1782 (goto-char (point-max))
1783 (should (equal
1784 (list
1785 (list
1786 "Foo (class)"
1787 (cons "*class definition*" (copy-marker 2))
1788 (list
1789 "foo (def)"
1790 (cons "*function definition*" (copy-marker 21))
1791 (cons "foo1 (def)" (copy-marker 40))
1792 (cons "foo2 (def)" (copy-marker 77)))))
1793 (python-imenu-create-index)))))
1794
1747(ert-deftest python-imenu-create-flat-index-1 () 1795(ert-deftest python-imenu-create-flat-index-1 ()
1748 (python-tests-with-temp-buffer 1796 (python-tests-with-temp-buffer
1749 " 1797 "
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
index a18899df02f..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,11 +543,22 @@ 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)))))
548 549
550(ert-deftest ruby-move-to-block-moves-from-else-to-if ()
551 (ruby-with-temp-buffer (ruby-test-string
552 "if true
553 | nested_block do
554 | end
555 |else
556 |end")
557 (goto-char (point-min))
558 (forward-line 3)
559 (ruby-beginning-of-block)
560 (should (= 1 (line-number-at-pos)))))
561
549(ert-deftest ruby-beginning-of-defun-does-not-fold-case () 562(ert-deftest ruby-beginning-of-defun-does-not-fold-case ()
550 (ruby-with-temp-buffer 563 (ruby-with-temp-buffer
551 (ruby-test-string 564 (ruby-test-string
@@ -554,7 +567,8 @@ VALUES-PLIST is a list with alternating index and value elements."
554 | Class.to_s 567 | Class.to_s
555 | end 568 | end
556 |end") 569 |end")
557 (goto-line 4) 570 (goto-char (point-min))
571 (forward-line 3)
558 (let ((case-fold-search t)) 572 (let ((case-fold-search t))
559 (beginning-of-defun)) 573 (beginning-of-defun))
560 (should (= 2 (line-number-at-pos))))) 574 (should (= 2 (line-number-at-pos)))))
@@ -567,7 +581,8 @@ VALUES-PLIST is a list with alternating index and value elements."
567 | 'ho hum' 581 | 'ho hum'
568 | end 582 | end
569 |end") 583 |end")
570 (goto-line 2) 584 (goto-char (point-min))
585 (forward-line 1)
571 (end-of-defun) 586 (end-of-defun)
572 (should (= 5 (line-number-at-pos))))) 587 (should (= 5 (line-number-at-pos)))))
573 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