aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp
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/lisp
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/lisp')
-rw-r--r--test/lisp/char-fold-tests.el124
-rw-r--r--test/lisp/emacs-lisp/package-tests.el11
2 files changed, 133 insertions, 2 deletions
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)