aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJoakim Verona2015-01-21 00:26:56 +0100
committerJoakim Verona2015-01-21 00:26:56 +0100
commit8628a48fec7fcd8bdbbf6ce5808fc574631d1541 (patch)
tree3dfc3b71850123e7514ddb149a0ba768618cfddf /test
parentffd9ee1d6412a6e61383930562e6167a458f0d5f (diff)
parent0dd19ac82662c5710e73852f438fd55e1d9225b7 (diff)
downloademacs-8628a48fec7fcd8bdbbf6ce5808fc574631d1541.tar.gz
emacs-8628a48fec7fcd8bdbbf6ce5808fc574631d1541.zip
Merge branch 'master' into xwidget
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog26
-rw-r--r--test/automated/descr-text-test.el94
-rw-r--r--test/automated/package-test.el17
-rw-r--r--test/automated/tildify-tests.el71
4 files changed, 191 insertions, 17 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 4b9e7a92621..dcce0bf3c39 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,29 @@
12015-01-20 Jorgen Schaefer <contact@jorgenschaefer.de>
2
3 * automated/package-test.el (package-test-install-prioritized):
4 Removed test due to unreproducable failures.
5
62015-01-20 Michal Nazarewicz <mina86@mina86.com>
7
8 * automated/descr-text-test.el: New file with tests for
9 `describe-char-eldoc--truncate', `describe-char-eldoc--format',
10 and `describe-char-eldoc'.
11
122015-01-20 Michal Nazarewicz <mina86@mina86.com>
13
14 * automated/tildify-tests.el (tildify-space-undo-test--test):
15 A new helper function for testing `tildify-double-space-undos'
16 behaviour in the `tildify-space' function.
17 (tildify-space-undo-test-html, tildify-space-undo-test-html-nbsp)
18 (tildify-space-undo-test-xml, tildify-space-undo-test-tex): New
19 tests for `tildify-doule-space-undos' behaviour.
20
21 * automated/tildify-tests.el (tildify-space-test--test):
22 A new helper function for testing `tildify-space' function.
23 (tildify-space-test-html, tildify-space-test-html-nbsp)
24 (tildify-space-test-xml, tildify-space-test-tex): New tests for
25 `tildify-space' function.
26
12015-01-18 Stefan Monnier <monnier@iro.umontreal.ca> 272015-01-18 Stefan Monnier <monnier@iro.umontreal.ca>
2 28
3 * automated/Makefile.in (EMACS_EXTRAOPT): New var. 29 * automated/Makefile.in (EMACS_EXTRAOPT): New var.
diff --git a/test/automated/descr-text-test.el b/test/automated/descr-text-test.el
new file mode 100644
index 00000000000..81ae727f076
--- /dev/null
+++ b/test/automated/descr-text-test.el
@@ -0,0 +1,94 @@
1;;; descr-text-test.el --- ERT tests for descr-text.el -*- lexical-binding: t -*-
2
3;; Copyright (C) 2014 Free Software Foundation, Inc.
4
5;; Author: Michal Nazarewicz <mina86@mina86.com>
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;; This package defines regression tests for the descr-text package.
25
26;;; Code:
27
28(require 'ert)
29(require 'descr-text)
30
31
32(ert-deftest descr-text-test-truncate ()
33 "Tests describe-char-eldoc--truncate function."
34 (should (equal ""
35 (describe-char-eldoc--truncate " \t \n" 100)))
36 (should (equal "foo"
37 (describe-char-eldoc--truncate "foo" 1)))
38 (should (equal "foo..."
39 (describe-char-eldoc--truncate "foo wilma fred" 0)))
40 (should (equal "foo..."
41 (describe-char-eldoc--truncate
42 "foo wilma fred" (length "foo wilma"))))
43 (should (equal "foo wilma..."
44 (describe-char-eldoc--truncate
45 "foo wilma fred" (+ 3 (length "foo wilma")))))
46 (should (equal "foo wilma..."
47 (describe-char-eldoc--truncate
48 "foo wilma fred" (1- (length "foo wilma fred")))))
49 (should (equal "foo wilma fred"
50 (describe-char-eldoc--truncate
51 "foo wilma fred" (length "foo wilma fred"))))
52 (should (equal "foo wilma fred"
53 (describe-char-eldoc--truncate
54 " foo\t wilma \nfred\t " (length "foo wilma fred")))))
55
56(ert-deftest descr-text-test-format-desc ()
57 "Tests describe-char-eldoc--format function."
58 (should (equal "U+2026: Horizontal ellipsis (Po: Punctuation, Other)"
59 (describe-char-eldoc--format ?…)))
60 (should (equal "U+2026: Horizontal ellipsis (Punctuation, Other)"
61 (describe-char-eldoc--format ?… 51)))
62 (should (equal "U+2026: Horizontal ellipsis (Po)"
63 (describe-char-eldoc--format ?… 40)))
64 (should (equal "Horizontal ellipsis (Po)"
65 (describe-char-eldoc--format ?… 30)))
66 (should (equal "Horizontal ellipsis"
67 (describe-char-eldoc--format ?… 20)))
68 (should (equal "Horizontal..."
69 (describe-char-eldoc--format ?… 10))))
70
71(ert-deftest descr-text-test-desc ()
72 "Tests describe-char-eldoc function."
73 (with-temp-buffer
74 (insert "a…")
75 (goto-char (point-min))
76 (should (eq ?a (following-char))) ; make sure we are where we think we are
77 ;; Function should return nil for an ASCII character.
78 (should (not (describe-char-eldoc)))
79
80 (goto-char (1+ (point)))
81 (should (eq ?… (following-char)))
82 (let ((eldoc-echo-area-use-multiline-p t))
83 ;; Function should return description of an Unicode character.
84 (should (equal "U+2026: Horizontal ellipsis (Po: Punctuation, Other)"
85 (describe-char-eldoc))))
86
87 (goto-char (point-max))
88 ;; At the end of the buffer, function should return nil and not blow up.
89 (should (not (describe-char-eldoc)))))
90
91
92(provide 'descr-text-test)
93
94;;; descr-text-test.el ends here
diff --git a/test/automated/package-test.el b/test/automated/package-test.el
index c33a1ba0232..27a71c528c6 100644
--- a/test/automated/package-test.el
+++ b/test/automated/package-test.el
@@ -230,23 +230,6 @@ Must called from within a `tar-mode' buffer."
230 (package-refresh-contents) 230 (package-refresh-contents)
231 (package-install 'simple-single))) 231 (package-install 'simple-single)))
232 232
233(ert-deftest package-test-install-prioritized ()
234 "Install a lower version from a higher-prioritized archive."
235 (with-package-test ()
236 (let* ((newer-version (expand-file-name "data/package/newer-versions"
237 package-test-file-dir))
238 (package-archives `(("older" . ,package-test-data-dir)
239 ("newer" . ,newer-version)))
240 (package-archive-priorities '(("newer" . 100))))
241
242 (package-initialize)
243 (package-refresh-contents)
244 (package-install 'simple-single)
245
246 (let ((installed (cadr (assq 'simple-single package-alist))))
247 (should (version-list-= '(1 3)
248 (package-desc-version installed)))))))
249
250(ert-deftest package-test-install-multifile () 233(ert-deftest package-test-install-multifile ()
251 "Check properties of the installed multi-file package." 234 "Check properties of the installed multi-file package."
252 (with-package-test (:basedir "data/package" :install '(multi-file)) 235 (with-package-test (:basedir "data/package" :install '(multi-file))
diff --git a/test/automated/tildify-tests.el b/test/automated/tildify-tests.el
index b1f3de94fc5..b53f58c279e 100644
--- a/test/automated/tildify-tests.el
+++ b/test/automated/tildify-tests.el
@@ -185,6 +185,77 @@ The function must terminate as soon as callback returns nil."
185 (+ (point-min) 10) (+ (point-min) 20)))) ; start at "3" end past "5" 185 (+ (point-min) 10) (+ (point-min) 20)))) ; start at "3" end past "5"
186 186
187 187
188(defun tildify-space-test--test (modes nbsp env-open &optional set-space-string)
189 (with-temp-buffer
190 (dolist (mode modes)
191 (funcall mode)
192 (when set-space-string
193 (setq-local tildify-space-string nbsp))
194 (let ((header (concat "Testing `tildify-space' in "
195 (symbol-name mode) "\n")))
196 ;; Replace space with hard space.
197 (erase-buffer)
198 (insert header "Lorem v ")
199 (should (tildify-space))
200 (should (string-equal (concat header "Lorem v" nbsp) (buffer-string)))
201 ;; Inside and ignore environment, replacing does not happen.
202 (erase-buffer)
203 (insert header env-open "Lorem v ")
204 (should (not (tildify-space)))
205 (should (string-equal (concat header env-open "Lorem v ")
206 (buffer-string)))))))
207
208(ert-deftest tildify-space-test-html ()
209 "Tests auto-tildification in an HTML document"
210 (tildify-space-test--test '(html-mode sgml-mode) " " "<pre>"))
211
212(ert-deftest tildify-space-test-html-nbsp ()
213 "Tests auto-tildification in an HTML document"
214 (tildify-space-test--test '(html-mode sgml-mode) "&nbsp;" "<pre>" t))
215
216(ert-deftest tildify-space-test-xml ()
217 "Tests auto-tildification in an XML document"
218 (tildify-space-test--test '(nxml-mode) " " "<! -- "))
219
220(ert-deftest tildify-space-test-tex ()
221 "Tests tildification in a TeX document"
222 (tildify-space-test--test '(tex-mode latex-mode plain-tex-mode)
223 "~" "\\verb# "))
224
225
226(defun tildify-space-undo-test--test
227 (modes nbsp env-open &optional set-space-string)
228 (with-temp-buffer
229 (dolist (mode modes)
230 (funcall mode)
231 (when set-space-string
232 (setq-local tildify-space-string nbsp))
233 (let ((header (concat "Testing double-space-undos in "
234 (symbol-name mode) "\n")))
235 (erase-buffer)
236 (insert header "Lorem v" nbsp " ")
237 (should (not (tildify-space)))
238 (should (string-equal (concat header "Lorem v ") (buffer-string)))))))
239
240(ert-deftest tildify-space-undo-test-html ()
241 "Tests auto-tildification in an HTML document"
242 (tildify-space-undo-test--test '(html-mode sgml-mode) " " "<pre>"))
243
244(ert-deftest tildify-space-undo-test-html-nbsp ()
245 "Tests auto-tildification in an HTML document"
246 (tildify-space-undo-test--test '(html-mode sgml-mode) "&nbsp;" "<pre>" t))
247
248(ert-deftest tildify-space-undo-test-xml ()
249 "Tests auto-tildification in an XML document"
250 (tildify-space-undo-test--test '(nxml-mode) " " "<! -- "))
251
252(ert-deftest tildify-space-undo-test-tex ()
253 "Tests tildification in a TeX document"
254 (tildify-space-undo-test--test '(tex-mode latex-mode plain-tex-mode)
255 "~" "\\verb# "))
256
257
258
188(provide 'tildify-tests) 259(provide 'tildify-tests)
189 260
190;;; tildify-tests.el ends here 261;;; tildify-tests.el ends here