aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVincent Belaïche2016-07-28 18:12:50 +0200
committerVincent Belaïche2016-07-28 18:12:50 +0200
commit90ab699c4f281d0c9a9b71f3eb4c8493d00fcf4f (patch)
treedf3235d89ee8e4d32571b8a8521f75f7576913c2 /test
parent41b28dea8587c13b0bc59c1ec70b65afab3aeeca (diff)
parentec359399a47f852b4d022a30245449438e349193 (diff)
downloademacs-90ab699c4f281d0c9a9b71f3eb4c8493d00fcf4f.tar.gz
emacs-90ab699c4f281d0c9a9b71f3eb4c8493d00fcf4f.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog.12
-rw-r--r--test/Makefile.in13
-rw-r--r--test/lisp/calendar/icalendar-tests.el3
-rw-r--r--test/lisp/dired-tests.el21
-rw-r--r--test/lisp/emacs-lisp/ert-x-tests.el43
-rw-r--r--test/lisp/emacs-lisp/map-tests.el8
-rw-r--r--test/lisp/emacs-lisp/package-tests.el2
-rw-r--r--test/lisp/emacs-lisp/seq-tests.el19
-rw-r--r--test/lisp/emulation/viper-tests.el2
-rw-r--r--test/lisp/erc/erc-track-tests.el10
-rw-r--r--test/lisp/filenotify-tests.el131
-rw-r--r--test/lisp/gnus/message-tests.el2
-rw-r--r--test/lisp/help-fns-tests.el61
-rw-r--r--test/lisp/international/ucs-normalize-tests.el277
-rw-r--r--test/lisp/net/tramp-tests.el75
-rw-r--r--test/lisp/progmodes/cc-mode.el65
-rw-r--r--test/lisp/progmodes/ruby-mode-tests.el11
-rw-r--r--test/lisp/simple-tests.el50
-rw-r--r--test/lisp/textmodes/css-mode-tests.el3
-rw-r--r--test/lisp/vc/vc-bzr-tests.el3
-rw-r--r--test/manual/cedet/tests/test.el2
-rw-r--r--test/src/callproc-tests.el39
-rw-r--r--test/src/chartab-tests.el51
-rw-r--r--test/src/editfns-tests.el136
-rw-r--r--test/src/fns-tests.el10
-rw-r--r--test/src/regex-tests.el92
26 files changed, 957 insertions, 174 deletions
diff --git a/test/ChangeLog.1 b/test/ChangeLog.1
index 3520f13df60..367ca74b7b9 100644
--- a/test/ChangeLog.1
+++ b/test/ChangeLog.1
@@ -79,7 +79,7 @@
79 * indent/js-indent-first-initialiser-dynamic.js: 79 * indent/js-indent-first-initialiser-dynamic.js:
80 New tests for `js-indent-first-initialiser'. 80 New tests for `js-indent-first-initialiser'.
81 81
822015-03-10 Przemyslaw Wojnowski <esperanto@cumego.com> 822015-03-10 Przemysław Wojnowski <esperanto@cumego.com>
83 83
84 * automated/cl-lib-tests.el: Add tests for plusp, second, ... 84 * automated/cl-lib-tests.el: Add tests for plusp, second, ...
85 (cl-lib-test-plusp, cl-lib-test-minusp) 85 (cl-lib-test-plusp, cl-lib-test-minusp)
diff --git a/test/Makefile.in b/test/Makefile.in
index 7ebc0ded4e7..33e625fc996 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -106,14 +106,17 @@ else
106SELECTOR_ACTUAL=$(SELECTOR_EXPENSIVE) 106SELECTOR_ACTUAL=$(SELECTOR_EXPENSIVE)
107endif 107endif
108 108
109## Byte-compile all test files to test for errors (unless explicitly
110## told not to), but then evaluate the un-byte-compiled files, because
111## they give cleaner stacktraces.
109 112
113## Beware: it approximates 'no-byte-compile', so watch out for false-positives!
110%.log: %.el 114%.log: %.el
111 @if grep '^;.*no-byte-compile: t' $< > /dev/null; then \ 115 elc=$<c; \
112 loadfile=$<; \ 116 if ! grep '^;.*no-byte-compile: t' $< > /dev/null; then \
113 else \ 117 ${MAKE} $$elc; \
114 loadfile=$<c; \
115 ${MAKE} $$loadfile; \
116 fi; \ 118 fi; \
119 loadfile=$<; \
117 echo Testing $$loadfile; \ 120 echo Testing $$loadfile; \
118 stat=OK ; \ 121 stat=OK ; \
119 ${MKDIR_P} $(dir $@) ; \ 122 ${MKDIR_P} $(dir $@) ; \
diff --git a/test/lisp/calendar/icalendar-tests.el b/test/lisp/calendar/icalendar-tests.el
index 20d88349bbc..6db4222697e 100644
--- a/test/lisp/calendar/icalendar-tests.el
+++ b/test/lisp/calendar/icalendar-tests.el
@@ -32,7 +32,6 @@
32;;; Code: 32;;; Code:
33 33
34(require 'ert) 34(require 'ert)
35(require 'ert-x)
36(require 'icalendar) 35(require 'icalendar)
37 36
38;; ====================================================================== 37;; ======================================================================
@@ -64,7 +63,7 @@
64 (hash (format "%d" (abs (sxhash entry-full)))) 63 (hash (format "%d" (abs (sxhash entry-full))))
65 (contents "DTSTART:19640630T070100\nblahblah") 64 (contents "DTSTART:19640630T070100\nblahblah")
66 (username (or user-login-name "UNKNOWN_USER"))) 65 (username (or user-login-name "UNKNOWN_USER")))
67 (ert-with-function-mocked current-time (lambda () '(1 2 3)) 66 (cl-letf (((symbol-function 'current-time) (lambda () '(1 2 3))))
68 (should (= 77 icalendar--uid-count)) 67 (should (= 77 icalendar--uid-count))
69 (should (string= (concat "xxx-123-77-" hash "-" username "-19640630") 68 (should (string= (concat "xxx-123-77-" hash "-" username "-19640630")
70 (icalendar--create-uid entry-full contents))) 69 (icalendar--create-uid entry-full contents)))
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 3efe2599138..6dd4bb91bc2 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -31,5 +31,26 @@
31 (symbol-function 31 (symbol-function
32 'dired-jump)))) 32 'dired-jump))))
33 33
34(ert-deftest dired-test-bug22694 ()
35 "Test for http://debbugs.gnu.org/22694 ."
36 (let* ((dir (expand-file-name "bug22694" default-directory))
37 (file "test")
38 (full-name (expand-file-name file dir))
39 (regexp "bar")
40 (dired-always-read-filesystem t))
41 (if (file-exists-p dir)
42 (delete-directory dir 'recursive))
43 (make-directory dir)
44 (with-temp-file full-name (insert "foo"))
45 (find-file-noselect full-name)
46 (dired dir)
47 (with-temp-file full-name (insert "bar"))
48 (dired-mark-files-containing-regexp regexp)
49 (unwind-protect
50 (should (equal (dired-get-marked-files nil nil nil 'distinguish-1-mark)
51 `(t ,full-name)))
52 ;; Clean up
53 (delete-directory dir 'recursive))))
54
34(provide 'dired-tests) 55(provide 'dired-tests)
35;; dired-tests.el ends here 56;; dired-tests.el ends here
diff --git a/test/lisp/emacs-lisp/ert-x-tests.el b/test/lisp/emacs-lisp/ert-x-tests.el
index a2665e7c390..ef8642aebfb 100644
--- a/test/lisp/emacs-lisp/ert-x-tests.el
+++ b/test/lisp/emacs-lisp/ert-x-tests.el
@@ -275,49 +275,6 @@ desired effect."
275 (should (equal (c x) (lisp x)))))) 275 (should (equal (c x) (lisp x))))))
276 276
277 277
278(defun ert--dummy-id (a)
279 "Identity function. Used for tests only."
280 a)
281
282(ert-deftest ert-with-function-mocked ()
283 (let ((mock-id (lambda (_) 21)))
284 (should (eq 42 (ert--dummy-id 42)))
285
286 (ert-with-function-mocked ert--dummy-id nil
287 (fset 'ert--dummy-id mock-id)
288 (should (eq 21 (ert--dummy-id 42))))
289 (should (eq 42 (ert--dummy-id 42)))
290
291 (ert-with-function-mocked ert--dummy-id mock-id
292 (should (eq 21 (ert--dummy-id 42))))
293 (should (eq 42 (ert--dummy-id 42)))
294
295 (should
296 (catch 'exit
297 (ert-with-function-mocked ert--dummy-id mock-id
298 (should (eq 21 (ert--dummy-id 42))))
299 (throw 'exit t)))
300 (should (eq 42 (ert--dummy-id 42)))
301
302 (should
303 (string= "Foo"
304 (condition-case err
305 (progn
306 (ert-with-function-mocked ert--dummy-id mock-id
307 (should (eq 21 (ert--dummy-id 42))))
308 (user-error "Foo"))
309 (user-error (cadr err)))))
310 (should (eq 42 (ert--dummy-id 42)))
311
312 (should
313 (string= "`ert--dummy-id' unexpectedly called."
314 (condition-case err
315 (ert-with-function-mocked ert--dummy-id nil
316 (ert--dummy-id 42))
317 (ert-test-failed (cadr err)))))
318 (should (eq 42 (ert--dummy-id 42)))))
319
320
321(provide 'ert-x-tests) 278(provide 'ert-x-tests)
322 279
323;;; ert-x-tests.el ends here 280;;; ert-x-tests.el ends here
diff --git a/test/lisp/emacs-lisp/map-tests.el b/test/lisp/emacs-lisp/map-tests.el
index 20cb0f6b399..0af1c656e09 100644
--- a/test/lisp/emacs-lisp/map-tests.el
+++ b/test/lisp/emacs-lisp/map-tests.el
@@ -192,6 +192,14 @@ Evaluate BODY for each created map.
192 (2 . b) 192 (2 . b)
193 (3 . c)))))) 193 (3 . c))))))
194 194
195(ert-deftest test-map-do ()
196 (with-maps-do map
197 (let ((result nil))
198 (map-do (lambda (k v)
199 (add-to-list 'result (list (int-to-string k) v)))
200 map)
201 (should (equal result '(("2" 5) ("1" 4) ("0" 3)))))))
202
195(ert-deftest test-map-keys-apply () 203(ert-deftest test-map-keys-apply ()
196 (with-maps-do map 204 (with-maps-do map
197 (should (equal (map-keys-apply (lambda (k) (int-to-string k)) 205 (should (equal (map-keys-apply (lambda (k) (int-to-string k))
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el
index 0a446fde086..3d2801e3d70 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -370,8 +370,6 @@ Must called from within a `tar-mode' buffer."
370(ert-deftest package-test-update-archives-async () 370(ert-deftest package-test-update-archives-async ()
371 "Test updating package archives asynchronously." 371 "Test updating package archives asynchronously."
372 (skip-unless (executable-find "python2")) 372 (skip-unless (executable-find "python2"))
373 ;; For some reason this test doesn't work reliably on hydra.nixos.org.
374 (skip-unless (not (getenv "NIX_STORE")))
375 (let* ((package-menu-async t) 373 (let* ((package-menu-async t)
376 (default-directory package-test-data-dir) 374 (default-directory package-test-data-dir)
377 (process (start-process 375 (process (start-process
diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el
index 50543de8ada..c2065c6718f 100644
--- a/test/lisp/emacs-lisp/seq-tests.el
+++ b/test/lisp/emacs-lisp/seq-tests.el
@@ -107,6 +107,21 @@ Evaluate BODY for each created sequence.
107 '(a b c d)) 107 '(a b c d))
108 '((a 0) (b 1) (c 2) (d 3))))) 108 '((a 0) (b 1) (c 2) (d 3)))))
109 109
110(ert-deftest test-seq-do-indexed ()
111 (let ((result nil))
112 (seq-do-indexed (lambda (elt i)
113 (add-to-list 'result (list elt i)))
114 nil)
115 (should (equal result nil)))
116 (with-test-sequences (seq '(4 5 6))
117 (let ((result nil))
118 (seq-do-indexed (lambda (elt i)
119 (add-to-list 'result (list elt i)))
120 seq)
121 (should (equal (seq-elt result 0) '(6 2)))
122 (should (equal (seq-elt result 1) '(5 1)))
123 (should (equal (seq-elt result 2) '(4 0))))))
124
110(ert-deftest test-seq-filter () 125(ert-deftest test-seq-filter ()
111 (with-test-sequences (seq '(6 7 8 9 10)) 126 (with-test-sequences (seq '(6 7 8 9 10))
112 (should (equal (seq-filter #'test-sequences-evenp seq) '(6 8 10))) 127 (should (equal (seq-filter #'test-sequences-evenp seq) '(6 8 10)))
@@ -166,6 +181,10 @@ Evaluate BODY for each created sequence.
166 (should-not (seq-contains seq 3)) 181 (should-not (seq-contains seq 3))
167 (should-not (seq-contains seq nil)))) 182 (should-not (seq-contains seq nil))))
168 183
184(ert-deftest test-seq-contains-should-return-the-elt ()
185 (with-test-sequences (seq '(3 4 5 6))
186 (should (= 5 (seq-contains seq 5)))))
187
169(ert-deftest test-seq-every-p () 188(ert-deftest test-seq-every-p ()
170 (with-test-sequences (seq '(43 54 22 1)) 189 (with-test-sequences (seq '(43 54 22 1))
171 (should (seq-every-p (lambda (elt) t) seq)) 190 (should (seq-every-p (lambda (elt) t) seq))
diff --git a/test/lisp/emulation/viper-tests.el b/test/lisp/emulation/viper-tests.el
index 074dd637538..0d6095b2c92 100644
--- a/test/lisp/emulation/viper-tests.el
+++ b/test/lisp/emulation/viper-tests.el
@@ -38,7 +38,7 @@ after itself, although it will leave a buffer called
38 ;; Select an expert-level for the same reason. 38 ;; Select an expert-level for the same reason.
39 (viper-expert-level 5) 39 (viper-expert-level 5)
40 ;; viper loads this even with -q so make sure it's empty! 40 ;; viper loads this even with -q so make sure it's empty!
41 (viper-custom-file-name (make-temp-file "viper-tests")) 41 (viper-custom-file-name (make-temp-file "viper-tests" nil ".elc"))
42 (before-buffer (current-buffer))) 42 (before-buffer (current-buffer)))
43 (unwind-protect 43 (unwind-protect
44 (progn 44 (progn
diff --git a/test/lisp/erc/erc-track-tests.el b/test/lisp/erc/erc-track-tests.el
index 24dfcfbe6e0..7cf3ef7bb2f 100644
--- a/test/lisp/erc/erc-track-tests.el
+++ b/test/lisp/erc/erc-track-tests.el
@@ -24,6 +24,7 @@
24 24
25(require 'ert) 25(require 'ert)
26(require 'erc-track) 26(require 'erc-track)
27(require 'font-core)
27 28
28(ert-deftest erc-track--shorten-aggressive-nil () 29(ert-deftest erc-track--shorten-aggressive-nil ()
29 "Test non-aggressive erc track buffer name shortening." 30 "Test non-aggressive erc track buffer name shortening."
@@ -107,9 +108,12 @@
107(ert-deftest erc-track--erc-faces-in () 108(ert-deftest erc-track--erc-faces-in ()
108 "`erc-faces-in' should pick up both 'face and 'font-lock-face properties." 109 "`erc-faces-in' should pick up both 'face and 'font-lock-face properties."
109 (let ((str0 "is bold") 110 (let ((str0 "is bold")
110 (str1 "is bold") 111 (str1 "is bold"))
111 ;;(char-property-alias-alist '((face font-lock-face))) 112 ;; Turn on Font Lock mode: this initialize `char-property-alias-alist'
112 ) 113 ;; to '((face font-lock-face)). Note that `font-lock-mode' don't
114 ;; turn on the mode if the test is run on batch mode or if the
115 ;; buffer name starts with ?\s (Bug#23954).
116 (unless font-lock-mode (font-lock-default-function 1))
113 (put-text-property 3 (length str0) 'font-lock-face 117 (put-text-property 3 (length str0) 'font-lock-face
114 '(bold erc-current-nick-face) str0) 118 '(bold erc-current-nick-face) str0)
115 (put-text-property 3 (length str1) 'face 119 (put-text-property 3 (length str1) 'face
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 518a1eb1f5a..0e6e58e7b80 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -1,4 +1,4 @@
1;;; file-notify-tests.el --- Tests of file notifications -*- lexical-binding: t; -*- 1;;; filenotify-tests.el --- Tests of file notifications -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2013-2016 Free Software Foundation, Inc. 3;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
4 4
@@ -385,7 +385,7 @@ delivered."
385 ;; Flush pending events. 385 ;; Flush pending events.
386 (file-notify--wait-for-events 386 (file-notify--wait-for-events
387 (file-notify--test-timeout) 387 (file-notify--test-timeout)
388 (input-pending-p)) 388 (not (input-pending-p)))
389 (setq file-notify--test-events nil 389 (setq file-notify--test-events nil
390 file-notify--test-results nil) 390 file-notify--test-results nil)
391 ,@body 391 ,@body
@@ -444,16 +444,9 @@ delivered."
444 ;; cygwin recognizes only `deleted' and `stopped' events. 444 ;; cygwin recognizes only `deleted' and `stopped' events.
445 ((eq system-type 'cygwin) 445 ((eq system-type 'cygwin)
446 '(deleted stopped)) 446 '(deleted stopped))
447 ;; inotify and kqueue raise just one `changed' event. 447 ;; There could be one or two `changed' events.
448 ((or (string-equal "inotify" (file-notify--test-library)) 448 (t '((changed deleted stopped)
449 (string-equal "kqueue" (file-notify--test-library))) 449 (changed changed deleted stopped))))
450 '(changed deleted stopped))
451 ;; gfilenotify raises one or two `changed' events
452 ;; randomly, no chance to test. So we accept both cases.
453 ((string-equal "gfilenotify" (file-notify--test-library))
454 '((changed deleted stopped)
455 (changed changed deleted stopped)))
456 (t '(changed changed deleted stopped)))
457 (write-region 450 (write-region
458 "another text" nil file-notify--test-tmpfile nil 'no-message) 451 "another text" nil file-notify--test-tmpfile nil 'no-message)
459 (read-event nil nil file-notify--test-read-event-timeout) 452 (read-event nil nil file-notify--test-read-event-timeout)
@@ -739,16 +732,9 @@ delivered."
739 ;; cygwin recognizes only `deleted' and `stopped' events. 732 ;; cygwin recognizes only `deleted' and `stopped' events.
740 ((eq system-type 'cygwin) 733 ((eq system-type 'cygwin)
741 '(deleted stopped)) 734 '(deleted stopped))
742 ;; inotify and kqueue raise just one `changed' event. 735 ;; There could be one or two `changed' events.
743 ((or (string-equal "inotify" (file-notify--test-library)) 736 (t '((changed deleted stopped)
744 (string-equal "kqueue" (file-notify--test-library))) 737 (changed changed deleted stopped))))
745 '(changed deleted stopped))
746 ;; gfilenotify raises one or two `changed' events
747 ;; randomly, no chance to test. So we accept both cases.
748 ((string-equal "gfilenotify" (file-notify--test-library))
749 '((changed deleted stopped)
750 (changed changed deleted stopped)))
751 (t '(changed changed deleted stopped)))
752 (write-region 738 (write-region
753 "another text" nil file-notify--test-tmpfile nil 'no-message) 739 "another text" nil file-notify--test-tmpfile nil 'no-message)
754 (read-event nil nil file-notify--test-read-event-timeout) 740 (read-event nil nil file-notify--test-read-event-timeout)
@@ -944,21 +930,9 @@ delivered."
944 '(change) #'file-notify--test-event-handler))) 930 '(change) #'file-notify--test-event-handler)))
945 (should (file-notify-valid-p file-notify--test-desc)) 931 (should (file-notify-valid-p file-notify--test-desc))
946 (file-notify--test-with-events 932 (file-notify--test-with-events
947 (cond 933 ;; There could be one or two `changed' events.
948 ;; On Cygwin there is one `changed' event in both the 934 '((changed)
949 ;; local and remote cases. 935 (changed changed))
950 ((eq system-type 'cygwin) '(changed))
951 ;; For w32notify and in the remote case, there are two
952 ;; `changed' events.
953 ((or (string-equal (file-notify--test-library) "w32notify")
954 (file-remote-p temporary-file-directory))
955 '(changed changed))
956 ;; gfilenotify raises one or two `changed' events
957 ;; randomly, no chance to test. So we accept both cases.
958 ((string-equal "gfilenotify" (file-notify--test-library))
959 '((changed)
960 (changed changed)))
961 (t '(changed)))
962 ;; There shouldn't be any problem, because the file is kept. 936 ;; There shouldn't be any problem, because the file is kept.
963 (with-temp-buffer 937 (with-temp-buffer
964 (let ((buffer-file-name file-notify--test-tmpfile) 938 (let ((buffer-file-name file-notify--test-tmpfile)
@@ -993,7 +967,7 @@ delivered."
993 (should (file-notify-valid-p file-notify--test-desc)) 967 (should (file-notify-valid-p file-notify--test-desc))
994 (file-notify--test-with-events 968 (file-notify--test-with-events
995 (cond 969 (cond
996 ;; On Cygwin we only get the `changed' event. 970 ;; On cygwin we only get the `changed' event.
997 ((eq system-type 'cygwin) '(changed)) 971 ((eq system-type 'cygwin) '(changed))
998 (t '(renamed created changed))) 972 (t '(renamed created changed)))
999 ;; The file is renamed when creating a backup. It shall 973 ;; The file is renamed when creating a backup. It shall
@@ -1062,53 +1036,38 @@ the file watch."
1062 (should (file-notify-valid-p file-notify--test-desc1)) 1036 (should (file-notify-valid-p file-notify--test-desc1))
1063 (should (file-notify-valid-p file-notify--test-desc2)) 1037 (should (file-notify-valid-p file-notify--test-desc2))
1064 (should-not (equal file-notify--test-desc1 file-notify--test-desc2)) 1038 (should-not (equal file-notify--test-desc1 file-notify--test-desc2))
1065 ;; gfilenotify raises one or two `changed' events randomly in 1039 (let ((n 100))
1066 ;; the file monitor, no chance to test. 1040 ;; Run the test.
1067 (unless (string-equal "gfilenotify" (file-notify--test-library)) 1041 (file-notify--test-with-events
1068 (let ((n 100) events) 1042 ;; There could be one or two `changed' events.
1069 ;; Compute the expected events. 1043 (list
1070 (dotimes (_i (/ n 2)) 1044 (append
1071 (setq events 1045 '(:random)
1072 (append 1046 ;; Directory monitor and file monitor.
1073 (append 1047 (make-list (/ n 2) 'changed)
1074 ;; Directory monitor and file monitor. 1048 (make-list (/ n 2) 'changed)
1075 (cond 1049 ;; Just the directory monitor.
1076 ;; In the remote case, there are two `changed' 1050 (make-list (/ n 2) 'created)
1077 ;; events. 1051 (make-list (/ n 2) 'changed))
1078 ((file-remote-p temporary-file-directory) 1052 (append
1079 '(changed changed changed changed)) 1053 '(:random)
1080 ;; The directory monitor in kqueue does not 1054 ;; Directory monitor and file monitor.
1081 ;; raise any `changed' event. Just the file 1055 (make-list (/ n 2) 'changed)
1082 ;; monitor event is received. 1056 (make-list (/ n 2) 'changed)
1083 ((string-equal (file-notify--test-library) "kqueue") 1057 (make-list (/ n 2) 'changed)
1084 '(changed)) 1058 (make-list (/ n 2) 'changed)
1085 ;; Otherwise, both monitors report the 1059 ;; Just the directory monitor.
1086 ;; `changed' event. 1060 (make-list (/ n 2) 'created)
1087 (t '(changed changed))) 1061 (make-list (/ n 2) 'changed)))
1088 1062 (dotimes (i n)
1089 ;; Just the directory monitor. 1063 (read-event nil nil file-notify--test-read-event-timeout)
1090 (cond 1064 (if (zerop (mod i 2))
1091 ;; In kqueue, there is an additional `changed' 1065 (write-region
1092 ;; event. Why? 1066 "any text" nil file-notify--test-tmpfile1 t 'no-message)
1093 ((string-equal (file-notify--test-library) "kqueue") 1067 (let ((temporary-file-directory file-notify--test-tmpfile))
1094 '(changed created changed)) 1068 (write-region
1095 (t '(created changed)))) 1069 "any text" nil
1096 events))) 1070 (file-notify--test-make-temp-name) nil 'no-message))))))
1097 ;; gvfs-monitor-dir returns the events in random order.
1098 (when (string-equal "gvfs-monitor-dir" (file-notify--test-library))
1099 (setq events (cons :random events)))
1100
1101 ;; Run the test.
1102 (file-notify--test-with-events events
1103 (dotimes (i n)
1104 (read-event nil nil file-notify--test-read-event-timeout)
1105 (if (zerop (mod i 2))
1106 (write-region
1107 "any text" nil file-notify--test-tmpfile1 t 'no-message)
1108 (let ((temporary-file-directory file-notify--test-tmpfile))
1109 (write-region
1110 "any text" nil
1111 (file-notify--test-make-temp-name) nil 'no-message)))))))
1112 1071
1113 ;; If we delete the file, the directory monitor shall still be 1072 ;; If we delete the file, the directory monitor shall still be
1114 ;; active. We receive the `deleted' event from both the 1073 ;; active. We receive the `deleted' event from both the
@@ -1218,4 +1177,4 @@ the file watch."
1218;; * Check, why cygwin recognizes only `deleted' and `stopped' events. 1177;; * Check, why cygwin recognizes only `deleted' and `stopped' events.
1219 1178
1220(provide 'file-notify-tests) 1179(provide 'file-notify-tests)
1221;;; file-notify-tests.el ends here 1180;;; filenotify-tests.el ends here
diff --git a/test/lisp/gnus/message-tests.el b/test/lisp/gnus/message-tests.el
index ae34f24d741..13c15e33b27 100644
--- a/test/lisp/gnus/message-tests.el
+++ b/test/lisp/gnus/message-tests.el
@@ -57,7 +57,7 @@
57 57
58 58
59(ert-deftest message-strip-subject-trailing-was () 59(ert-deftest message-strip-subject-trailing-was ()
60 (ert-with-function-mocked message-talkative-question nil 60 (cl-letf (((symbol-function 'message-talkative-question) nil))
61 (with-temp-buffer 61 (with-temp-buffer
62 (let ((no-was "Re: Foo ") 62 (let ((no-was "Re: Foo ")
63 (with-was "Re: Foo \t (was: Bar ) ") 63 (with-was "Re: Foo \t (was: Bar ) ")
diff --git a/test/lisp/help-fns-tests.el b/test/lisp/help-fns-tests.el
index babba1a68fc..ba0d8ed8e38 100644
--- a/test/lisp/help-fns-tests.el
+++ b/test/lisp/help-fns-tests.el
@@ -27,13 +27,62 @@
27 27
28(autoload 'help-fns-test--macro "help-fns" nil nil t) 28(autoload 'help-fns-test--macro "help-fns" nil nil t)
29 29
30
31;;; Several tests for describe-function
32
33(defun help-fns-tests--describe-function (func)
34 "Helper function for `describe-function' tests.
35FUNC is the function to describe, a symbol.
36Return first line of the output of (describe-function-1 FUNC)."
37 (let ((string (with-output-to-string
38 (describe-function-1 func))))
39 (string-match "\\(.+\\)\n" string)
40 (match-string-no-properties 1 string)))
41
30(ert-deftest help-fns-test-bug17410 () 42(ert-deftest help-fns-test-bug17410 ()
31 "Test for http://debbugs.gnu.org/17410 ." 43 "Test for http://debbugs.gnu.org/17410 ."
32 (describe-function 'help-fns-test--macro) 44 (let ((regexp "autoloaded Lisp macro")
33 (with-current-buffer "*Help*" 45 (result (help-fns-tests--describe-function 'help-fns-test--macro)))
34 (goto-char (point-min)) 46 (should (string-match regexp result))))
35 (should (search-forward "autoloaded Lisp macro" (line-end-position))))) 47
36 48(ert-deftest help-fns-test-built-in ()
49 (let ((regexp "a built-in function in .C source code")
50 (result (help-fns-tests--describe-function 'mapcar)))
51 (should (string-match regexp result))))
52
53(ert-deftest help-fns-test-interactive-built-in ()
54 (let ((regexp "an interactive built-in function in .C source code")
55 (result (help-fns-tests--describe-function 're-search-forward)))
56 (should (string-match regexp result))))
57
58(ert-deftest help-fns-test-lisp-macro ()
59 (let ((regexp "a Lisp macro in .subr\.el")
60 (result (help-fns-tests--describe-function 'when)))
61 (should (string-match regexp result))))
62
63(ert-deftest help-fns-test-lisp-defun ()
64 (let ((regexp "a compiled Lisp function in .subr\.el")
65 (result (help-fns-tests--describe-function 'last)))
66 (should (string-match regexp result))))
67
68(ert-deftest help-fns-test-lisp-defsubst ()
69 (let ((regexp "a compiled Lisp function in .subr\.el")
70 (result (help-fns-tests--describe-function 'posn-window)))
71 (should (string-match regexp result))))
72
73(ert-deftest help-fns-test-alias-to-defun ()
74 (let ((regexp "an alias for .set-file-modes. in .subr\.el")
75 (result (help-fns-tests--describe-function 'chmod)))
76 (should (string-match regexp result))))
77
78(ert-deftest help-fns-test-bug23887 ()
79 "Test for http://debbugs.gnu.org/23887 ."
80 (let ((regexp "an alias for .re-search-forward. in .subr\.el")
81 (result (help-fns-tests--describe-function 'search-forward-regexp)))
82 (should (string-match regexp result))))
83
84
85;;; Test describe-function over functions with funny names
37(defun abc\\\[universal-argument\]b\`c\'d\\e\"f (x) 86(defun abc\\\[universal-argument\]b\`c\'d\\e\"f (x)
38 "A function with a funny name. 87 "A function with a funny name.
39 88
@@ -57,6 +106,8 @@
57 (should (search-forward 106 (should (search-forward
58 "(defgh\\\\\\[universal-argument\\]b\\`c\\'d\\\\e\\\"f X)")))) 107 "(defgh\\\\\\[universal-argument\\]b\\`c\\'d\\\\e\\\"f X)"))))
59 108
109
110;;; Test for describe-symbol
60(ert-deftest help-fns-test-describe-symbol () 111(ert-deftest help-fns-test-describe-symbol ()
61 "Test the `describe-symbol' function." 112 "Test the `describe-symbol' function."
62 ;; 'describe-symbol' would originally signal an error for 113 ;; 'describe-symbol' would originally signal an error for
diff --git a/test/lisp/international/ucs-normalize-tests.el b/test/lisp/international/ucs-normalize-tests.el
new file mode 100644
index 00000000000..42cf805b778
--- /dev/null
+++ b/test/lisp/international/ucs-normalize-tests.el
@@ -0,0 +1,277 @@
1;;; ucs-normalize --- tests for international/ucs-normalize.el -*- lexical-binding: t -*-
2
3;; Copyright (C) 2002-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;; The Part1 test takes a long time because it goes over the whole
23;; unicode character set; you should build Emacs with optimization
24;; enabled before running it.
25;;
26;; If there are lines marked as failing (see
27;; `ucs-normalize-tests--failing-lines-part1' and
28;; `ucs-normalize-tests--failing-lines-part2'), they may need to be
29;; adjusted when NormalizationTest.txt is updated. To get a list of
30;; currently failing lines, set those 2 variables to nil, run the
31;; tests, and inspect the values of
32;; `ucs-normalize-tests--part1-rule1-failed-lines' and
33;; `ucs-normalize-tests--part1-rule2-failed-chars', respectively.
34
35;;; Code:
36
37(eval-when-compile (require 'cl-lib))
38(require 'ert)
39(require 'ucs-normalize)
40
41(defconst ucs-normalize-test-data-file
42 (expand-file-name "admin/unidata/NormalizationTest.txt" source-directory))
43
44(defun ucs-normalize-tests--parse-column ()
45 (let ((chars nil)
46 (term nil))
47 (while (and (not (equal term ";"))
48 (looking-at "\\([[:xdigit:]]\\{4,6\\}\\)\\([; ]\\)"))
49 (let ((code-point (match-string 1)))
50 (setq term (match-string 2))
51 (goto-char (match-end 0))
52 (push (string-to-number code-point 16) chars)))
53 (nreverse chars)))
54
55(defmacro ucs-normalize-tests--normalize (norm str)
56 "Like `ucs-normalize-string' but reuse current buffer for efficiency.
57And NORM is one of the symbols `NFC', `NFD', `NFKC', `NFKD' for brevity."
58 (let ((norm-alist '((NFC . ucs-normalize-NFC-region)
59 (NFD . ucs-normalize-NFD-region)
60 (NFKC . ucs-normalize-NFKC-region)
61 (NFKD . ucs-normalize-NFKD-region))))
62 `(save-restriction
63 (narrow-to-region (point) (point))
64 (insert ,str)
65 (funcall #',(cdr (assq norm norm-alist)) (point-min) (point-max))
66 (delete-and-extract-region (point-min) (point-max)))))
67
68(defvar ucs-normalize-tests--chars-part1 nil)
69
70(defun ucs-normalize-tests--invariants-hold-p (&rest columns)
71 "Check 1st conformance rule.
72The following invariants must be true for all conformant implementations..."
73 (when ucs-normalize-tests--chars-part1
74 ;; See `ucs-normalize-tests--invariants-rule2-hold-p'.
75 (aset ucs-normalize-tests--chars-part1
76 (caar columns) 1))
77 (cl-destructuring-bind (source nfc nfd nfkc nfkd)
78 (mapcar (lambda (c) (apply #'string c)) columns)
79 (and
80 ;; c2 == toNFC(c1) == toNFC(c2) == toNFC(c3)
81 (equal nfc (ucs-normalize-tests--normalize NFC source))
82 (equal nfc (ucs-normalize-tests--normalize NFC nfc))
83 (equal nfc (ucs-normalize-tests--normalize NFC nfd))
84 ;; c4 == toNFC(c4) == toNFC(c5)
85 (equal nfkc (ucs-normalize-tests--normalize NFC nfkc))
86 (equal nfkc (ucs-normalize-tests--normalize NFC nfkd))
87
88 ;; c3 == toNFD(c1) == toNFD(c2) == toNFD(c3)
89 (equal nfd (ucs-normalize-tests--normalize NFD source))
90 (equal nfd (ucs-normalize-tests--normalize NFD nfc))
91 (equal nfd (ucs-normalize-tests--normalize NFD nfd))
92 ;; c5 == toNFD(c4) == toNFD(c5)
93 (equal nfkd (ucs-normalize-tests--normalize NFD nfkc))
94 (equal nfkd (ucs-normalize-tests--normalize NFD nfkd))
95
96 ;; c4 == toNFKC(c1) == toNFKC(c2) == toNFKC(c3) == toNFKC(c4) == toNFKC(c5)
97 (equal nfkc (ucs-normalize-tests--normalize NFKC source))
98 (equal nfkc (ucs-normalize-tests--normalize NFKC nfc))
99 (equal nfkc (ucs-normalize-tests--normalize NFKC nfd))
100 (equal nfkc (ucs-normalize-tests--normalize NFKC nfkc))
101 (equal nfkc (ucs-normalize-tests--normalize NFKC nfkd))
102
103 ;; c5 == toNFKD(c1) == toNFKD(c2) == toNFKD(c3) == toNFKD(c4) == toNFKD(c5)
104 (equal nfkd (ucs-normalize-tests--normalize NFKD source))
105 (equal nfkd (ucs-normalize-tests--normalize NFKD nfc))
106 (equal nfkd (ucs-normalize-tests--normalize NFKD nfd))
107 (equal nfkd (ucs-normalize-tests--normalize NFKD nfkc))
108 (equal nfkd (ucs-normalize-tests--normalize NFKD nfkd)))))
109
110(defun ucs-normalize-tests--invariants-rule2-hold-p (char)
111 "Check 2nd conformance rule.
112For every code point X assigned in this version of Unicode that is not specifically
113listed in Part 1, the following invariants must be true for all conformant
114implementations:
115
116 X == toNFC(X) == toNFD(X) == toNFKC(X) == toNFKD(X)"
117 (let ((X (string char)))
118 (and (equal X (ucs-normalize-tests--normalize NFC X))
119 (equal X (ucs-normalize-tests--normalize NFD X))
120 (equal X (ucs-normalize-tests--normalize NFKC X))
121 (equal X (ucs-normalize-tests--normalize NFKD X)))))
122
123(cl-defun ucs-normalize-tests--invariants-failing-for-part (part &optional skip-lines &key progress-str)
124 "Returns a list of failed line numbers."
125 (with-temp-buffer
126 (insert-file-contents ucs-normalize-test-data-file)
127 (let ((beg-line (progn (search-forward (format "@Part%d" part))
128 (forward-line)
129 (line-number-at-pos)))
130 (end-line (progn (or (search-forward (format "@Part%d" (1+ part)) nil t)
131 (goto-char (point-max)))
132 (line-number-at-pos))))
133 (goto-char (point-min))
134 (forward-line (1- beg-line))
135 (cl-loop with reporter = (if progress-str (make-progress-reporter
136 progress-str beg-line end-line
137 0 nil 0.5))
138 for line from beg-line to (1- end-line)
139 unless (or (= (following-char) ?#)
140 (ucs-normalize-tests--invariants-hold-p
141 (ucs-normalize-tests--parse-column)
142 (ucs-normalize-tests--parse-column)
143 (ucs-normalize-tests--parse-column)
144 (ucs-normalize-tests--parse-column)
145 (ucs-normalize-tests--parse-column))
146 (memq line skip-lines))
147 collect line
148 do (forward-line)
149 if reporter do (progress-reporter-update reporter line)))))
150
151(defun ucs-normalize-tests--invariants-failing-for-lines (lines)
152 "Returns a list of failed line numbers."
153 (with-temp-buffer
154 (insert-file-contents ucs-normalize-test-data-file)
155 (goto-char (point-min))
156 (cl-loop for prev-line = 1 then line
157 for line in lines
158 do (forward-line (- line prev-line))
159 unless (ucs-normalize-tests--invariants-hold-p
160 (ucs-normalize-tests--parse-column)
161 (ucs-normalize-tests--parse-column)
162 (ucs-normalize-tests--parse-column)
163 (ucs-normalize-tests--parse-column)
164 (ucs-normalize-tests--parse-column))
165 collect line)))
166
167(ert-deftest ucs-normalize-part0 ()
168 (should-not (ucs-normalize-tests--invariants-failing-for-part 0)))
169
170(defconst ucs-normalize-tests--failing-lines-part1
171 (list 15131 15132 15133 15134 15135 15136 15137 15138
172 15139
173 16149 16150 16151 16152 16153 16154 16155 16156
174 16157 16158 16159 16160 16161 16162 16163 16164
175 16165 16166 16167 16168 16169 16170 16171 16172
176 16173 16174 16175 16176 16177 16178 16179 16180
177 16181 16182 16183 16184 16185 16186 16187 16188
178 16189 16190 16191 16192 16193 16194 16195 16196
179 16197 16198 16199 16200 16201 16202 16203 16204
180 16205 16206 16207 16208 16209 16210 16211 16212
181 16213 16214 16215 16216 16217 16218 16219 16220
182 16221 16222 16223 16224 16225 16226 16227 16228
183 16229 16230 16231 16232 16233 16234 16235 16236
184 16237 16238 16239 16240 16241 16242 16243 16244
185 16245 16246 16247 16248 16249 16250 16251 16252
186 16253 16254 16255 16256 16257 16258 16259 16260
187 16261 16262 16263 16264 16265 16266 16267 16268
188 16269 16270 16271 16272 16273 16274 16275 16276
189 16277 16278 16279 16280 16281 16282 16283 16284
190 16285 16286 16287 16288 16289))
191
192;; Keep a record of failures, for consulting afterwards (the ert
193;; backtrace only shows a truncated version of these lists).
194(defvar ucs-normalize-tests--part1-rule1-failed-lines nil
195 "A list of line numbers.")
196(defvar ucs-normalize-tests--part1-rule2-failed-chars nil
197 "A list of code points.")
198
199(defun ucs-normalize-tests--part1-rule2 (chars-part1)
200 (let ((reporter (make-progress-reporter "UCS Normalize Test Part1, rule 2"
201 0 (max-char)))
202 (failed-chars nil))
203 (map-char-table
204 (lambda (char-range listed-in-part)
205 (unless (eq listed-in-part 1)
206 (if (characterp char-range)
207 (progn (unless (ucs-normalize-tests--invariants-rule2-hold-p char-range)
208 (push char-range failed-chars))
209 (progress-reporter-update reporter char-range))
210 (cl-loop for char from (car char-range) to (cdr char-range)
211 unless (ucs-normalize-tests--invariants-rule2-hold-p char)
212 do (push char failed-chars)
213 do (progress-reporter-update reporter char)))))
214 chars-part1)
215 (progress-reporter-done reporter)
216 failed-chars))
217
218(ert-deftest ucs-normalize-part1 ()
219 :tags '(:expensive-test)
220 ;; This takes a long time, so make sure we're compiled.
221 (dolist (fun '(ucs-normalize-tests--part1-rule2
222 ucs-normalize-tests--invariants-failing-for-part
223 ucs-normalize-tests--invariants-hold-p
224 ucs-normalize-tests--invariants-rule2-hold-p))
225 (or (byte-code-function-p (symbol-function fun))
226 (byte-compile fun)))
227 (let ((ucs-normalize-tests--chars-part1 (make-char-table 'ucs-normalize-tests t)))
228 (should-not
229 (setq ucs-normalize-tests--part1-rule1-failed-lines
230 (ucs-normalize-tests--invariants-failing-for-part
231 1 ucs-normalize-tests--failing-lines-part1
232 :progress-str "UCS Normalize Test Part1, rule 1")))
233 (should-not (setq ucs-normalize-tests--part1-rule2-failed-chars
234 (ucs-normalize-tests--part1-rule2
235 ucs-normalize-tests--chars-part1)))))
236
237(ert-deftest ucs-normalize-part1-failing ()
238 :expected-result :failed
239 (skip-unless ucs-normalize-tests--failing-lines-part1)
240 (should-not
241 (ucs-normalize-tests--invariants-failing-for-lines
242 ucs-normalize-tests--failing-lines-part1)))
243
244(defconst ucs-normalize-tests--failing-lines-part2
245 (list 18328 18330 18332 18334 18336 18338 18340 18342
246 18344 18346 18348 18350 18352 18354 18356 18358
247 18360 18362 18364 18366 18368 18370 18372 18374
248 18376 18378 18380 18382 18384 18386 18388 18390
249 18392 18394 18396 18398 18400 18402 18404 18406
250 18408 18410 18412 18414 18416 18418 18420 18422
251 18424 18426 18494 18496 18498 18500 18502 18504
252 18506 18508 18510 18512 18514 18516 18518 18520
253 18522 18524 18526 18528 18530 18532 18534 18536
254 18538 18540 18542 18544 18546 18548 18550 18552
255 18554 18556 18558 18560 18562 18564 18566 18568
256 18570 18572 18574 18576 18578 18580 18582 18584
257 18586 18588 18590 18592 18594 18596))
258
259(ert-deftest ucs-normalize-part2 ()
260 :tags '(:expensive-test)
261 (should-not
262 (ucs-normalize-tests--invariants-failing-for-part
263 2 ucs-normalize-tests--failing-lines-part2
264 :progress-str "UCS Normalize Test Part2")))
265
266(ert-deftest ucs-normalize-part2-failing ()
267 :expected-result :failed
268 (skip-unless ucs-normalize-tests--failing-lines-part2)
269 (should-not
270 (ucs-normalize-tests--invariants-failing-for-lines
271 ucs-normalize-tests--failing-lines-part2)))
272
273(ert-deftest ucs-normalize-part3 ()
274 (should-not
275 (ucs-normalize-tests--invariants-failing-for-part 3)))
276
277;;; ucs-normalize-tests.el ends here
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index a8d89e87c2d..a1ae78ab5c3 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -115,11 +115,10 @@ being the result.")
115(defmacro tramp--instrument-test-case (verbose &rest body) 115(defmacro tramp--instrument-test-case (verbose &rest body)
116 "Run BODY with `tramp-verbose' equal VERBOSE. 116 "Run BODY with `tramp-verbose' equal VERBOSE.
117Print the the content of the Tramp debug buffer, if BODY does not 117Print the the content of the Tramp debug buffer, if BODY does not
118eval properly in `should', `should-not' or `should-error'. BODY 118eval properly in `should' or `should-not'. `should-error' is not
119shall not contain a timeout." 119handled properly. BODY shall not contain a timeout."
120 (declare (indent 1) (debug (natnump body))) 120 (declare (indent 1) (debug (natnump body)))
121 `(let ((tramp-verbose ,verbose) 121 `(let ((tramp-verbose ,verbose)
122 (tramp-message-show-message t)
123 (tramp-debug-on-error t) 122 (tramp-debug-on-error t)
124 (debug-ignored-errors 123 (debug-ignored-errors
125 (cons "^make-symbolic-link not supported$" debug-ignored-errors))) 124 (cons "^make-symbolic-link not supported$" debug-ignored-errors)))
@@ -932,7 +931,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
932 (make-directory tmp-name1) 931 (make-directory tmp-name1)
933 (should (file-directory-p tmp-name1)) 932 (should (file-directory-p tmp-name1))
934 (should (file-accessible-directory-p tmp-name1)) 933 (should (file-accessible-directory-p tmp-name1))
935 (should-error (make-directory tmp-name2) :type 'file-error) 934 (should-error (make-directory tmp-name2))
936 (make-directory tmp-name2 'parents) 935 (make-directory tmp-name2 'parents)
937 (should (file-directory-p tmp-name2)) 936 (should (file-directory-p tmp-name2))
938 (should (file-accessible-directory-p tmp-name2))) 937 (should (file-accessible-directory-p tmp-name2)))
@@ -952,19 +951,16 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
952 (should-not (file-directory-p tmp-name)) 951 (should-not (file-directory-p tmp-name))
953 ;; Delete non-empty directory. 952 ;; Delete non-empty directory.
954 (make-directory tmp-name) 953 (make-directory tmp-name)
954 (should (file-directory-p tmp-name))
955 (write-region "foo" nil (expand-file-name "bla" tmp-name)) 955 (write-region "foo" nil (expand-file-name "bla" tmp-name))
956 (should-error (delete-directory tmp-name) :type 'file-error) 956 (should (file-exists-p (expand-file-name "bla" tmp-name)))
957 (should-error (delete-directory tmp-name))
957 (delete-directory tmp-name 'recursive) 958 (delete-directory tmp-name 'recursive)
958 (should-not (file-directory-p tmp-name)))) 959 (should-not (file-directory-p tmp-name))))
959 960
960(ert-deftest tramp-test15-copy-directory () 961(ert-deftest tramp-test15-copy-directory ()
961 "Check `copy-directory'." 962 "Check `copy-directory'."
962 (skip-unless (tramp--test-enabled)) 963 (skip-unless (tramp--test-enabled))
963 (skip-unless
964 (not
965 (eq
966 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
967 'tramp-smb-file-name-handler)))
968 964
969 (let* ((tmp-name1 (tramp--test-make-temp-name)) 965 (let* ((tmp-name1 (tramp--test-make-temp-name))
970 (tmp-name2 (tramp--test-make-temp-name)) 966 (tmp-name2 (tramp--test-make-temp-name))
@@ -973,6 +969,8 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
973 (tmp-name4 (expand-file-name "foo" tmp-name1)) 969 (tmp-name4 (expand-file-name "foo" tmp-name1))
974 (tmp-name5 (expand-file-name "foo" tmp-name2)) 970 (tmp-name5 (expand-file-name "foo" tmp-name2))
975 (tmp-name6 (expand-file-name "foo" tmp-name3))) 971 (tmp-name6 (expand-file-name "foo" tmp-name3)))
972
973 ;; Copy complete directory.
976 (unwind-protect 974 (unwind-protect
977 (progn 975 (progn
978 ;; Copy empty directory. 976 ;; Copy empty directory.
@@ -991,6 +989,31 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
991 ;; Cleanup. 989 ;; Cleanup.
992 (ignore-errors 990 (ignore-errors
993 (delete-directory tmp-name1 'recursive) 991 (delete-directory tmp-name1 'recursive)
992 (delete-directory tmp-name2 'recursive)))
993
994 ;; Copy directory contents.
995 (unwind-protect
996 (progn
997 ;; Copy empty directory.
998 (make-directory tmp-name1)
999 (write-region "foo" nil tmp-name4)
1000 (should (file-directory-p tmp-name1))
1001 (should (file-exists-p tmp-name4))
1002 (copy-directory tmp-name1 tmp-name2 nil 'parents 'contents)
1003 (should (file-directory-p tmp-name2))
1004 (should (file-exists-p tmp-name5))
1005 ;; Target directory does exist already.
1006 (delete-file tmp-name5)
1007 (should-not (file-exists-p tmp-name5))
1008 (copy-directory tmp-name1 tmp-name2 nil 'parents 'contents)
1009 (should (file-directory-p tmp-name2))
1010 (should (file-exists-p tmp-name5))
1011 (should-not (file-directory-p tmp-name3))
1012 (should-not (file-exists-p tmp-name6)))
1013
1014 ;; Cleanup.
1015 (ignore-errors
1016 (delete-directory tmp-name1 'recursive)
994 (delete-directory tmp-name2 'recursive))))) 1017 (delete-directory tmp-name2 'recursive)))))
995 1018
996(ert-deftest tramp-test16-directory-files () 1019(ert-deftest tramp-test16-directory-files ()
@@ -1090,12 +1113,12 @@ This tests also `file-readable-p' and `file-regular-p'."
1090 (progn 1113 (progn
1091 (write-region "foo" nil tmp-name1) 1114 (write-region "foo" nil tmp-name1)
1092 (should (file-exists-p tmp-name1)) 1115 (should (file-exists-p tmp-name1))
1093 (setq attr (file-attributes tmp-name1))
1094 (should (consp attr))
1095 (should (file-exists-p tmp-name1))
1096 (should (file-readable-p tmp-name1)) 1116 (should (file-readable-p tmp-name1))
1097 (should (file-regular-p tmp-name1)) 1117 (should (file-regular-p tmp-name1))
1118
1098 ;; We do not test inodes and device numbers. 1119 ;; We do not test inodes and device numbers.
1120 (setq attr (file-attributes tmp-name1))
1121 (should (consp attr))
1099 (should (null (car attr))) 1122 (should (null (car attr)))
1100 (should (numberp (nth 1 attr))) ;; Link. 1123 (should (numberp (nth 1 attr))) ;; Link.
1101 (should (numberp (nth 2 attr))) ;; Uid. 1124 (should (numberp (nth 2 attr))) ;; Uid.
@@ -1390,10 +1413,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
1390 (format "%s:" method) 1413 (format "%s:" method)
1391 (file-name-all-completions (substring method 0 1) "/")))) 1414 (file-name-all-completions (substring method 0 1) "/"))))
1392 (unless (zerop (length host)) 1415 (unless (zerop (length host))
1393 (should 1416 (let ((tramp-default-method (or method tramp-default-method)))
1394 (member 1417 (should
1395 (format "%s:" host) 1418 (member
1396 (file-name-all-completions (substring host 0 1) "/")))) 1419 (format "%s:" host)
1420 (file-name-all-completions (substring host 0 1) "/")))))
1397 (unless (or (zerop (length method)) (zerop (length host))) 1421 (unless (or (zerop (length method)) (zerop (length host)))
1398 (should 1422 (should
1399 (member 1423 (member
@@ -1846,6 +1870,12 @@ This does not support globbing characters in file names (yet)."
1846 (string-match 1870 (string-match
1847 "ftp$" (file-remote-p tramp-test-temporary-file-directory 'method)))) 1871 "ftp$" (file-remote-p tramp-test-temporary-file-directory 'method))))
1848 1872
1873(defun tramp--test-rsync-p ()
1874 "Check, whether the rsync method is used.
1875This does not support special file names."
1876 (string-equal
1877 "rsync" (file-remote-p tramp-test-temporary-file-directory 'method)))
1878
1849(defun tramp--test-gvfs-p () 1879(defun tramp--test-gvfs-p ()
1850 "Check, whether the remote host runs a GVFS based method. 1880 "Check, whether the remote host runs a GVFS based method.
1851This requires restrictions of file name syntax." 1881This requires restrictions of file name syntax."
@@ -2045,6 +2075,7 @@ Several special characters do not work properly there."
2045(ert-deftest tramp-test31-special-characters () 2075(ert-deftest tramp-test31-special-characters ()
2046 "Check special characters in file names." 2076 "Check special characters in file names."
2047 (skip-unless (tramp--test-enabled)) 2077 (skip-unless (tramp--test-enabled))
2078 (skip-unless (not (tramp--test-rsync-p)))
2048 2079
2049 (tramp--test-special-characters)) 2080 (tramp--test-special-characters))
2050 2081
@@ -2053,6 +2084,7 @@ Several special characters do not work properly there."
2053Use the `stat' command." 2084Use the `stat' command."
2054 :tags '(:expensive-test) 2085 :tags '(:expensive-test)
2055 (skip-unless (tramp--test-enabled)) 2086 (skip-unless (tramp--test-enabled))
2087 (skip-unless (not (tramp--test-rsync-p)))
2056 (skip-unless 2088 (skip-unless
2057 (eq 2089 (eq
2058 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory) 2090 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
@@ -2072,6 +2104,7 @@ Use the `stat' command."
2072Use the `perl' command." 2104Use the `perl' command."
2073 :tags '(:expensive-test) 2105 :tags '(:expensive-test)
2074 (skip-unless (tramp--test-enabled)) 2106 (skip-unless (tramp--test-enabled))
2107 (skip-unless (not (tramp--test-rsync-p)))
2075 (skip-unless 2108 (skip-unless
2076 (eq 2109 (eq
2077 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory) 2110 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
@@ -2094,6 +2127,7 @@ Use the `perl' command."
2094Use the `ls' command." 2127Use the `ls' command."
2095 :tags '(:expensive-test) 2128 :tags '(:expensive-test)
2096 (skip-unless (tramp--test-enabled)) 2129 (skip-unless (tramp--test-enabled))
2130 (skip-unless (not (tramp--test-rsync-p)))
2097 (skip-unless 2131 (skip-unless
2098 (eq 2132 (eq
2099 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory) 2133 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
@@ -2129,6 +2163,7 @@ Use the `ls' command."
2129(ert-deftest tramp-test32-utf8 () 2163(ert-deftest tramp-test32-utf8 ()
2130 "Check UTF8 encoding in file names and file contents." 2164 "Check UTF8 encoding in file names and file contents."
2131 (skip-unless (tramp--test-enabled)) 2165 (skip-unless (tramp--test-enabled))
2166 (skip-unless (not (tramp--test-rsync-p)))
2132 2167
2133 (tramp--test-utf8)) 2168 (tramp--test-utf8))
2134 2169
@@ -2137,6 +2172,7 @@ Use the `ls' command."
2137Use the `stat' command." 2172Use the `stat' command."
2138 :tags '(:expensive-test) 2173 :tags '(:expensive-test)
2139 (skip-unless (tramp--test-enabled)) 2174 (skip-unless (tramp--test-enabled))
2175 (skip-unless (not (tramp--test-rsync-p)))
2140 (skip-unless 2176 (skip-unless
2141 (eq 2177 (eq
2142 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory) 2178 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
@@ -2156,6 +2192,7 @@ Use the `stat' command."
2156Use the `perl' command." 2192Use the `perl' command."
2157 :tags '(:expensive-test) 2193 :tags '(:expensive-test)
2158 (skip-unless (tramp--test-enabled)) 2194 (skip-unless (tramp--test-enabled))
2195 (skip-unless (not (tramp--test-rsync-p)))
2159 (skip-unless 2196 (skip-unless
2160 (eq 2197 (eq
2161 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory) 2198 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
@@ -2178,6 +2215,7 @@ Use the `perl' command."
2178Use the `ls' command." 2215Use the `ls' command."
2179 :tags '(:expensive-test) 2216 :tags '(:expensive-test)
2180 (skip-unless (tramp--test-enabled)) 2217 (skip-unless (tramp--test-enabled))
2218 (skip-unless (not (tramp--test-rsync-p)))
2181 (skip-unless 2219 (skip-unless
2182 (eq 2220 (eq
2183 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory) 2221 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
@@ -2355,8 +2393,7 @@ Since it unloads Tramp, it shall be the last test to run."
2355 2393
2356;; * Work on skipped tests. Make a comment, when it is impossible. 2394;; * Work on skipped tests. Make a comment, when it is impossible.
2357;; * Fix `tramp-test06-directory-file-name' for `ftp'. 2395;; * Fix `tramp-test06-directory-file-name' for `ftp'.
2358;; * Fix `tramp-test15-copy-directory' for `smb'. Using tar in a pipe 2396;; * Fix `tramp-test15-copy-directory' for `rsync'.
2359;; doesn't work well when an interactive password must be provided.
2360;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?). 2397;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?).
2361;; * Fix Bug#16928. Set expected error of `tramp-test33-asynchronous-requests'. 2398;; * Fix Bug#16928. Set expected error of `tramp-test33-asynchronous-requests'.
2362;; * Fix `tramp-test35-unload' (Not all symbols are unbound). Set 2399;; * Fix `tramp-test35-unload' (Not all symbols are unbound). Set
diff --git a/test/lisp/progmodes/cc-mode.el b/test/lisp/progmodes/cc-mode.el
new file mode 100644
index 00000000000..6cd9fa4bad5
--- /dev/null
+++ b/test/lisp/progmodes/cc-mode.el
@@ -0,0 +1,65 @@
1;;; cc-mode-tests.el --- Test suite for cc-mode. -*- lexical-binning: t -*-
2
3;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5;; Author: Michal Nazarewicz <mina86@mina86.com>
6;; Keywords: internal
7;; Human-Keywords: internal
8
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software: you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24;;; Code:
25
26(require 'ert)
27(require 'ert-x)
28(require 'cc-mode)
29
30(ert-deftest c-or-c++-mode ()
31 "Test c-or-c++-mode language detection."
32 (cl-letf* ((mode nil)
33 (do-test (lambda (content expected)
34 (delete-region (point-min) (point-max))
35 (insert content)
36 (setq mode nil)
37 (c-or-c++-mode)
38 (unless(eq expected mode)
39 (ert-fail
40 (format "expected %s but got %s when testing '%s'"
41 expected mode content)))))
42 ((symbol-function 'c-mode) (lambda () (setq mode 'c-mode)))
43 ((symbol-function 'c++-mode) (lambda () (setq mode 'c++-mode))))
44 (with-temp-buffer
45 (mapc (lambda (content)
46 (funcall do-test content 'c++-mode)
47 (funcall do-test (concat "// " content) 'c-mode)
48 (funcall do-test (concat " * " content) 'c-mode))
49 '("using \t namespace \t std;"
50 "using \t std::string;"
51 "namespace \t {"
52 "namespace \t foo \t {"
53 "class \t Blah_42 \t {"
54 "class \t Blah_42 \t \n"
55 "class \t _42_Blah:public Foo {"
56 "template \t < class T >"
57 "template< class T >"
58 "#include <string>"
59 "#include<iostream>"
60 "#include \t <map>"))
61
62 (mapc (lambda (content) (funcall do-test content 'c-mode))
63 '("struct \t Blah_42 \t {"
64 "struct template {"
65 "#include <string.h>")))))
diff --git a/test/lisp/progmodes/ruby-mode-tests.el b/test/lisp/progmodes/ruby-mode-tests.el
index 52126a3bdf1..97f277bff41 100644
--- a/test/lisp/progmodes/ruby-mode-tests.el
+++ b/test/lisp/progmodes/ruby-mode-tests.el
@@ -716,6 +716,17 @@ VALUES-PLIST is a list with alternating index and value elements."
716 (ruby-backward-sexp) 716 (ruby-backward-sexp)
717 (should (= 2 (line-number-at-pos))))) 717 (should (= 2 (line-number-at-pos)))))
718 718
719(ert-deftest ruby-toggle-string-quotes-quotes-correctly ()
720 (let ((pairs
721 '(("puts '\"foo\"\\''" . "puts \"\\\"foo\\\"'\"")
722 ("puts \"'foo'\\\"\"" . "puts '\\'foo\\'\"'"))))
723 (dolist (pair pairs)
724 (ruby-with-temp-buffer (car pair)
725 (beginning-of-line)
726 (search-forward "foo")
727 (ruby-toggle-string-quotes)
728 (should (string= (buffer-string) (cdr pair)))))))
729
719(ert-deftest ruby--insert-coding-comment-ruby-style () 730(ert-deftest ruby--insert-coding-comment-ruby-style ()
720 (with-temp-buffer 731 (with-temp-buffer
721 (let ((ruby-encoding-magic-comment-style 'ruby)) 732 (let ((ruby-encoding-magic-comment-style 'ruby))
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index 12ebc75ea92..97b6c491629 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -204,7 +204,7 @@
204 204
205 205
206;;; `delete-trailing-whitespace' 206;;; `delete-trailing-whitespace'
207(ert-deftest simple-delete-trailing-whitespace () 207(ert-deftest simple-delete-trailing-whitespace--bug-21766 ()
208 "Test bug#21766: delete-whitespace sometimes deletes non-whitespace." 208 "Test bug#21766: delete-whitespace sometimes deletes non-whitespace."
209 (defvar python-indent-guess-indent-offset) ; to avoid a warning 209 (defvar python-indent-guess-indent-offset) ; to avoid a warning
210 (let ((python (featurep 'python)) 210 (let ((python (featurep 'python))
@@ -219,11 +219,25 @@
219 "\n" 219 "\n"
220 "\n")) 220 "\n"))
221 (delete-trailing-whitespace) 221 (delete-trailing-whitespace)
222 (should (equal (count-lines (point-min) (point-max)) 3))) 222 (should (string-equal (buffer-string)
223 (concat "query = \"\"\"WITH filtered AS\n"
224 "WHERE\n"
225 "\"\"\".format(fv_)\n"))))
223 ;; Let's clean up if running interactive 226 ;; Let's clean up if running interactive
224 (unless (or noninteractive python) 227 (unless (or noninteractive python)
225 (unload-feature 'python))))) 228 (unload-feature 'python)))))
226 229
230(ert-deftest simple-delete-trailing-whitespace--formfeeds ()
231 "Test formfeeds are not deleted but whitespace past them is."
232 (with-temp-buffer
233 (with-syntax-table (make-syntax-table)
234 (modify-syntax-entry ?\f " ") ; Make sure \f is whitespace
235 (insert " \f \n \f \f \n\nlast\n")
236 (delete-trailing-whitespace)
237 (should (string-equal (buffer-string) " \f\n \f \f\n\nlast\n"))
238 (should (equal ?\s (char-syntax ?\f)))
239 (should (equal ?\s (char-syntax ?\n))))))
240
227 241
228;;; auto-boundary tests 242;;; auto-boundary tests
229(ert-deftest undo-auto-boundary-timer () 243(ert-deftest undo-auto-boundary-timer ()
@@ -310,6 +324,38 @@
310 (= 6 324 (= 6
311 (undo-test-point-after-forward-kill)))) 325 (undo-test-point-after-forward-kill))))
312 326
327(defmacro simple-test-undo-with-switched-buffer (buffer &rest body)
328 (let ((before-buffer (make-symbol "before-buffer")))
329 `(let ((,before-buffer (current-buffer)))
330 (unwind-protect
331 (progn
332 (switch-to-buffer ,buffer)
333 ,@body)
334 (switch-to-buffer ,before-buffer)))))
335
336;; This tests for a regression in emacs 25.0 see bug #23632
337(ert-deftest simple-test-undo-extra-boundary-in-tex ()
338 (should
339 (string=
340 ""
341 (simple-test-undo-with-switched-buffer
342 "temp.tex"
343 (latex-mode)
344 ;; This macro calls `latex-insert-block'
345 (execute-kbd-macro
346 (read-kbd-macro
347 "
348C-c C-o ;; latex-insert-block
349RET ;; newline
350C-/ ;; undo
351"
352 ))
353 (buffer-substring-no-properties
354 (point-min)
355 (point-max))))))
356
357
358
313 359
314(provide 'simple-test) 360(provide 'simple-test)
315;;; simple-test.el ends here 361;;; simple-test.el ends here
diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el
index fd86fd2d878..d2817875956 100644
--- a/test/lisp/textmodes/css-mode-tests.el
+++ b/test/lisp/textmodes/css-mode-tests.el
@@ -111,7 +111,8 @@
111 (let ((completions (css-mode-tests--completions))) 111 (let ((completions (css-mode-tests--completions)))
112 (should 112 (should
113 (equal (seq-sort #'string-lessp completions) 113 (equal (seq-sort #'string-lessp completions)
114 '("absolute" "fixed" "inherit" "relative" "static")))))) 114 '("absolute" "fixed" "inherit" "initial" "relative"
115 "static" "unset"))))))
115 116
116(ert-deftest css-test-complete-pseudo-class () 117(ert-deftest css-test-complete-pseudo-class ()
117 (with-temp-buffer 118 (with-temp-buffer
diff --git a/test/lisp/vc/vc-bzr-tests.el b/test/lisp/vc/vc-bzr-tests.el
index 98d176ca1ee..f27e6588cf2 100644
--- a/test/lisp/vc/vc-bzr-tests.el
+++ b/test/lisp/vc/vc-bzr-tests.el
@@ -25,7 +25,6 @@
25;;; Code: 25;;; Code:
26 26
27(require 'ert) 27(require 'ert)
28(require 'ert-x)
29(require 'vc-bzr) 28(require 'vc-bzr)
30(require 'vc-dir) 29(require 'vc-dir)
31 30
@@ -102,7 +101,7 @@
102 (while (vc-dir-busy) 101 (while (vc-dir-busy)
103 (sit-for 0.1)) 102 (sit-for 0.1))
104 (vc-dir-mark-all-files t) 103 (vc-dir-mark-all-files t)
105 (ert-with-function-mocked y-or-n-p (lambda (_) t) 104 (cl-letf (((symbol-function 'y-or-n-p) (lambda (_) t)))
106 (vc-next-action nil)) 105 (vc-next-action nil))
107 (should (get-buffer "*vc-log*"))) 106 (should (get-buffer "*vc-log*")))
108 (delete-directory homedir t)))) 107 (delete-directory homedir t))))
diff --git a/test/manual/cedet/tests/test.el b/test/manual/cedet/tests/test.el
index 0b8f9dee619..15517da0dc2 100644
--- a/test/manual/cedet/tests/test.el
+++ b/test/manual/cedet/tests/test.el
@@ -89,7 +89,7 @@
89(defconst a-defconst 'a "var doc const") 89(defconst a-defconst 'a "var doc const")
90 90
91(defcustom a-defcustom nil 91(defcustom a-defcustom nil
92 "*doc custom" 92 "doc custom"
93 :group 'a-defgroup 93 :group 'a-defgroup
94 :type 'boolean) 94 :type 'boolean)
95 95
diff --git a/test/src/callproc-tests.el b/test/src/callproc-tests.el
new file mode 100644
index 00000000000..46541aba78c
--- /dev/null
+++ b/test/src/callproc-tests.el
@@ -0,0 +1,39 @@
1;;; callproc-tests.el --- callproc.c tests -*- lexical-binding: t -*-
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;;; Code:
21
22(require 'ert)
23(eval-when-compile (require 'cl-lib))
24
25(ert-deftest initial-environment-preserved ()
26 "Check that `initial-environment' is not modified by Emacs (Bug #10980)."
27 (skip-unless (eq system-type 'windows-nt))
28 (cl-destructuring-bind (initial-shell shell)
29 (with-temp-buffer
30 (let ((process-environment (cons "SHELL" process-environment)))
31 (call-process (expand-file-name invocation-name invocation-directory)
32 nil t nil
33 "--batch" "-Q" "--eval"
34 (prin1-to-string
35 '(progn (prin1 (getenv-internal "SHELL" initial-environment))
36 (prin1 (getenv-internal "SHELL"))))))
37 (split-string-and-unquote (buffer-string)))
38 (should (equal initial-shell "nil"))
39 (should-not (equal initial-shell shell))))
diff --git a/test/src/chartab-tests.el b/test/src/chartab-tests.el
new file mode 100644
index 00000000000..016ddcdde61
--- /dev/null
+++ b/test/src/chartab-tests.el
@@ -0,0 +1,51 @@
1;;; chartab-tests.el --- Tests for char-tab.c
2
3;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5;; Author: Eli Zaretskii <eliz@gnu.org>
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
24(defun chartab-set-and-test (rng)
25 (let ((tbl (make-char-table nil nil))
26 (from (car rng))
27 (to (cdr rng)))
28 (set-char-table-range tbl rng t)
29 (should (eq (aref tbl from) t))
30 (should (eq (aref tbl to) t))
31 (should (eq (aref tbl (/ (+ from to) 2)) t))
32 (when (< to (max-char))
33 (should-not (eq (aref tbl (1+ to)) t)))
34 (when (> from 0)
35 (should-not (eq (aref tbl (1- from)) t)))))
36
37(ert-deftest chartab-test-range-setting ()
38 (mapc (lambda (elt)
39 (chartab-set-and-test elt))
40 '((0 . 127)
41 (128 . 256)
42 (#x1000 . #x1fff)
43 (#x1001 . #x2000)
44 (#x10000 . #x20000)
45 (#x10001 . #x1ffff)
46 (#x20000 . #x30000)
47 (#xe0e00 . #xe0ef6)
48 )))
49
50(provide 'chartab-tests)
51;;; chartab-tests.el ends here
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
new file mode 100644
index 00000000000..2f90d1e7495
--- /dev/null
+++ b/test/src/editfns-tests.el
@@ -0,0 +1,136 @@
1;;; editfns-tests.el -- tests for editfns.c
2
3;; Copyright (C) 2016 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 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
24(ert-deftest format-properties ()
25 ;; Bug #23730
26 (should (ert-equal-including-properties
27 (format (propertize "%d" 'face '(:background "red")) 1)
28 #("1" 0 1 (face (:background "red")))))
29 (should (ert-equal-including-properties
30 (format (propertize "%2d" 'face '(:background "red")) 1)
31 #(" 1" 0 2 (face (:background "red")))))
32 (should (ert-equal-including-properties
33 (format (propertize "%02d" 'face '(:background "red")) 1)
34 #("01" 0 2 (face (:background "red")))))
35 (should (ert-equal-including-properties
36 (format (concat (propertize "%2d" 'x 'X)
37 (propertize "a" 'a 'A)
38 (propertize "b" 'b 'B))
39 1)
40 #(" 1ab" 0 2 (x X) 2 3 (a A) 3 4 (b B))))
41
42 ;; Bug #5306
43 (should (ert-equal-including-properties
44 (format "%.10s"
45 (concat "1234567890aaaa"
46 (propertize "12345678901234567890" 'xxx 25)))
47 "1234567890"))
48 (should (ert-equal-including-properties
49 (format "%.10s"
50 (concat "123456789"
51 (propertize "12345678901234567890" 'xxx 25)))
52 #("1234567891" 9 10 (xxx 25))))
53
54 ;; Bug #23859
55 (should (ert-equal-including-properties
56 (format "%4s" (propertize "hi" 'face 'bold))
57 #(" hi" 2 4 (face bold))))
58
59 ;; Bug #23897
60 (should (ert-equal-including-properties
61 (format "%s" (concat (propertize "01234" 'face 'bold) "56789"))
62 #("0123456789" 0 5 (face bold))))
63 (should (ert-equal-including-properties
64 (format "%s" (concat (propertize "01" 'face 'bold)
65 (propertize "23" 'face 'underline)
66 "45"))
67 #("012345" 0 2 (face bold) 2 4 (face underline))))
68 ;; The last property range is extended to include padding on the
69 ;; right, but the first range is not extended to the left to include
70 ;; padding on the left!
71 (should (ert-equal-including-properties
72 (format "%12s" (concat (propertize "01234" 'face 'bold) "56789"))
73 #(" 0123456789" 2 7 (face bold))))
74 (should (ert-equal-including-properties
75 (format "%-12s" (concat (propertize "01234" 'face 'bold) "56789"))
76 #("0123456789 " 0 5 (face bold))))
77 (should (ert-equal-including-properties
78 (format "%10s" (concat (propertize "01" 'face 'bold)
79 (propertize "23" 'face 'underline)
80 "45"))
81 #(" 012345" 4 6 (face bold) 6 8 (face underline))))
82 (should (ert-equal-including-properties
83 (format "%-10s" (concat (propertize "01" 'face 'bold)
84 (propertize "23" 'face 'underline)
85 "45"))
86 #("012345 " 0 2 (face bold) 2 4 (face underline))))
87 (should (ert-equal-including-properties
88 (format "%-10s" (concat (propertize "01" 'face 'bold)
89 (propertize "23" 'face 'underline)
90 (propertize "45" 'face 'italic)))
91 #("012345 " 0 2 (face bold) 2 4 (face underline) 4 10 (face italic)))))
92
93;; Tests for bug#5131.
94(defun transpose-test-reverse-word (start end)
95 "Reverse characters in a word by transposing pairs of characters."
96 (let ((begm (make-marker))
97 (endm (make-marker)))
98 (set-marker begm start)
99 (set-marker endm end)
100 (while (> endm begm)
101 (progn (transpose-regions begm (1+ begm) endm (1+ endm) t)
102 (set-marker begm (1+ begm))
103 (set-marker endm (1- endm))))))
104
105(defun transpose-test-get-byte-positions (len)
106 "Validate character position to byte position translation."
107 (let ((bytes '()))
108 (dotimes (pos len)
109 (setq bytes (add-to-list 'bytes (position-bytes (1+ pos)) t)))
110 bytes))
111
112(ert-deftest transpose-ascii-regions-test ()
113 (with-temp-buffer
114 (erase-buffer)
115 (insert "abcd")
116 (transpose-test-reverse-word 1 4)
117 (should (string= (buffer-string) "dcba"))
118 (should (equal (transpose-test-get-byte-positions 5) '(1 2 3 4 5)))))
119
120(ert-deftest transpose-nonascii-regions-test-1 ()
121 (with-temp-buffer
122 (erase-buffer)
123 (insert "÷bcd")
124 (transpose-test-reverse-word 1 4)
125 (should (string= (buffer-string) "dcb÷"))
126 (should (equal (transpose-test-get-byte-positions 5) '(1 2 3 4 6)))))
127
128(ert-deftest transpose-nonascii-regions-test-2 ()
129 (with-temp-buffer
130 (erase-buffer)
131 (insert "÷ab\"äé")
132 (transpose-test-reverse-word 1 6)
133 (should (string= (buffer-string) "éä\"ba÷"))
134 (should (equal (transpose-test-get-byte-positions 7) '(1 3 5 6 7 8 10)))))
135
136;;; editfns-tests.el ends here
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index 848589692ea..c533bad3cdc 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -235,3 +235,13 @@
235 (backward-delete-char 1) 235 (backward-delete-char 1)
236 (buffer-hash)) 236 (buffer-hash))
237 (sha1 "foo")))) 237 (sha1 "foo"))))
238
239(ert-deftest fns-tests-mapcan ()
240 (should-error (mapcan))
241 (should-error (mapcan #'identity))
242 (should-error (mapcan #'identity (make-char-table 'foo)))
243 (should (equal (mapcan #'list '(1 2 3)) '(1 2 3)))
244 ;; `mapcan' is destructive
245 (let ((data '((foo) (bar))))
246 (should (equal (mapcan #'identity data) '(foo bar)))
247 (should (equal data '((foo bar) (bar))))))
diff --git a/test/src/regex-tests.el b/test/src/regex-tests.el
new file mode 100644
index 00000000000..00165ab0512
--- /dev/null
+++ b/test/src/regex-tests.el
@@ -0,0 +1,92 @@
1;;; regex-tests.el --- tests for regex.c functions -*- lexical-binding: t -*-
2
3;; Copyright (C) 2015-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;;; Code:
21
22(require 'ert)
23
24(ert-deftest regex-word-cc-fallback-test ()
25 "Test that ‘[[:cc:]]*x’ matches ‘x’ (bug#24020).
26
27Test that a regex of the form \"[[:cc:]]*x\" where CC is
28a character class which matches a multibyte character X, matches
29string \"x\".
30
31For example, ‘[[:word:]]*\u2620’ regex (note: \u2620 is a word
32character) must match a string \"\u2420\"."
33 (dolist (class '("[[:word:]]" "\\sw"))
34 (dolist (repeat '("*" "+"))
35 (dolist (suffix '("" "b" "bar" "\u2620"))
36 (dolist (string '("" "foo"))
37 (when (not (and (string-equal repeat "+")
38 (string-equal string "")))
39 (should (string-match (concat "^" class repeat suffix "$")
40 (concat string suffix)))))))))
41
42(defun regex--test-cc (name matching not-matching)
43 (should (string-match-p (concat "^[[:" name ":]]*$") matching))
44 (should (string-match-p (concat "^[[:" name ":]]*?\u2622$")
45 (concat matching "\u2622")))
46 (should (string-match-p (concat "^[^[:" name ":]]*$") not-matching))
47 (should (string-match-p (concat "^[^[:" name ":]]*\u2622$")
48 (concat not-matching "\u2622")))
49 (with-temp-buffer
50 (insert matching)
51 (let ((p (point)))
52 (insert not-matching)
53 (goto-char (point-min))
54 (skip-chars-forward (concat "[:" name ":]"))
55 (should (equal (point) p))
56 (skip-chars-forward (concat "^[:" name ":]"))
57 (should (equal (point) (point-max)))
58 (goto-char (point-min))
59 (skip-chars-forward (concat "[:" name ":]\u2622"))
60 (should (or (equal (point) p) (equal (point) (1+ p)))))))
61
62(ert-deftest regex-character-classes ()
63 "Perform sanity test of regexes using character classes.
64
65Go over all the supported character classes and test whether the
66classes and their inversions match what they are supposed to
67match. The test is done using `string-match-p' as well as
68`skip-chars-forward'."
69 (let (case-fold-search)
70 (regex--test-cc "alnum" "abcABC012łąka" "-, \t\n")
71 (regex--test-cc "alpha" "abcABCłąka" "-,012 \t\n")
72 (regex--test-cc "digit" "012" "abcABCłąka-, \t\n")
73 (regex--test-cc "xdigit" "0123aBc" "łąk-, \t\n")
74 (regex--test-cc "upper" "ABCŁĄKA" "abc012-, \t\n")
75 (regex--test-cc "lower" "abcłąka" "ABC012-, \t\n")
76
77 (regex--test-cc "word" "abcABC012\u2620" "-, \t\n")
78
79 (regex--test-cc "punct" ".,-" "abcABC012\u2620 \t\n")
80 (regex--test-cc "cntrl" "\1\2\t\n" ".,-abcABC012\u2620 ")
81 (regex--test-cc "graph" "abcłąka\u2620-," " \t\n\1")
82 (regex--test-cc "print" "abcłąka\u2620-, " "\t\n\1")
83
84 (regex--test-cc "space" " \t\n\u2001" "abcABCł0123")
85 (regex--test-cc "blank" " \t" "\n\u2001")
86
87 (regex--test-cc "ascii" "abcABC012 \t\n\1" "łą\u2620")
88 (regex--test-cc "nonascii" "łą\u2622" "abcABC012 \t\n\1")
89 (regex--test-cc "unibyte" "abcABC012 \t\n\1" "łą\u2622")
90 (regex--test-cc "multibyte" "łą\u2622" "abcABC012 \t\n\1")))
91
92;;; regex-tests.el ends here