aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPaul Eggert2016-05-26 12:55:06 -0700
committerPaul Eggert2016-05-26 12:55:06 -0700
commit0bf5739b77c75f13d46fc49d5e3c098fe49a5070 (patch)
treed342da7bc9065197736a8184e55c9925a40f04f0 /test
parent764f04871d67a5aad8943136d5142ed59bfa9a51 (diff)
parentc3489d050405ccb026cd44a280ead3a5f6b456d9 (diff)
downloademacs-0bf5739b77c75f13d46fc49d5e3c098fe49a5070.tar.gz
emacs-0bf5739b77c75f13d46fc49d5e3c098fe49a5070.zip
Merge from origin/emacs-25
c3489d0 * lisp/w32-fns.el (set-message-beep, w32-get-locale-info) (w3... a4d882c Correct old cell name unbinding when renaming cell. 6c12c53 Merge branch 'emacs-25' of git.sv.gnu.org:/srv/git/emacs into... 0be6725 Document problem: slow screen refresh on missing font. 853b9b9 * admin/admin.el (add-release-logs): Basic check of existing ... 5fa80cf * build-aux/gitlog-to-emacslog: Handle empty generated Change... 3c79e51 * admin/admin.el (add-release-logs): Generate ChangeLog if ne... 42275df * doc/misc/texinfo.tex: Revert previous change (Bug#23611). 3f4a9d9 * admin/authors.el (authors): First update the ChangeLog. 897fb6f ; 'Changes from the pre-25.1 API' copyedits 825ca25 Rename vc-stay-local back to vc-cvs-stay-local 4efb3e8 * doc/emacs/files.texi (Comparing Files): * doc/emacs/trouble... b995d1e * doc/misc/eww.texi (Advanced): Fix xref. 2e589c0 Fix cross-references between manuals f3d2ded * doc/misc/vhdl-mode.texi (Sample Init File): Rename node to ... 906c810 ; * admin/release-process: Move etc/HISTORY from here... ; * ... bea1b65 * admin/admin.el (add-release-logs): Also update etc/HISTORY. 503e752 ; * CONTRIBUTE: Fix a typo. fbfd478 Avoid aborting due to errors in arguments of 'set-face-attrib... bdfbe6d ; * admin/release-process: Copyedits. 44a6aed ; * test/automated/data-tests.el: Standardize license notice. c33ed39 ; * test/automated/viper-tests.el: Standardize license notice. df4a14b Add automated test for viper-tests.el c0139e3 Fix viper undo breakage from undo-boundary changes 920d76c Fix reference to obsolete fn ps-eval-switch 18a9bc1 Do not trash symlinks to init file 2671179 Don't print the "decomposition" line for control chars in wha... 869092c Bring back xterm pasting with middle mouse 5ab0830 Provide workaround for xftfont rendering problem c9f7ec7 * lisp/desktop.el: Disable restore frameset if in non-graphic... 30989a0 Mention GTK+ problems in etc/PROBLEMS 421e3c4 * lisp/emacs-lisp/package.el (package-refresh-contents): dadfc30 Revert "epg: Add a way to detect gpg1 executable for tests" e41a5cb Avoid errors with Czech and Slovak input methods d4ae6d7 epg: Add a way to detect gpg1 executable for tests ebc3a94 * lisp/emacs-lisp/package.el: Fix free variable warnings. 6e71295 * lisp/emacs-lisp/package.el (package--with-response-buffer): c45d9f6 Improve documentation of 'server-name' 3b5e38c Modernize ASLR advice in etc/PROBLEMS 1fe1e0a * lisp/char-fold.el: Rename from character-fold.el.
Diffstat (limited to 'test')
-rw-r--r--test/automated/viper-tests.el160
-rw-r--r--test/lisp/char-fold-tests.el124
-rw-r--r--test/lisp/emacs-lisp/package-tests.el11
-rw-r--r--test/src/data-tests.el22
4 files changed, 304 insertions, 13 deletions
diff --git a/test/automated/viper-tests.el b/test/automated/viper-tests.el
new file mode 100644
index 00000000000..8b30f050935
--- /dev/null
+++ b/test/automated/viper-tests.el
@@ -0,0 +1,160 @@
1;;; viper-tests.el --- tests for viper.
2
3;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;;; Code:
23
24
25(require 'viper)
26
27(defun viper-test-undo-kmacro (kmacro)
28 "In a clean viper buffer, run KMACRO and return `buffer-string'.
29
30This function makes as many attempts as possible to clean up
31after itself, although it will leave a buffer called
32*viper-test-buffer* if it fails (this is deliberate!)."
33 (let (
34 ;; Viper just turns itself off during batch use.
35 (noninteractive nil)
36 ;; Switch off start up message or it will chew the key presses
37 (viper-inhibit-startup-message 't)
38 ;; Select an expert-level for the same reason.
39 (viper-expert-level 5)
40 ;; viper loads this even with -q so make sure it's empty!
41 (viper-custom-file-name (make-temp-file "viper-tests"))
42 (before-buffer (current-buffer)))
43 (unwind-protect
44 (progn
45 ;; viper-mode is essentially global, so set it here
46 (viper-mode)
47 ;; We must switch to buffer because we are using a keyboard macro
48 ;; which appears to not go to the current-buffer but what ever is
49 ;; currently taking keyboard events. We use a named buffer because
50 ;; then we can see what it in it if it all goes wrong.
51 (switch-to-buffer
52 (get-buffer-create
53 "*viper-test-buffer*"))
54 (erase-buffer)
55 ;; The new buffer fails to enter vi state so set it.
56 (viper-change-state-to-vi)
57 ;; Run the macro
58 (execute-kbd-macro kmacro)
59 (let ((rtn
60 (buffer-substring-no-properties
61 (point-min)
62 (point-max))))
63 ;; Kill the buffer iff the macro succeeds
64 (kill-buffer)
65 rtn))
66 ;; switch everthing off and restore the buffer
67 (toggle-viper-mode)
68 (switch-to-buffer before-buffer))))
69
70(ert-deftest viper-test-go ()
71 "Test that this file is running."
72 (should t))
73
74(ert-deftest viper-test-fix ()
75 "Test that the viper kmacro fixture is working."
76 (should
77 (viper-test-undo-kmacro [])))
78
79(ert-deftest viper-test-undo-1 ()
80 "Test for VI like undo behaviour.
81
82Insert 1, then 2 on consecutive lines, followed by undo. This
83should leave just 1 in the buffer.
84
85Test for Bug #22295"
86 (should
87 (equal
88 "1\n"
89 (viper-test-undo-kmacro
90 [
91 ?a
92 ?1
93 escape
94 ?o
95 ?2
96 escape
97 ?u
98 ]
99 ))))
100
101(ert-deftest viper-test-undo-2 ()
102 "Test for VI like undo behaviour.
103
104Insert \"1 2 3 4 5\" then delete the 2, then the 4, and undo.
105Should restore the 4, but leave the 2 deleted.
106
107Test for Bug #22295"
108 (should
109 (equal
110 "1 3 4 5\n"
111 (viper-test-undo-kmacro
112 [
113 ?i
114 ?1 ? ?2 ? ?3 ? ?4 ? ?5
115 escape
116 ?F ?2 ?d ?w
117 ?w ?d ?w
118 ?u
119 ]))))
120
121(ert-deftest viper-test-undo-3 ()
122 "Test for VI like undo behaviour.
123
124Insert \"1 2 3 4 5 6\", delete the 2, then the 3 4 and 5.
125Should restore the 3 4 and 5 but not the 2.
126
127Test for Bug #22295"
128 (should
129 (equal
130 "1 3 4 5 6\n"
131 (viper-test-undo-kmacro
132 [
133 ;; Insert this lot.
134 ?i ?1 ? ?2 ? ?3 ? ?4 ? ?5 ? ?6
135 escape
136 ;; Start of line.
137 ?0
138 ;; Move to 2, delete
139 ?w ?d ?w
140 ;; Delete 3 4 5
141 ?. ?. ?.
142 ;; Undo del 5, then
143 ?u ?. ?.
144 ]))))
145
146
147(ert-deftest viper-test-undo-4()
148 (should
149 (equal
150 ""
151 (viper-test-undo-kmacro
152 [
153 ?i ?1 escape
154 ?o ?2 escape
155 ?o ?3 escape
156 ?u ?. ?.
157 ])
158 )))
159
160;;; viper-tests.el ends here
diff --git a/test/lisp/char-fold-tests.el b/test/lisp/char-fold-tests.el
new file mode 100644
index 00000000000..485254aa6cf
--- /dev/null
+++ b/test/lisp/char-fold-tests.el
@@ -0,0 +1,124 @@
1;;; char-fold-tests.el --- Tests for char-fold.el -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
4
5;; Author: Artur Malabarba <bruce.connor.am@gmail.com>
6
7;; This program is free software; you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; This program is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Code:
21
22(require 'ert)
23(require 'char-fold)
24
25(defun char-fold--random-word (n)
26 (mapconcat (lambda (_) (string (+ 9 (random 117))))
27 (make-list n nil) ""))
28
29(defun char-fold--test-search-with-contents (contents string)
30 (with-temp-buffer
31 (insert contents)
32 (goto-char (point-min))
33 (should (search-forward-regexp (char-fold-to-regexp string) nil 'noerror))
34 (goto-char (point-min))
35 (should (char-fold-search-forward string nil 'noerror))
36 (should (char-fold-search-backward string nil 'noerror))))
37
38
39(ert-deftest char-fold--test-consistency ()
40 (dotimes (n 30)
41 (let ((w (char-fold--random-word n)))
42 ;; A folded string should always match the original string.
43 (char-fold--test-search-with-contents w w))))
44
45(ert-deftest char-fold--test-lax-whitespace ()
46 (dotimes (n 40)
47 (let ((w1 (char-fold--random-word n))
48 (w2 (char-fold--random-word n))
49 (search-spaces-regexp "\\s-+"))
50 (char-fold--test-search-with-contents
51 (concat w1 "\s\n\s\t\f\t\n\r\t" w2)
52 (concat w1 " " w2))
53 (char-fold--test-search-with-contents
54 (concat w1 "\s\n\s\t\f\t\n\r\t" w2)
55 (concat w1 (make-string 10 ?\s) w2)))))
56
57(defun char-fold--test-match-exactly (string &rest strings-to-match)
58 (let ((re (concat "\\`" (char-fold-to-regexp string) "\\'")))
59 (dolist (it strings-to-match)
60 (should (string-match re it)))
61 ;; Case folding
62 (let ((case-fold-search t))
63 (dolist (it strings-to-match)
64 (should (string-match (upcase re) (downcase it)))
65 (should (string-match (downcase re) (upcase it)))))))
66
67(ert-deftest char-fold--test-some-defaults ()
68 (dolist (it '(("ffl" . "ffl") ("ffi" . "ffi")
69 ("fi" . "fi") ("ff" . "ff")
70 ("ä" . "ä")))
71 (char-fold--test-search-with-contents (cdr it) (car it))
72 (let ((multi (char-table-extra-slot char-fold-table 0))
73 (char-fold-table (make-char-table 'char-fold-table)))
74 (set-char-table-extra-slot char-fold-table 0 multi)
75 (char-fold--test-match-exactly (car it) (cdr it)))))
76
77(ert-deftest char-fold--test-fold-to-regexp ()
78 (let ((char-fold-table (make-char-table 'char-fold-table))
79 (multi (make-char-table 'char-fold-table)))
80 (set-char-table-extra-slot char-fold-table 0 multi)
81 (aset char-fold-table ?a "xx")
82 (aset char-fold-table ?1 "44")
83 (aset char-fold-table ?\s "-!-")
84 (char-fold--test-match-exactly "a1a1" "xx44xx44")
85 (char-fold--test-match-exactly "a1 a 1" "xx44-!--!-xx-!-44")
86 (aset multi ?a '(("1" . "99")
87 ("2" . "88")
88 ("12" . "77")))
89 (char-fold--test-match-exactly "a" "xx")
90 (char-fold--test-match-exactly "a1" "xx44" "99")
91 (char-fold--test-match-exactly "a12" "77" "xx442" "992")
92 (char-fold--test-match-exactly "a2" "88")
93 (aset multi ?1 '(("2" . "yy")))
94 (char-fold--test-match-exactly "a1" "xx44" "99")
95 (char-fold--test-match-exactly "a12" "77" "xx442" "992")
96 ;; Support for this case is disabled. See function definition or:
97 ;; https://lists.gnu.org/archive/html/emacs-devel/2015-11/msg02562.html
98 ;; (char-fold--test-match-exactly "a12" "xxyy")
99 ))
100
101(ert-deftest char-fold--speed-test ()
102 (dolist (string (append '("tty-set-up-initial-frame-face"
103 "tty-set-up-initial-frame-face-frame-faceframe-faceframe-faceframe-face")
104 (mapcar #'char-fold--random-word '(10 50 100
105 50 100))))
106 (message "Testing %s" string)
107 ;; Make sure we didn't just fallback on the trivial search.
108 (should-not (string= (regexp-quote string)
109 (char-fold-to-regexp string)))
110 (with-temp-buffer
111 (save-excursion (insert string))
112 (let ((time (time-to-seconds (current-time))))
113 ;; Our initial implementation of case-folding in char-folding
114 ;; created a lot of redundant paths in the regexp. Because of
115 ;; that, if a really long string "almost" matches, the regexp
116 ;; engine took a long time to realize that it doesn't match.
117 (should-not (char-fold-search-forward (concat string "c") nil 'noerror))
118 ;; Ensure it took less than a second.
119 (should (< (- (time-to-seconds (current-time))
120 time)
121 1))))))
122
123(provide 'char-fold-tests)
124;;; char-fold-tests.el ends here
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el
index 70e129cc4f5..c7a5cc7af22 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -475,8 +475,15 @@ Must called from within a `tar-mode' buffer."
475 (package-initialize) 475 (package-initialize)
476 (package-import-keyring keyring) 476 (package-import-keyring keyring)
477 (package-refresh-contents) 477 (package-refresh-contents)
478 (should (package-install 'signed-good)) 478 (let ((package-check-signature 'allow-unsigned))
479 (should-error (package-install 'signed-bad)) 479 (should (package-install 'signed-good))
480 (should-error (package-install 'signed-bad)))
481 (let ((package-check-signature t))
482 (should (package-install 'signed-good))
483 (should-error (package-install 'signed-bad)))
484 (let ((package-check-signature nil))
485 (should (package-install 'signed-good))
486 (should (package-install 'signed-bad)))
480 ;; Check if the installed package status is updated. 487 ;; Check if the installed package status is updated.
481 (let ((buf (package-list-packages))) 488 (let ((buf (package-list-packages)))
482 (package-menu-refresh) 489 (package-menu-refresh)
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index 9ca5ac53333..0a292336f35 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -4,18 +4,18 @@
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
7;; This program is free software: you can redistribute it and/or 7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; modify it under the terms of the GNU General Public License as 8;; it under the terms of the GNU General Public License as published by
9;; published by the Free Software Foundation, either version 3 of the 9;; the Free Software Foundation, either version 3 of the License, or
10;; License, or (at your option) any later version. 10;; (at your option) any later version.
11;; 11
12;; This program is distributed in the hope that it will be useful, but 12;; GNU Emacs is distributed in the hope that it will be useful,
13;; WITHOUT ANY WARRANTY; without even the implied warranty of 13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; General Public License for more details. 15;; GNU General Public License for more details.
16;; 16
17;; You should have received a copy of the GNU General Public License 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/'. 18;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19 19
20;;; Commentary: 20;;; Commentary:
21 21