diff options
| author | Tom Tromey | 2013-01-16 11:48:32 -0700 |
|---|---|---|
| committer | Tom Tromey | 2013-01-16 11:48:32 -0700 |
| commit | 6f4de085f065e11f4df3195d47479f28f5ef08ba (patch) | |
| tree | 1211a00f1afc86c2b73624897993db02a4852943 /test | |
| parent | e078a23febca14bc919c5806670479c395e3253e (diff) | |
| parent | ffe04adc88e546c406f9b050238fb98a7243c7a0 (diff) | |
| download | emacs-6f4de085f065e11f4df3195d47479f28f5ef08ba.tar.gz emacs-6f4de085f065e11f4df3195d47479f28f5ef08ba.zip | |
merge from trunk
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 21 | ||||
| -rw-r--r-- | test/automated/advice-tests.el | 191 | ||||
| -rw-r--r-- | test/automated/compile-tests.el | 4 | ||||
| -rw-r--r-- | test/automated/man-tests.el | 118 | ||||
| -rw-r--r-- | test/automated/undo-tests.el | 231 |
5 files changed, 478 insertions, 87 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 43c783857f3..7857000ba2f 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,24 @@ | |||
| 1 | 2013-01-15 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * automated/advice-tests.el: Split up. Add advice-test-preactivate. | ||
| 4 | |||
| 5 | 2013-01-14 Glenn Morris <rgm@gnu.org> | ||
| 6 | |||
| 7 | * automated/compile-tests.el (compile-tests--test-regexps-data): | ||
| 8 | Fix interpretation of gnu line.col1-col2 format. (Bug#13335) | ||
| 9 | |||
| 10 | 2013-01-10 Wolfgang Jenkner <wjenkner@inode.at> | ||
| 11 | |||
| 12 | * automated/man-tests.el: New file. | ||
| 13 | |||
| 14 | 2013-01-09 Aaron S. Hawley <aaron.s.hawley@gmail.com> | ||
| 15 | |||
| 16 | * automated/undo-tests.el (undo-test0): Adjust error to code change. | ||
| 17 | |||
| 18 | 2013-01-08 Aaron S. Hawley <aaron.s.hawley@gmail.com> | ||
| 19 | |||
| 20 | * automated/undo-tests.el: New file. | ||
| 21 | |||
| 1 | 2012-12-27 Dmitry Gutov <dgutov@yandex.ru> | 22 | 2012-12-27 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 23 | ||
| 3 | * automated/ruby-mode-tests.el | 24 | * automated/ruby-mode-tests.el |
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el index bc9135c92d0..8beaea64cd9 100644 --- a/test/automated/advice-tests.el +++ b/test/automated/advice-tests.el | |||
| @@ -21,93 +21,112 @@ | |||
| 21 | 21 | ||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (ert-deftest advice-tests () | 24 | (ert-deftest advice-tests-nadvice () |
| 25 | "Test nadvice code." | ||
| 26 | (defun sm-test1 (x) (+ x 4)) | ||
| 27 | (should (equal (sm-test1 6) 10)) | ||
| 28 | (advice-add 'sm-test1 :around (lambda (f y) (* (funcall f y) 5))) | ||
| 29 | (should (equal (sm-test1 6) 50)) | ||
| 30 | (defun sm-test1 (x) (+ x 14)) | ||
| 31 | (should (equal (sm-test1 6) 100)) | ||
| 32 | (should (equal (null (get 'sm-test1 'defalias-fset-function)) nil)) | ||
| 33 | (advice-remove 'sm-test1 (lambda (f y) (* (funcall f y) 5))) | ||
| 34 | (should (equal (sm-test1 6) 20)) | ||
| 35 | (should (equal (get 'sm-test1 'defalias-fset-function) nil)) | ||
| 36 | |||
| 37 | (advice-add 'sm-test3 :around | ||
| 38 | (lambda (f &rest args) `(toto ,(apply f args))) | ||
| 39 | '((name . wrap-with-toto))) | ||
| 40 | (defmacro sm-test3 (x) `(call-test3 ,x)) | ||
| 41 | (should (equal (macroexpand '(sm-test3 56)) '(toto (call-test3 56))))) | ||
| 42 | |||
| 43 | (ert-deftest advice-tests-advice () | ||
| 25 | "Test advice code." | 44 | "Test advice code." |
| 26 | (with-temp-buffer | 45 | (defun sm-test2 (x) (+ x 4)) |
| 27 | (defun sm-test1 (x) (+ x 4)) | 46 | (should (equal (sm-test2 6) 10)) |
| 28 | (should (equal (sm-test1 6) 10)) | 47 | (defadvice sm-test2 (around sm-test activate) |
| 29 | (advice-add 'sm-test1 :around (lambda (f y) (* (funcall f y) 5))) | 48 | ad-do-it (setq ad-return-value (* ad-return-value 5))) |
| 30 | (should (equal (sm-test1 6) 50)) | 49 | (should (equal (sm-test2 6) 50)) |
| 31 | (defun sm-test1 (x) (+ x 14)) | 50 | (ad-deactivate 'sm-test2) |
| 32 | (should (equal (sm-test1 6) 100)) | 51 | (should (equal (sm-test2 6) 10)) |
| 33 | (should (equal (null (get 'sm-test1 'defalias-fset-function)) nil)) | 52 | (ad-activate 'sm-test2) |
| 34 | (advice-remove 'sm-test1 (lambda (f y) (* (funcall f y) 5))) | 53 | (should (equal (sm-test2 6) 50)) |
| 35 | (should (equal (sm-test1 6) 20)) | 54 | (defun sm-test2 (x) (+ x 14)) |
| 36 | (should (equal (null (get 'sm-test1 'defalias-fset-function)) t)) | 55 | (should (equal (sm-test2 6) 100)) |
| 37 | 56 | (should (equal (null (get 'sm-test2 'defalias-fset-function)) nil)) | |
| 38 | (defun sm-test2 (x) (+ x 4)) | 57 | (ad-remove-advice 'sm-test2 'around 'sm-test) |
| 39 | (should (equal (sm-test2 6) 10)) | 58 | (should (equal (sm-test2 6) 100)) |
| 40 | (defadvice sm-test2 (around sm-test activate) | 59 | (ad-activate 'sm-test2) |
| 41 | ad-do-it (setq ad-return-value (* ad-return-value 5))) | 60 | (should (equal (sm-test2 6) 20)) |
| 42 | (should (equal (sm-test2 6) 50)) | 61 | (should (equal (null (get 'sm-test2 'defalias-fset-function)) t)) |
| 43 | (ad-deactivate 'sm-test2) | 62 | |
| 44 | (should (equal (sm-test2 6) 10)) | 63 | (defadvice sm-test4 (around wrap-with-toto activate) |
| 45 | (ad-activate 'sm-test2) | 64 | ad-do-it (setq ad-return-value `(toto ,ad-return-value))) |
| 46 | (should (equal (sm-test2 6) 50)) | 65 | (defmacro sm-test4 (x) `(call-test4 ,x)) |
| 47 | (defun sm-test2 (x) (+ x 14)) | 66 | (should (equal (macroexpand '(sm-test4 56)) '(toto (call-test4 56)))) |
| 48 | (should (equal (sm-test2 6) 100)) | 67 | (defmacro sm-test4 (x) `(call-testq ,x)) |
| 49 | (should (equal (null (get 'sm-test2 'defalias-fset-function)) nil)) | 68 | (should (equal (macroexpand '(sm-test4 56)) '(toto (call-testq 56)))) |
| 50 | (ad-remove-advice 'sm-test2 'around 'sm-test) | 69 | |
| 51 | (should (equal (sm-test2 6) 100)) | 70 | ;; This used to signal an error (bug#12858). |
| 52 | (ad-activate 'sm-test2) | 71 | (autoload 'sm-test6 "foo") |
| 53 | (should (equal (sm-test2 6) 20)) | 72 | (defadvice sm-test6 (around test activate) |
| 54 | (should (equal (null (get 'sm-test2 'defalias-fset-function)) t)) | 73 | ad-do-it)) |
| 55 | 74 | ||
| 56 | (advice-add 'sm-test3 :around | 75 | (ert-deftest advice-tests-combination () |
| 57 | (lambda (f &rest args) `(toto ,(apply f args))) | 76 | "Combining old style and new style advices." |
| 58 | '((name . wrap-with-toto))) | 77 | (defun sm-test5 (x) (+ x 4)) |
| 59 | (defmacro sm-test3 (x) `(call-test3 ,x)) | 78 | (should (equal (sm-test5 6) 10)) |
| 60 | (should (equal (macroexpand '(sm-test3 56)) '(toto (call-test3 56)))) | 79 | (advice-add 'sm-test5 :around (lambda (f y) (* (funcall f y) 5))) |
| 61 | 80 | (should (equal (sm-test5 6) 50)) | |
| 62 | (defadvice sm-test4 (around wrap-with-toto activate) | 81 | (defadvice sm-test5 (around test activate) |
| 63 | ad-do-it (setq ad-return-value `(toto ,ad-return-value))) | 82 | ad-do-it (setq ad-return-value (+ ad-return-value 0.1))) |
| 64 | (defmacro sm-test4 (x) `(call-test4 ,x)) | 83 | (should (equal (sm-test5 5) 45.1)) |
| 65 | (should (equal (macroexpand '(sm-test4 56)) '(toto (call-test4 56)))) | 84 | (ad-deactivate 'sm-test5) |
| 66 | (defmacro sm-test4 (x) `(call-testq ,x)) | 85 | (should (equal (sm-test5 6) 50)) |
| 67 | (should (equal (macroexpand '(sm-test4 56)) '(toto (call-testq 56)))) | 86 | (ad-activate 'sm-test5) |
| 68 | 87 | (should (equal (sm-test5 6) 50.1)) | |
| 69 | ;; Combining old style and new style advices. | 88 | (defun sm-test5 (x) (+ x 14)) |
| 70 | (defun sm-test5 (x) (+ x 4)) | 89 | (should (equal (sm-test5 6) 100.1)) |
| 71 | (should (equal (sm-test5 6) 10)) | 90 | (advice-remove 'sm-test5 (lambda (f y) (* (funcall f y) 5))) |
| 72 | (advice-add 'sm-test5 :around (lambda (f y) (* (funcall f y) 5))) | 91 | (should (equal (sm-test5 6) 20.1))) |
| 73 | (should (equal (sm-test5 6) 50)) | 92 | |
| 74 | (defadvice sm-test5 (around test activate) | 93 | (ert-deftest advice-test-called-interactively-p () |
| 75 | ad-do-it (setq ad-return-value (+ ad-return-value 0.1))) | 94 | "Check interaction between advice and called-interactively-p." |
| 76 | (should (equal (sm-test5 5) 45.1)) | 95 | (defun sm-test7 (&optional x) (interactive) (+ (or x 7) 4)) |
| 77 | (ad-deactivate 'sm-test5) | 96 | (advice-add 'sm-test7 :around |
| 78 | (should (equal (sm-test5 6) 50)) | 97 | (lambda (f &rest args) |
| 79 | (ad-activate 'sm-test5) | 98 | (list (cons 1 (called-interactively-p)) (apply f args)))) |
| 80 | (should (equal (sm-test5 6) 50.1)) | 99 | (should (equal (sm-test7) '((1 . nil) 11))) |
| 81 | (defun sm-test5 (x) (+ x 14)) | 100 | (should (equal (call-interactively 'sm-test7) '((1 . t) 11))) |
| 82 | (should (equal (sm-test5 6) 100.1)) | 101 | (let ((smi 7)) |
| 83 | (advice-remove 'sm-test5 (lambda (f y) (* (funcall f y) 5))) | 102 | (advice-add 'sm-test7 :before |
| 84 | (should (equal (sm-test5 6) 20.1)) | 103 | (lambda (&rest args) |
| 85 | 104 | (setq smi (called-interactively-p)))) | |
| 86 | ;; This used to signal an error (bug#12858). | 105 | (should (equal (list (sm-test7) smi) |
| 87 | (autoload 'sm-test6 "foo") | 106 | '(((1 . nil) 11) nil))) |
| 88 | (defadvice sm-test6 (around test activate) | 107 | (should (equal (list (call-interactively 'sm-test7) smi) |
| 89 | ad-do-it) | 108 | '(((1 . t) 11) t)))) |
| 90 | 109 | (advice-add 'sm-test7 :around | |
| 91 | ;; Check interaction between advice and called-interactively-p. | 110 | (lambda (f &rest args) |
| 92 | (defun sm-test7 (&optional x) (interactive) (+ (or x 7) 4)) | 111 | (cons (cons 2 (called-interactively-p)) (apply f args)))) |
| 93 | (advice-add 'sm-test7 :around | 112 | (should (equal (call-interactively 'sm-test7) '((2 . t) (1 . t) 11)))) |
| 94 | (lambda (f &rest args) | 113 | |
| 95 | (list (cons 1 (called-interactively-p)) (apply f args)))) | 114 | (ert-deftest advice-test-interactive () |
| 96 | (should (equal (sm-test7) '((1 . nil) 11))) | 115 | "Check handling of interactive spec." |
| 97 | (should (equal (call-interactively 'sm-test7) '((1 . t) 11))) | 116 | (defun sm-test8 (a) (interactive "p") a) |
| 98 | (let ((smi 7)) | 117 | (defadvice sm-test8 (before adv1 activate) nil) |
| 99 | (advice-add 'sm-test7 :before | 118 | (defadvice sm-test8 (before adv2 activate) (interactive "P") nil) |
| 100 | (lambda (&rest args) | 119 | (should (equal (interactive-form 'sm-test8) '(interactive "P")))) |
| 101 | (setq smi (called-interactively-p)))) | 120 | |
| 102 | (should (equal (list (sm-test7) smi) | 121 | (ert-deftest advice-test-preactivate () |
| 103 | '(((1 . nil) 11) nil))) | 122 | (should (equal (null (get 'sm-test9 'defalias-fset-function)) t)) |
| 104 | (should (equal (list (call-interactively 'sm-test7) smi) | 123 | (defun sm-test9 (a) (interactive "p") a) |
| 105 | '(((1 . t) 11) t)))) | 124 | (should (equal (null (get 'sm-test9 'defalias-fset-function)) t)) |
| 106 | (advice-add 'sm-test7 :around | 125 | (defadvice sm-test9 (before adv1 pre act protect compile) nil) |
| 107 | (lambda (f &rest args) | 126 | (should (equal (null (get 'sm-test9 'defalias-fset-function)) nil)) |
| 108 | (cons (cons 2 (called-interactively-p)) (apply f args)))) | 127 | (defadvice sm-test9 (before adv2 pre act protect compile) |
| 109 | (should (equal (call-interactively 'sm-test7) '((2 . t) (1 . t) 11))) | 128 | (interactive "P") nil) |
| 110 | )) | 129 | (should (equal (interactive-form 'sm-test9) '(interactive "P")))) |
| 111 | 130 | ||
| 112 | ;; Local Variables: | 131 | ;; Local Variables: |
| 113 | ;; no-byte-compile: t | 132 | ;; no-byte-compile: t |
diff --git a/test/automated/compile-tests.el b/test/automated/compile-tests.el index f976efe72de..682867d1178 100644 --- a/test/automated/compile-tests.el +++ b/test/automated/compile-tests.el | |||
| @@ -176,8 +176,10 @@ | |||
| 176 | ("foo.c:8.23: note: message" 1 23 8 "foo.c") | 176 | ("foo.c:8.23: note: message" 1 23 8 "foo.c") |
| 177 | ("foo.c:8.23: info: message" 1 23 8 "foo.c") | 177 | ("foo.c:8.23: info: message" 1 23 8 "foo.c") |
| 178 | ("foo.c:8:23:information: message" 1 23 8 "foo.c") | 178 | ("foo.c:8:23:information: message" 1 23 8 "foo.c") |
| 179 | ("foo.c:8.23-45: Informational: message" 1 (23 . nil) (8 . 45) "foo.c") | 179 | ("foo.c:8.23-45: Informational: message" 1 (23 . 46) (8 . nil) "foo.c") |
| 180 | ("foo.c:8-23: message" 1 nil (8 . 23) "foo.c") | 180 | ("foo.c:8-23: message" 1 nil (8 . 23) "foo.c") |
| 181 | ;; The next one is not in the GNU standards AFAICS. | ||
| 182 | ;; Here we seem to interpret it as LINE1-LINE2.COL2. | ||
| 181 | ("foo.c:8-45.3: message" 1 (nil . 4) (8 . 45) "foo.c") | 183 | ("foo.c:8-45.3: message" 1 (nil . 4) (8 . 45) "foo.c") |
| 182 | ("foo.c:8.23-9.1: message" 1 (23 . 2) (8 . 9) "foo.c") | 184 | ("foo.c:8.23-9.1: message" 1 (23 . 2) (8 . 9) "foo.c") |
| 183 | ("jade:dbcommon.dsl:133:17:E: missing argument for function call" | 185 | ("jade:dbcommon.dsl:133:17:E: missing argument for function call" |
diff --git a/test/automated/man-tests.el b/test/automated/man-tests.el new file mode 100644 index 00000000000..8a2ec953002 --- /dev/null +++ b/test/automated/man-tests.el | |||
| @@ -0,0 +1,118 @@ | |||
| 1 | ;;; man-tests.el --- Test suite for man. | ||
| 2 | |||
| 3 | ;; Copyright (C) 2013 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Wolfgang Jenkner <wjenkner@inode.at> | ||
| 6 | ;; Keywords: help, internal, unix | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Code: | ||
| 24 | |||
| 25 | (require 'ert) | ||
| 26 | (require 'man) | ||
| 27 | |||
| 28 | (defconst man-tests-parse-man-k-tests | ||
| 29 | '(;; GNU/Linux: man-db-2.6.1 | ||
| 30 | ("\ | ||
| 31 | sin (3) - sine function | ||
| 32 | sinf (3) - sine function | ||
| 33 | sinl (3) - sine function" | ||
| 34 | . (#("sin(3)" 0 6 (help-echo "sine function")) #("sinf(3)" 0 7 (help-echo "sine function")) #("sinl(3)" 0 7 (help-echo "sine function")))) | ||
| 35 | ;; GNU/Linux: man-1.6g | ||
| 36 | ("\ | ||
| 37 | sin (3) - sine function | ||
| 38 | sinf [sin] (3) - sine function | ||
| 39 | sinl [sin] (3) - sine function" | ||
| 40 | . (#("sin(3)" 0 6 (help-echo "sine function")) #("sinf(3)" 0 7 (help-echo "sine function")) #("sinl(3)" 0 7 (help-echo "sine function")))) | ||
| 41 | ;; FreeBSD 9 | ||
| 42 | ("\ | ||
| 43 | sin(3), sinf(3), sinl(3) - sine functions" | ||
| 44 | . (#("sin(3)" 0 6 (help-echo "sine functions")) #("sinf(3)" 0 7 (help-echo "sine functions")) #("sinl(3)" 0 7 (help-echo "sine functions")))) | ||
| 45 | ;; SunOS, Solaris | ||
| 46 | ;; http://docs.oracle.com/cd/E19455-01/805-6331/usradm-7/index.html | ||
| 47 | ;; SunOS 4 | ||
| 48 | ("\ | ||
| 49 | tset, reset (1) - establish or restore terminal characteristics" | ||
| 50 | . (#("tset(1)" 0 7 (help-echo "establish or restore terminal characteristics")) #("reset(1)" 0 8 (help-echo "establish or restore terminal characteristics")))) | ||
| 51 | ;; SunOS 5.7, Solaris | ||
| 52 | ("\ | ||
| 53 | reset tset (1b) - establish or restore terminal characteristics | ||
| 54 | tset tset (1b) - establish or restore terminal characteristics" | ||
| 55 | . (#("reset(1b)" 0 8 (help-echo "establish or restore terminal characteristics")) #("tset(1b)" 0 7 (help-echo "establish or restore terminal characteristics")))) | ||
| 56 | ;; Minix 3 | ||
| 57 | ;; http://www.minix3.org/manpages/html5/whatis.html | ||
| 58 | ("\ | ||
| 59 | cawf, nroff (1) - C version of the nroff-like, Amazingly Workable (text) Formatter | ||
| 60 | whatis (5) - database of online manual pages" | ||
| 61 | . (#("cawf(1)" 0 7 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("nroff(1)" 0 8 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("whatis(5)" 0 9 (help-echo "database of online manual pages")))) | ||
| 62 | ;; HP-UX | ||
| 63 | ;; http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/man.1.html | ||
| 64 | ;; Assuming that the line break in the zgrep description was | ||
| 65 | ;; introduced by the man page formatting. | ||
| 66 | ("\ | ||
| 67 | grep, egrep, fgrep (1) - search a file for a pattern | ||
| 68 | zgrep(1) - search possibly compressed files for a regular expression" | ||
| 69 | . (#("grep(1)" 0 7 (help-echo "search a file for a pattern")) #("egrep(1)" 0 8 (help-echo "search a file for a pattern")) #("fgrep(1)" 0 8 (help-echo "search a file for a pattern")) #("zgrep(1)" 0 8 (help-echo "search possibly compressed files for a regular expression")))) | ||
| 70 | ;; AIX | ||
| 71 | ;; http://pic.dhe.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.cmds/doc/aixcmds6/whatis.htm | ||
| 72 | ("\ | ||
| 73 | ls(1) -Displays the contents of a directory." | ||
| 74 | . (#("ls(1)" 0 5 (help-echo "Displays the contents of a directory.")))) | ||
| 75 | ;; https://www.ibm.com/developerworks/mydeveloperworks/blogs/cgaix/entry/catman_0703_102_usr_lbin_mkwhatis_the_error_number_is_1?lang=en | ||
| 76 | ("\ | ||
| 77 | loopmount(1) - Associate an image file to a loopback device." | ||
| 78 | . (#("loopmount(1)" 0 12 (help-echo "Associate an image file to a loopback device.")))) | ||
| 79 | ) | ||
| 80 | "List of tests for `Man-parse-man-k'. | ||
| 81 | Each element is a cons cell whose car is a string containing | ||
| 82 | man -k output. That should result in the table which is stored | ||
| 83 | in the cdr of the element.") | ||
| 84 | |||
| 85 | (defun man-tests-name-equal-p (name description string) | ||
| 86 | (and (equal name string) | ||
| 87 | (not (next-single-property-change 0 'help-echo string)) | ||
| 88 | (equal (get-text-property 0 'help-echo string) description))) | ||
| 89 | |||
| 90 | (defun man-tests-parse-man-k-test-case (test) | ||
| 91 | (let ((temp-buffer (get-buffer-create " *test-man*")) | ||
| 92 | (man-k-output (car test))) | ||
| 93 | (unwind-protect | ||
| 94 | (save-window-excursion | ||
| 95 | (with-current-buffer temp-buffer | ||
| 96 | (erase-buffer) | ||
| 97 | (insert man-k-output) | ||
| 98 | (let ((result (Man-parse-man-k)) | ||
| 99 | (checklist (cdr test))) | ||
| 100 | (while (and checklist result | ||
| 101 | (man-tests-name-equal-p | ||
| 102 | (car checklist) | ||
| 103 | (get-text-property 0 'help-echo | ||
| 104 | (car checklist)) | ||
| 105 | (pop result))) | ||
| 106 | (pop checklist)) | ||
| 107 | (and (null checklist) (null result))))) | ||
| 108 | (and (buffer-name temp-buffer) | ||
| 109 | (kill-buffer temp-buffer))))) | ||
| 110 | |||
| 111 | (ert-deftest man-tests () | ||
| 112 | "Test man." | ||
| 113 | (dolist (test man-tests-parse-man-k-tests) | ||
| 114 | (should (man-tests-parse-man-k-test-case test)))) | ||
| 115 | |||
| 116 | (provide 'man-tests) | ||
| 117 | |||
| 118 | ;;; man-tests.el ends here | ||
diff --git a/test/automated/undo-tests.el b/test/automated/undo-tests.el new file mode 100644 index 00000000000..3037db03602 --- /dev/null +++ b/test/automated/undo-tests.el | |||
| @@ -0,0 +1,231 @@ | |||
| 1 | ;;; undo-tests.el --- Tests of primitive-undo | ||
| 2 | |||
| 3 | ;; Copyright (C) 2012 Aaron S. Hawley | ||
| 4 | |||
| 5 | ;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com> | ||
| 6 | |||
| 7 | ;; This program is free software: you can redistribute it and/or | ||
| 8 | ;; modify it under the terms of the GNU General Public License as | ||
| 9 | ;; published by the Free Software Foundation, either version 3 of the | ||
| 10 | ;; License, or (at your option) any later version. | ||
| 11 | ;; | ||
| 12 | ;; This program is distributed in the hope that it will be useful, but | ||
| 13 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | ;; General Public License for more details. | ||
| 16 | ;; | ||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with this program. If not, see `http://www.gnu.org/licenses/'. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;; Profiling when the code was translate from C to Lisp on 2012-12-24. | ||
| 23 | |||
| 24 | ;;; C | ||
| 25 | |||
| 26 | ;; (elp-instrument-function 'primitive-undo) | ||
| 27 | ;; (load-file "undo-test.elc") | ||
| 28 | ;; (benchmark 100 '(let ((undo-test5-error nil)) (undo-test-all))) | ||
| 29 | ;; Elapsed time: 305.218000s (104.841000s in 14804 GCs) | ||
| 30 | ;; M-x elp-results | ||
| 31 | ;; Function Name Call Count Elapsed Time Average Time | ||
| 32 | ;; primitive-undo 2600 3.4889999999 0.0013419230 | ||
| 33 | |||
| 34 | ;;; Lisp | ||
| 35 | |||
| 36 | ;; (load-file "primundo.elc") | ||
| 37 | ;; (elp-instrument-function 'primitive-undo) | ||
| 38 | ;; (benchmark 100 '(undo-test-all)) | ||
| 39 | ;; Elapsed time: 295.974000s (104.582000s in 14704 GCs) | ||
| 40 | ;; M-x elp-results | ||
| 41 | ;; Function Name Call Count Elapsed Time Average Time | ||
| 42 | ;; primitive-undo 2700 3.6869999999 0.0013655555 | ||
| 43 | |||
| 44 | ;;; Code: | ||
| 45 | |||
| 46 | (require 'ert) | ||
| 47 | |||
| 48 | (ert-deftest undo-test0 () | ||
| 49 | "Test basics of \\[undo]." | ||
| 50 | (with-temp-buffer | ||
| 51 | (buffer-enable-undo) | ||
| 52 | (condition-case err | ||
| 53 | (undo) | ||
| 54 | (error | ||
| 55 | (unless (string= "No further undo information" | ||
| 56 | (cadr err)) | ||
| 57 | (error err)))) | ||
| 58 | (undo-boundary) | ||
| 59 | (insert "This") | ||
| 60 | (undo-boundary) | ||
| 61 | (erase-buffer) | ||
| 62 | (undo-boundary) | ||
| 63 | (insert "That") | ||
| 64 | (undo-boundary) | ||
| 65 | (forward-word -1) | ||
| 66 | (undo-boundary) | ||
| 67 | (insert "With ") | ||
| 68 | (undo-boundary) | ||
| 69 | (forward-word -1) | ||
| 70 | (undo-boundary) | ||
| 71 | (kill-word 1) | ||
| 72 | (undo-boundary) | ||
| 73 | (put-text-property (point-min) (point-max) 'face 'bold) | ||
| 74 | (undo-boundary) | ||
| 75 | (remove-text-properties (point-min) (point-max) '(face default)) | ||
| 76 | (undo-boundary) | ||
| 77 | (set-buffer-multibyte (not enable-multibyte-characters)) | ||
| 78 | (undo-boundary) | ||
| 79 | (undo) | ||
| 80 | (should | ||
| 81 | (equal (should-error (undo-more nil)) | ||
| 82 | '(wrong-type-argument number-or-marker-p nil))) | ||
| 83 | (undo-more 7) | ||
| 84 | (should (string-equal "" (buffer-string))))) | ||
| 85 | |||
| 86 | (ert-deftest undo-test1 () | ||
| 87 | "Test undo of \\[undo] command (redo)." | ||
| 88 | (with-temp-buffer | ||
| 89 | (buffer-enable-undo) | ||
| 90 | (undo-boundary) | ||
| 91 | (insert "This") | ||
| 92 | (undo-boundary) | ||
| 93 | (erase-buffer) | ||
| 94 | (undo-boundary) | ||
| 95 | (insert "That") | ||
| 96 | (undo-boundary) | ||
| 97 | (forward-word -1) | ||
| 98 | (undo-boundary) | ||
| 99 | (insert "With ") | ||
| 100 | (undo-boundary) | ||
| 101 | (forward-word -1) | ||
| 102 | (undo-boundary) | ||
| 103 | (kill-word 1) | ||
| 104 | (undo-boundary) | ||
| 105 | (facemenu-add-face 'bold (point-min) (point-max)) | ||
| 106 | (undo-boundary) | ||
| 107 | (set-buffer-multibyte (not enable-multibyte-characters)) | ||
| 108 | (undo-boundary) | ||
| 109 | (should | ||
| 110 | (string-equal (buffer-string) | ||
| 111 | (progn | ||
| 112 | (undo) | ||
| 113 | (undo-more 4) | ||
| 114 | (undo) | ||
| 115 | ;(undo-more -4) | ||
| 116 | (buffer-string)))))) | ||
| 117 | |||
| 118 | (ert-deftest undo-test2 () | ||
| 119 | "Test basic redoing with \\[undo] command." | ||
| 120 | (with-temp-buffer | ||
| 121 | (buffer-enable-undo) | ||
| 122 | (undo-boundary) | ||
| 123 | (insert "One") | ||
| 124 | (undo-boundary) | ||
| 125 | (insert " Zero") | ||
| 126 | (undo-boundary) | ||
| 127 | (push-mark) | ||
| 128 | (delete-region (save-excursion | ||
| 129 | (forward-word -1) | ||
| 130 | (point)) (point)) | ||
| 131 | (undo-boundary) | ||
| 132 | (beginning-of-line) | ||
| 133 | (insert "Zero") | ||
| 134 | (undo-boundary) | ||
| 135 | (undo) | ||
| 136 | (should | ||
| 137 | (string-equal (buffer-string) | ||
| 138 | (progn | ||
| 139 | (undo-more 2) | ||
| 140 | (undo) | ||
| 141 | (buffer-string)))))) | ||
| 142 | |||
| 143 | (ert-deftest undo-test3 () | ||
| 144 | "Test modtime with \\[undo] command." | ||
| 145 | (let ((tmpfile (make-temp-file "undo-test3"))) | ||
| 146 | (with-temp-file tmpfile | ||
| 147 | (let ((buffer-file-name tmpfile)) | ||
| 148 | (buffer-enable-undo) | ||
| 149 | (set (make-local-variable 'make-backup-files) nil) | ||
| 150 | (undo-boundary) | ||
| 151 | (insert ?\s) | ||
| 152 | (undo-boundary) | ||
| 153 | (basic-save-buffer) | ||
| 154 | (insert ?\t) | ||
| 155 | (undo) | ||
| 156 | (should | ||
| 157 | (string-equal (buffer-string) | ||
| 158 | (progn | ||
| 159 | (undo) | ||
| 160 | (buffer-string))))) | ||
| 161 | (delete-file tmpfile)))) | ||
| 162 | |||
| 163 | (ert-deftest undo-test4 () | ||
| 164 | "Test \\[undo] of \\[flush-lines]." | ||
| 165 | (with-temp-buffer | ||
| 166 | (buffer-enable-undo) | ||
| 167 | (dotimes (i 1048576) | ||
| 168 | (if (zerop (% i 2)) | ||
| 169 | (insert "Evenses") | ||
| 170 | (insert "Oddses"))) | ||
| 171 | (undo-boundary) | ||
| 172 | (should | ||
| 173 | ;; Avoid string-equal because ERT will save the `buffer-string' | ||
| 174 | ;; to the explanation. Using `not' will record nil or non-nil. | ||
| 175 | (not | ||
| 176 | (null | ||
| 177 | (string-equal (buffer-string) | ||
| 178 | (progn | ||
| 179 | (flush-lines "oddses" (point-min) (point-max)) | ||
| 180 | (undo-boundary) | ||
| 181 | (undo) | ||
| 182 | (undo) | ||
| 183 | (buffer-string)))))))) | ||
| 184 | |||
| 185 | (ert-deftest undo-test5 () | ||
| 186 | "Test basic redoing with \\[undo] command." | ||
| 187 | (with-temp-buffer | ||
| 188 | (buffer-enable-undo) | ||
| 189 | (undo-boundary) | ||
| 190 | (insert "AYE") | ||
| 191 | (undo-boundary) | ||
| 192 | (insert " BEE") | ||
| 193 | (undo-boundary) | ||
| 194 | (setq buffer-undo-list (cons '(0.0 bogus) buffer-undo-list)) | ||
| 195 | (push-mark) | ||
| 196 | (delete-region (save-excursion | ||
| 197 | (forward-word -1) | ||
| 198 | (point)) (point)) | ||
| 199 | (undo-boundary) | ||
| 200 | (beginning-of-line) | ||
| 201 | (insert "CEE") | ||
| 202 | (undo-boundary) | ||
| 203 | (undo) | ||
| 204 | (setq buffer-undo-list (cons "bogus" buffer-undo-list)) | ||
| 205 | (should | ||
| 206 | (string-equal | ||
| 207 | (buffer-string) | ||
| 208 | (progn | ||
| 209 | (if (and (boundp 'undo-test5-error) (not undo-test5-error)) | ||
| 210 | (progn | ||
| 211 | (should (null (undo-more 2))) | ||
| 212 | (should (undo))) | ||
| 213 | ;; Errors are generated by new Lisp version of | ||
| 214 | ;; `primitive-undo' not by built-in C version. | ||
| 215 | (should | ||
| 216 | (equal (should-error (undo-more 2)) | ||
| 217 | '(error "Unrecognized entry in undo list (0.0 bogus)"))) | ||
| 218 | (should | ||
| 219 | (equal (should-error (undo)) | ||
| 220 | '(error "Unrecognized entry in undo list \"bogus\"")))) | ||
| 221 | (buffer-string)))))) | ||
| 222 | |||
| 223 | (defun undo-test-all (&optional interactive) | ||
| 224 | "Run all tests for \\[undo]." | ||
| 225 | (interactive "p") | ||
| 226 | (if interactive | ||
| 227 | (ert-run-tests-interactively "^undo-") | ||
| 228 | (ert-run-tests-batch "^undo-"))) | ||
| 229 | |||
| 230 | (provide 'undo-tests) | ||
| 231 | ;;; undo-tests.el ends here | ||