aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEli Zaretskii2013-03-28 20:13:59 +0200
committerEli Zaretskii2013-03-28 20:13:59 +0200
commitd76bf86f438d4f5f9fe493ab76f02ffc78f3ae2e (patch)
tree04fa8bc7bd2058a316a7ee30f8741d25bfd0b060 /test
parent2ef26ceb192c7683754cf0b4aa3087f501254332 (diff)
parente74aeda863cd6896e06e92586f87b45d63d67d15 (diff)
downloademacs-d76bf86f438d4f5f9fe493ab76f02ffc78f3ae2e.tar.gz
emacs-d76bf86f438d4f5f9fe493ab76f02ffc78f3ae2e.zip
Merge from trunk and resolve conflicts.
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog109
-rw-r--r--test/automated/Makefile.in2
-rw-r--r--test/automated/advice-tests.el193
-rw-r--r--test/automated/bytecomp-tests.el2
-rw-r--r--test/automated/comint-testsuite.el2
-rw-r--r--test/automated/compile-tests.el6
-rw-r--r--test/automated/ert-tests.el2
-rw-r--r--test/automated/ert-x-tests.el2
-rw-r--r--test/automated/f90.el20
-rw-r--r--test/automated/files.el12
-rw-r--r--test/automated/font-parse-tests.el2
-rw-r--r--test/automated/gnus-tests.el2
-rw-r--r--test/automated/icalendar-tests.el2
-rw-r--r--test/automated/inotify-test.el60
-rw-r--r--test/automated/lexbind-tests.el2
-rw-r--r--test/automated/man-tests.el118
-rw-r--r--test/automated/newsticker-tests.el2
-rw-r--r--test/automated/occur-tests.el2
-rw-r--r--test/automated/python-tests.el2216
-rw-r--r--test/automated/ruby-mode-tests.el221
-rw-r--r--test/automated/thingatpt.el88
-rw-r--r--test/automated/undo-tests.el231
-rw-r--r--test/automated/url-future-tests.el2
-rw-r--r--test/automated/url-util-tests.el2
-rw-r--r--test/automated/vc-bzr.el2
-rw-r--r--test/automated/xml-parse-tests.el2
-rw-r--r--test/cedet/cedet-utests.el2
-rw-r--r--test/cedet/ede-tests.el2
-rw-r--r--test/cedet/semantic-ia-utest.el2
-rw-r--r--test/cedet/semantic-tests.el2
-rw-r--r--test/cedet/semantic-utest-c.el2
-rw-r--r--test/cedet/semantic-utest.el2
-rw-r--r--test/cedet/srecode-tests.el2
-rw-r--r--test/cedet/tests/test.c2
-rw-r--r--test/cedet/tests/test.el2
-rw-r--r--test/cedet/tests/test.make2
-rw-r--r--test/cedet/tests/testdoublens.cpp2
-rw-r--r--test/cedet/tests/testdoublens.hpp2
-rw-r--r--test/cedet/tests/testjavacomp.java2
-rw-r--r--test/cedet/tests/testpolymorph.cpp2
-rw-r--r--test/cedet/tests/testspp.c2
-rw-r--r--test/cedet/tests/testsppreplace.c2
-rw-r--r--test/cedet/tests/testsppreplaced.c2
-rw-r--r--test/cedet/tests/testsubclass.cpp2
-rw-r--r--test/cedet/tests/testsubclass.hh2
-rw-r--r--test/cedet/tests/testtypedefs.cpp2
-rw-r--r--test/cedet/tests/testvarnames.c2
-rw-r--r--test/eshell.el2
-rw-r--r--test/indent/octave.m4
-rw-r--r--test/indent/pascal.pas8
-rwxr-xr-xtest/indent/shell.sh12
-rw-r--r--test/redisplay-testsuite.el2
-rw-r--r--test/rmailmm.el2
53 files changed, 3187 insertions, 189 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index b66c2925287..43648ad1bb1 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,110 @@
12013-03-05 Paul Eggert <eggert@cs.ucla.edu>
2
3 * indent/octave.m: Fix encoding error in comment. Add coding tag.
4
52013-02-28 Fabián Ezequiel Gallina <fgallina@cuca>
6
7 * automated/python-tests.el (python-tests-with-temp-buffer): Doc fix.
8 (python-tests-with-temp-file): New macro.
9 (python-tests-shell-interpreter): New var.
10 (python-shell-get-process-name-1)
11 (python-shell-internal-get-process-name-1)
12 (python-shell-parse-command-1)
13 (python-shell-calculate-process-environment-1)
14 (python-shell-calculate-process-environment-2)
15 (python-shell-calculate-process-environment-3)
16 (python-shell-calculate-exec-path-1)
17 (python-shell-calculate-exec-path-2)
18 (python-shell-make-comint-1)
19 (python-shell-make-comint-2)
20 (python-shell-get-process-1)
21 (python-shell-get-or-create-process-1)
22 (python-shell-internal-get-or-create-process-1): New tests.
23
242013-02-21 Fabián Ezequiel Gallina <fgallina@cuca>
25
26 * automated/python-tests.el: New file.
27
282013-02-14 Dmitry Gutov <dgutov@yandex.ru>
29
30 * automated/ruby-mode-tests.el
31 (ruby-move-to-block-skips-percent-literal): Add depth-affecting
32 bits inside the examples.
33 (ruby-move-to-block-skips-heredoc): New test.
34 (ruby-add-log-current-method-after-inner-class): Lower
35 expectations: move point inside a method, initially.
36
372013-02-13 Dmitry Gutov <dgutov@yandex.ru>
38
39 * automated/ruby-mode-tests.el
40 (ruby-move-to-block-skips-percent-literal): New test.
41
422013-02-04 Chong Yidong <cyd@gnu.org>
43
44 * automated/thingatpt.el: New file.
45
462013-02-03 Chong Yidong <cyd@gnu.org>
47
48 * automated/files.el (file-test--do-local-variables-test): Avoid
49 compilation warning message.
50
512013-01-27 Dmitry Gutov <dgutov@yandex.ru>
52
53 * automated/ruby-mode-tests.el
54 (ruby-indent-spread-args-in-parens): New test.
55 * automated/ruby-mode-tests.el (ruby-block-test-example):
56 Break indentation of the do block opener and add a line inside it.
57 * automated/ruby-mode-tests.el (works-on-do, ok-with-three):
58 Adjust line numbers.
59
602013-01-15 Stefan Monnier <monnier@iro.umontreal.ca>
61
62 * automated/advice-tests.el: Split up. Add advice-test-preactivate.
63
642013-01-14 Glenn Morris <rgm@gnu.org>
65
66 * automated/compile-tests.el (compile-tests--test-regexps-data):
67 Fix interpretation of gnu line.col1-col2 format. (Bug#13335)
68
692013-01-10 Wolfgang Jenkner <wjenkner@inode.at>
70
71 * automated/man-tests.el: New file.
72
732013-01-09 Aaron S. Hawley <aaron.s.hawley@gmail.com>
74
75 * automated/undo-tests.el (undo-test0): Adjust error to code change.
76
772013-01-08 Aaron S. Hawley <aaron.s.hawley@gmail.com>
78
79 * automated/undo-tests.el: New file.
80
812012-12-27 Dmitry Gutov <dgutov@yandex.ru>
82
83 * automated/ruby-mode-tests.el
84 (ruby-indent-after-block-in-continued-expression): New test.
85
862012-12-14 Dmitry Gutov <dgutov@yandex.ru>
87
88 * automated/ruby-mode-tests.el
89 Rename one interpolation test; add three more.
90 (ruby-with-temp-buffer): New macro, use it where appropriate.
91 (ruby-add-log-current-method-examples): Use "_" for target point.
92 Add four new tests for ruby-add-log-current-method.
93
942012-12-11 Glenn Morris <rgm@gnu.org>
95
96 * automated/f90.el (f90-test-bug13138): New test.
97
982012-12-10 Rüdiger Sonderfeld <ruediger@c-plusplus.de>
99
100 * automated/inotify-test.el: New test.
101
1022012-12-02 Chong Yidong <cyd@gnu.org>
103
104 * automated/ruby-mode-tests.el
105 (ruby-add-log-current-method-examples): Don't use loop macro, to
106 allow automated testing to work.
107
12012-11-20 Stefan Monnier <monnier@iro.umontreal.ca> 1082012-11-20 Stefan Monnier <monnier@iro.umontreal.ca>
2 109
3 * automated/advice-tests.el (advice-tests--data): Remove. 110 * automated/advice-tests.el (advice-tests--data): Remove.
@@ -557,7 +664,7 @@
557;; coding: utf-8 664;; coding: utf-8
558;; End: 665;; End:
559 666
560 Copyright (C) 2008-2012 Free Software Foundation, Inc. 667 Copyright (C) 2008-2013 Free Software Foundation, Inc.
561 668
562 This file is part of GNU Emacs. 669 This file is part of GNU Emacs.
563 670
diff --git a/test/automated/Makefile.in b/test/automated/Makefile.in
index 5f92e21d91a..1a4e3c9b1ea 100644
--- a/test/automated/Makefile.in
+++ b/test/automated/Makefile.in
@@ -1,5 +1,5 @@
1# Maintenance productions for the automated test directory 1# Maintenance productions for the automated test directory
2# Copyright (C) 2010-2012 Free Software Foundation, Inc. 2# Copyright (C) 2010-2013 Free Software Foundation, Inc.
3 3
4# This file is part of GNU Emacs. 4# This file is part of GNU Emacs.
5 5
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el
index 94f69e77e43..8beaea64cd9 100644
--- a/test/automated/advice-tests.el
+++ b/test/automated/advice-tests.el
@@ -1,6 +1,6 @@
1;;; advice-tests.el --- Test suite for the new advice thingy. 1;;; advice-tests.el --- Test suite for the new advice thingy.
2 2
3;; Copyright (C) 2012 Free Software Foundation, Inc. 3;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
@@ -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/bytecomp-tests.el b/test/automated/bytecomp-tests.el
index b7ec79fd51c..96e4bed5fd0 100644
--- a/test/automated/bytecomp-tests.el
+++ b/test/automated/bytecomp-tests.el
@@ -1,6 +1,6 @@
1;;; bytecomp-testsuite.el 1;;; bytecomp-testsuite.el
2 2
3;; Copyright (C) 2008-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
4 4
5;; Author: Shigeru Fukaya <shigeru.fukaya@gmail.com> 5;; Author: Shigeru Fukaya <shigeru.fukaya@gmail.com>
6;; Created: November 2008 6;; Created: November 2008
diff --git a/test/automated/comint-testsuite.el b/test/automated/comint-testsuite.el
index 7317c107d59..dd3ebb03d2a 100644
--- a/test/automated/comint-testsuite.el
+++ b/test/automated/comint-testsuite.el
@@ -1,6 +1,6 @@
1;;; comint-testsuite.el 1;;; comint-testsuite.el
2 2
3;; Copyright (C) 2010-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
diff --git a/test/automated/compile-tests.el b/test/automated/compile-tests.el
index 9415ee3a17e..682867d1178 100644
--- a/test/automated/compile-tests.el
+++ b/test/automated/compile-tests.el
@@ -1,6 +1,6 @@
1;;; compile-tests.el --- Test suite for font parsing. 1;;; compile-tests.el --- Test suite for font parsing.
2 2
3;; Copyright (C) 2011-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5;; Author: Chong Yidong <cyd@stupidchicken.com> 5;; Author: Chong Yidong <cyd@stupidchicken.com>
6;; Keywords: internal 6;; Keywords: internal
@@ -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/ert-tests.el b/test/automated/ert-tests.el
index 1aef1921871..0c3c3692c1d 100644
--- a/test/automated/ert-tests.el
+++ b/test/automated/ert-tests.el
@@ -1,6 +1,6 @@
1;;; ert-tests.el --- ERT's self-tests -*- lexical-binding: t -*- 1;;; ert-tests.el --- ERT's self-tests -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2007-2008, 2010-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2007-2008, 2010-2013 Free Software Foundation, Inc.
4 4
5;; Author: Christian Ohler <ohler@gnu.org> 5;; Author: Christian Ohler <ohler@gnu.org>
6 6
diff --git a/test/automated/ert-x-tests.el b/test/automated/ert-x-tests.el
index e03c8475442..dc67fe34833 100644
--- a/test/automated/ert-x-tests.el
+++ b/test/automated/ert-x-tests.el
@@ -1,6 +1,6 @@
1;;; ert-x-tests.el --- Tests for ert-x.el 1;;; ert-x-tests.el --- Tests for ert-x.el
2 2
3;; Copyright (C) 2008, 2010-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc.
4 4
5;; Author: Phil Hagelberg 5;; Author: Phil Hagelberg
6;; Christian Ohler <ohler@gnu.org> 6;; Christian Ohler <ohler@gnu.org>
diff --git a/test/automated/f90.el b/test/automated/f90.el
index 25b77f07ad3..dd627605df6 100644
--- a/test/automated/f90.el
+++ b/test/automated/f90.el
@@ -1,6 +1,6 @@
1;;; f90.el --- tests for progmodes/f90.el 1;;; f90.el --- tests for progmodes/f90.el
2 2
3;; Copyright (C) 2011-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5;; Author: Glenn Morris <rgm@gnu.org> 5;; Author: Glenn Morris <rgm@gnu.org>
6 6
@@ -154,5 +154,23 @@ end module modname")
154 (f90-indent-line) 154 (f90-indent-line)
155 (should (= 0 (current-indentation))))) 155 (should (= 0 (current-indentation)))))
156 156
157(ert-deftest f90-test-bug13138 ()
158 "Test for http://debbugs.gnu.org/13138 ."
159 (with-temp-buffer
160 (f90-mode)
161 (insert "program prog
162 integer :: i = &
163#ifdef foo
164 & 1
165#else
166 & 2
167#endif
168
169 write(*,*) i
170end program prog")
171 (goto-char (point-min))
172 (forward-line 2)
173 (f90-indent-subprogram)
174 (should (= 0 (current-indentation)))))
157 175
158;;; f90.el ends here 176;;; f90.el ends here
diff --git a/test/automated/files.el b/test/automated/files.el
index b6011395bfd..f2d2192a420 100644
--- a/test/automated/files.el
+++ b/test/automated/files.el
@@ -1,6 +1,6 @@
1;;; files.el --- tests for file handling. 1;;; files.el --- tests for file handling.
2 2
3;; Copyright (C) 2012 Free Software Foundation, Inc. 3;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
@@ -23,9 +23,9 @@
23 23
24;; Set to t if the local variable was set, `query' if the query was 24;; Set to t if the local variable was set, `query' if the query was
25;; triggered. 25;; triggered.
26(defvar files-test-result) 26(defvar files-test-result nil)
27 27
28(defvar files-test-safe-result) 28(defvar files-test-safe-result nil)
29(put 'files-test-safe-result 'safe-local-variable 'booleanp) 29(put 'files-test-safe-result 'safe-local-variable 'booleanp)
30 30
31(defun files-test-fun1 () 31(defun files-test-fun1 ()
@@ -123,11 +123,11 @@ form.")
123(defun file-test--do-local-variables-test (str test-settings) 123(defun file-test--do-local-variables-test (str test-settings)
124 (with-temp-buffer 124 (with-temp-buffer
125 (insert str) 125 (insert str)
126 (setq files-test-result nil
127 files-test-safe-result nil)
126 (let ((enable-local-variables (nth 0 test-settings)) 128 (let ((enable-local-variables (nth 0 test-settings))
127 (enable-local-eval (nth 1 test-settings)) 129 (enable-local-eval (nth 1 test-settings))
128 (files-test-result nil) 130 (files-test-queried nil))
129 (files-test-queried nil)
130 (files-test-safe-result nil))
131 (hack-local-variables) 131 (hack-local-variables)
132 (eval (nth 2 test-settings))))) 132 (eval (nth 2 test-settings)))))
133 133
diff --git a/test/automated/font-parse-tests.el b/test/automated/font-parse-tests.el
index 6aeaee4adce..3a216a2b715 100644
--- a/test/automated/font-parse-tests.el
+++ b/test/automated/font-parse-tests.el
@@ -1,6 +1,6 @@
1;;; font-parse-tests.el --- Test suite for font parsing. 1;;; font-parse-tests.el --- Test suite for font parsing.
2 2
3;; Copyright (C) 2011-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5;; Author: Chong Yidong <cyd@stupidchicken.com> 5;; Author: Chong Yidong <cyd@stupidchicken.com>
6;; Keywords: internal 6;; Keywords: internal
diff --git a/test/automated/gnus-tests.el b/test/automated/gnus-tests.el
index 3b5340bcdd3..a27075b53f1 100644
--- a/test/automated/gnus-tests.el
+++ b/test/automated/gnus-tests.el
@@ -1,6 +1,6 @@
1;;; gnus-tests.el --- Wrapper for the Gnus tests 1;;; gnus-tests.el --- Wrapper for the Gnus tests
2 2
3;; Copyright (C) 2011-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5;; Author: Teodor Zlatanov <tzz@lifelogs.com> 5;; Author: Teodor Zlatanov <tzz@lifelogs.com>
6 6
diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el
index 58b8379bb11..bca462da4d9 100644
--- a/test/automated/icalendar-tests.el
+++ b/test/automated/icalendar-tests.el
@@ -1,6 +1,6 @@
1;; icalendar-tests.el --- Test suite for icalendar.el 1;; icalendar-tests.el --- Test suite for icalendar.el
2 2
3;; Copyright (C) 2005, 2008-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2005, 2008-2013 Free Software Foundation, Inc.
4 4
5;; Author: Ulf Jasper <ulf.jasper@web.de> 5;; Author: Ulf Jasper <ulf.jasper@web.de>
6;; Created: March 2005 6;; Created: March 2005
diff --git a/test/automated/inotify-test.el b/test/automated/inotify-test.el
new file mode 100644
index 00000000000..175f262b282
--- /dev/null
+++ b/test/automated/inotify-test.el
@@ -0,0 +1,60 @@
1;;; inotify-tests.el --- Test suite for inotify. -*- lexical-binding: t -*-
2
3;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
4
5;; Author: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
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
28(when (featurep 'inotify)
29
30 ;; (ert-deftest filewatch-file-watch-aspects-check ()
31 ;; "Test whether `file-watch' properly checks the aspects."
32 ;; (let ((temp-file (make-temp-file "filewatch-aspects")))
33 ;; (should (stringp temp-file))
34 ;; (should-error (file-watch temp-file 'wrong nil)
35 ;; :type 'error)
36 ;; (should-error (file-watch temp-file '(modify t) nil)
37 ;; :type 'error)
38 ;; (should-error (file-watch temp-file '(modify all-modify) nil)
39 ;; :type 'error)
40 ;; (should-error (file-watch temp-file '(access wrong modify) nil)
41 ;; :type 'error)))
42
43 (ert-deftest inotify-file-watch-simple ()
44 "Test if watching a normal file works."
45 (let ((temp-file (make-temp-file "inotify-simple"))
46 (events 0))
47 (let ((wd
48 (inotify-add-watch temp-file t (lambda (ev)
49 (setq events (1+ events))))))
50 (unwind-protect
51 (progn
52 (with-temp-file temp-file
53 (insert "Foo\n"))
54 (sit-for 5) ;; Hacky. Wait for 5s until events are processed
55 (should (> events 0)))
56 (inotify-rm-watch wd)))))
57)
58
59(provide 'inotify-tests)
60;;; inotify-tests.el ends here.
diff --git a/test/automated/lexbind-tests.el b/test/automated/lexbind-tests.el
index 22668bc7d02..0fed946182e 100644
--- a/test/automated/lexbind-tests.el
+++ b/test/automated/lexbind-tests.el
@@ -1,6 +1,6 @@
1;;; lexbind-tests.el --- Testing the lexbind byte-compiler 1;;; lexbind-tests.el --- Testing the lexbind byte-compiler
2 2
3;; Copyright (C) 2011-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5;; Author: Stefan Monnier <monnier@iro.umontreal.ca> 5;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6;; Keywords: 6;; Keywords:
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 ("\
31sin (3) - sine function
32sinf (3) - sine function
33sinl (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 ("\
37sin (3) - sine function
38sinf [sin] (3) - sine function
39sinl [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 ("\
43sin(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 ("\
49tset, 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 ("\
53reset tset (1b) - establish or restore terminal characteristics
54tset 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 ("\
59cawf, nroff (1) - C version of the nroff-like, Amazingly Workable (text) Formatter
60whatis (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 ("\
67grep, egrep, fgrep (1) - search a file for a pattern
68zgrep(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 ("\
73ls(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 ("\
77loopmount(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'.
81Each element is a cons cell whose car is a string containing
82man -k output. That should result in the table which is stored
83in 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/newsticker-tests.el b/test/automated/newsticker-tests.el
index 5b60535e463..4fe656e6929 100644
--- a/test/automated/newsticker-tests.el
+++ b/test/automated/newsticker-tests.el
@@ -1,6 +1,6 @@
1;;; newsticker-testsuite.el --- Test suite for newsticker. 1;;; newsticker-testsuite.el --- Test suite for newsticker.
2 2
3;; Copyright (C) 2003-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2003-2013 Free Software Foundation, Inc.
4 4
5;; Author: Ulf Jasper <ulf.jasper@web.de> 5;; Author: Ulf Jasper <ulf.jasper@web.de>
6;; Keywords: News, RSS, Atom 6;; Keywords: News, RSS, Atom
diff --git a/test/automated/occur-tests.el b/test/automated/occur-tests.el
index 5fe9722d4e7..7cc4df6bffa 100644
--- a/test/automated/occur-tests.el
+++ b/test/automated/occur-tests.el
@@ -1,6 +1,6 @@
1;;; occur-tests.el --- Test suite for occur. 1;;; occur-tests.el --- Test suite for occur.
2 2
3;; Copyright (C) 2010-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
4 4
5;; Author: Juri Linkov <juri@jurta.org> 5;; Author: Juri Linkov <juri@jurta.org>
6;; Keywords: matching, internal 6;; Keywords: matching, internal
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
new file mode 100644
index 00000000000..ab8eb4816d3
--- /dev/null
+++ b/test/automated/python-tests.el
@@ -0,0 +1,2216 @@
1;;; python-tests.el --- Test suite for python.el
2
3;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;;; Code:
23
24(require 'python)
25
26(defmacro python-tests-with-temp-buffer (contents &rest body)
27 "Create a `python-mode' enabled temp buffer with CONTENTS.
28BODY is code to be executed within the temp buffer. Point is
29always located at the beginning of buffer."
30 (declare (indent 1) (debug t))
31 `(with-temp-buffer
32 (python-mode)
33 (insert ,contents)
34 (goto-char (point-min))
35 ,@body))
36
37(defmacro python-tests-with-temp-file (contents &rest body)
38 "Create a `python-mode' enabled file with CONTENTS.
39BODY is code to be executed within the temp buffer. Point is
40always located at the beginning of buffer."
41 (declare (indent 1) (debug t))
42 `(let* ((temp-file (concat (make-temp-file "python-tests") ".py"))
43 (buffer (find-file-noselect temp-file)))
44 (unwind-protect
45 (with-current-buffer buffer
46 (python-mode)
47 (insert ,contents)
48 (goto-char (point-min))
49 ,@body)
50 (and buffer (kill-buffer buffer)))))
51
52(defun python-tests-look-at (string &optional num restore-point)
53 "Move point at beginning of STRING in the current buffer.
54Optional argument NUM defaults to 1 and is an integer indicating
55how many occurrences must be found, when positive the search is
56done forwards, otherwise backwards. When RESTORE-POINT is
57non-nil the point is not moved but the position found is still
58returned. When searching forward and point is already looking at
59STRING, it is skipped so the next STRING occurrence is selected."
60 (let* ((num (or num 1))
61 (starting-point (point))
62 (string (regexp-quote string))
63 (search-fn (if (> num 0) #'re-search-forward #'re-search-backward))
64 (deinc-fn (if (> num 0) #'1- #'1+))
65 (found-point))
66 (prog2
67 (catch 'exit
68 (while (not (= num 0))
69 (when (and (> num 0)
70 (looking-at string))
71 ;; Moving forward and already looking at STRING, skip it.
72 (forward-char (length (match-string-no-properties 0))))
73 (and (not (funcall search-fn string nil t))
74 (throw 'exit t))
75 (when (> num 0)
76 ;; `re-search-forward' leaves point at the end of the
77 ;; occurrence, move back so point is at the beginning
78 ;; instead.
79 (forward-char (- (length (match-string-no-properties 0)))))
80 (setq
81 num (funcall deinc-fn num)
82 found-point (point))))
83 found-point
84 (and restore-point (goto-char starting-point)))))
85
86
87;;; Tests for your tests, so you can test while you test.
88
89(ert-deftest python-tests-look-at-1 ()
90 "Test forward movement."
91 (python-tests-with-temp-buffer
92 "Lorem ipsum dolor sit amet, consectetur adipisicing elit,
93sed do eiusmod tempor incididunt ut labore et dolore magna
94aliqua."
95 (let ((expected (save-excursion
96 (dotimes (i 3)
97 (re-search-forward "et" nil t))
98 (forward-char -2)
99 (point))))
100 (should (= (python-tests-look-at "et" 3 t) expected))
101 ;; Even if NUM is bigger than found occurrences the point of last
102 ;; one should be returned.
103 (should (= (python-tests-look-at "et" 6 t) expected))
104 ;; If already looking at STRING, it should skip it.
105 (dotimes (i 2) (re-search-forward "et"))
106 (forward-char -2)
107 (should (= (python-tests-look-at "et") expected)))))
108
109(ert-deftest python-tests-look-at-2 ()
110 "Test backward movement."
111 (python-tests-with-temp-buffer
112 "Lorem ipsum dolor sit amet, consectetur adipisicing elit,
113sed do eiusmod tempor incididunt ut labore et dolore magna
114aliqua."
115 (let ((expected
116 (save-excursion
117 (re-search-forward "et" nil t)
118 (forward-char -2)
119 (point))))
120 (dotimes (i 3)
121 (re-search-forward "et" nil t))
122 (should (= (python-tests-look-at "et" -3 t) expected))
123 (should (= (python-tests-look-at "et" -6 t) expected)))))
124
125
126;;; Bindings
127
128
129;;; Python specialized rx
130
131
132;;; Font-lock and syntax
133
134
135;;; Indentation
136
137;; See: http://www.python.org/dev/peps/pep-0008/#indentation
138
139(ert-deftest python-indent-pep8-1 ()
140 "First pep8 case."
141 (python-tests-with-temp-buffer
142 "# Aligned with opening delimiter
143foo = long_function_name(var_one, var_two,
144 var_three, var_four)
145"
146 (should (eq (car (python-indent-context)) 'no-indent))
147 (should (= (python-indent-calculate-indentation) 0))
148 (python-tests-look-at "foo = long_function_name(var_one, var_two,")
149 (should (eq (car (python-indent-context)) 'after-line))
150 (should (= (python-indent-calculate-indentation) 0))
151 (python-tests-look-at "var_three, var_four)")
152 (should (eq (car (python-indent-context)) 'inside-paren))
153 (should (= (python-indent-calculate-indentation) 25))))
154
155(ert-deftest python-indent-pep8-2 ()
156 "Second pep8 case."
157 (python-tests-with-temp-buffer
158 "# More indentation included to distinguish this from the rest.
159def long_function_name(
160 var_one, var_two, var_three,
161 var_four):
162 print (var_one)
163"
164 (should (eq (car (python-indent-context)) 'no-indent))
165 (should (= (python-indent-calculate-indentation) 0))
166 (python-tests-look-at "def long_function_name(")
167 (should (eq (car (python-indent-context)) 'after-line))
168 (should (= (python-indent-calculate-indentation) 0))
169 (python-tests-look-at "var_one, var_two, var_three,")
170 (should (eq (car (python-indent-context)) 'inside-paren))
171 (should (= (python-indent-calculate-indentation) 8))
172 (python-tests-look-at "var_four):")
173 (should (eq (car (python-indent-context)) 'inside-paren))
174 (should (= (python-indent-calculate-indentation) 8))
175 (python-tests-look-at "print (var_one)")
176 (should (eq (car (python-indent-context)) 'after-beginning-of-block))
177 (should (= (python-indent-calculate-indentation) 4))))
178
179(ert-deftest python-indent-pep8-3 ()
180 "Third pep8 case."
181 (python-tests-with-temp-buffer
182 "# Extra indentation is not necessary.
183foo = long_function_name(
184 var_one, var_two,
185 var_three, var_four)
186"
187 (should (eq (car (python-indent-context)) 'no-indent))
188 (should (= (python-indent-calculate-indentation) 0))
189 (python-tests-look-at "foo = long_function_name(")
190 (should (eq (car (python-indent-context)) 'after-line))
191 (should (= (python-indent-calculate-indentation) 0))
192 (python-tests-look-at "var_one, var_two,")
193 (should (eq (car (python-indent-context)) 'inside-paren))
194 (should (= (python-indent-calculate-indentation) 4))
195 (python-tests-look-at "var_three, var_four)")
196 (should (eq (car (python-indent-context)) 'inside-paren))
197 (should (= (python-indent-calculate-indentation) 4))))
198
199(ert-deftest python-indent-inside-paren-1 ()
200 "The most simple inside-paren case that shouldn't fail."
201 (python-tests-with-temp-buffer
202 "
203data = {
204 'key':
205 {
206 'objlist': [
207 {
208 'pk': 1,
209 'name': 'first',
210 },
211 {
212 'pk': 2,
213 'name': 'second',
214 }
215 ]
216 }
217}
218"
219 (python-tests-look-at "data = {")
220 (should (eq (car (python-indent-context)) 'after-line))
221 (should (= (python-indent-calculate-indentation) 0))
222 (python-tests-look-at "'key':")
223 (should (eq (car (python-indent-context)) 'inside-paren))
224 (should (= (python-indent-calculate-indentation) 4))
225 (python-tests-look-at "{")
226 (should (eq (car (python-indent-context)) 'inside-paren))
227 (should (= (python-indent-calculate-indentation) 4))
228 (python-tests-look-at "'objlist': [")
229 (should (eq (car (python-indent-context)) 'inside-paren))
230 (should (= (python-indent-calculate-indentation) 8))
231 (python-tests-look-at "{")
232 (should (eq (car (python-indent-context)) 'inside-paren))
233 (should (= (python-indent-calculate-indentation) 12))
234 (python-tests-look-at "'pk': 1,")
235 (should (eq (car (python-indent-context)) 'inside-paren))
236 (should (= (python-indent-calculate-indentation) 16))
237 (python-tests-look-at "'name': 'first',")
238 (should (eq (car (python-indent-context)) 'inside-paren))
239 (should (= (python-indent-calculate-indentation) 16))
240 (python-tests-look-at "},")
241 (should (eq (car (python-indent-context)) 'inside-paren))
242 (should (= (python-indent-calculate-indentation) 12))
243 (python-tests-look-at "{")
244 (should (eq (car (python-indent-context)) 'inside-paren))
245 (should (= (python-indent-calculate-indentation) 12))
246 (python-tests-look-at "'pk': 2,")
247 (should (eq (car (python-indent-context)) 'inside-paren))
248 (should (= (python-indent-calculate-indentation) 16))
249 (python-tests-look-at "'name': 'second',")
250 (should (eq (car (python-indent-context)) 'inside-paren))
251 (should (= (python-indent-calculate-indentation) 16))
252 (python-tests-look-at "}")
253 (should (eq (car (python-indent-context)) 'inside-paren))
254 (should (= (python-indent-calculate-indentation) 12))
255 (python-tests-look-at "]")
256 (should (eq (car (python-indent-context)) 'inside-paren))
257 (should (= (python-indent-calculate-indentation) 8))
258 (python-tests-look-at "}")
259 (should (eq (car (python-indent-context)) 'inside-paren))
260 (should (= (python-indent-calculate-indentation) 4))
261 (python-tests-look-at "}")
262 (should (eq (car (python-indent-context)) 'inside-paren))
263 (should (= (python-indent-calculate-indentation) 0))))
264
265(ert-deftest python-indent-inside-paren-2 ()
266 "Another more compact paren group style."
267 (python-tests-with-temp-buffer
268 "
269data = {'key': {
270 'objlist': [
271 {'pk': 1,
272 'name': 'first'},
273 {'pk': 2,
274 'name': 'second'}
275 ]
276}}
277"
278 (python-tests-look-at "data = {")
279 (should (eq (car (python-indent-context)) 'after-line))
280 (should (= (python-indent-calculate-indentation) 0))
281 (python-tests-look-at "'objlist': [")
282 (should (eq (car (python-indent-context)) 'inside-paren))
283 (should (= (python-indent-calculate-indentation) 4))
284 (python-tests-look-at "{'pk': 1,")
285 (should (eq (car (python-indent-context)) 'inside-paren))
286 (should (= (python-indent-calculate-indentation) 8))
287 (python-tests-look-at "'name': 'first'},")
288 (should (eq (car (python-indent-context)) 'inside-paren))
289 (should (= (python-indent-calculate-indentation) 9))
290 (python-tests-look-at "{'pk': 2,")
291 (should (eq (car (python-indent-context)) 'inside-paren))
292 (should (= (python-indent-calculate-indentation) 8))
293 (python-tests-look-at "'name': 'second'}")
294 (should (eq (car (python-indent-context)) 'inside-paren))
295 (should (= (python-indent-calculate-indentation) 9))
296 (python-tests-look-at "]")
297 (should (eq (car (python-indent-context)) 'inside-paren))
298 (should (= (python-indent-calculate-indentation) 4))
299 (python-tests-look-at "}}")
300 (should (eq (car (python-indent-context)) 'inside-paren))
301 (should (= (python-indent-calculate-indentation) 0))
302 (python-tests-look-at "}")
303 (should (eq (car (python-indent-context)) 'inside-paren))
304 (should (= (python-indent-calculate-indentation) 0))))
305
306(ert-deftest python-indent-after-block-1 ()
307 "The most simple after-block case that shouldn't fail."
308 (python-tests-with-temp-buffer
309 "
310def foo(a, b, c=True):
311"
312 (should (eq (car (python-indent-context)) 'no-indent))
313 (should (= (python-indent-calculate-indentation) 0))
314 (goto-char (point-max))
315 (should (eq (car (python-indent-context)) 'after-beginning-of-block))
316 (should (= (python-indent-calculate-indentation) 4))))
317
318(ert-deftest python-indent-after-block-2 ()
319 "A weird (malformed) multiline block statement."
320 (python-tests-with-temp-buffer
321 "
322def foo(a, b, c={
323 'a':
324}):
325"
326 (goto-char (point-max))
327 (should (eq (car (python-indent-context)) 'after-beginning-of-block))
328 (should (= (python-indent-calculate-indentation) 4))))
329
330(ert-deftest python-indent-dedenters-1 ()
331 "Check all dedenters."
332 (python-tests-with-temp-buffer
333 "
334def foo(a, b, c):
335 if a:
336 print (a)
337 elif b:
338 print (b)
339 else:
340 try:
341 print (c.pop())
342 except (IndexError, AttributeError):
343 print (c)
344 finally:
345 print ('nor a, nor b are true')
346"
347 (python-tests-look-at "if a:")
348 (should (eq (car (python-indent-context)) 'after-beginning-of-block))
349 (should (= (python-indent-calculate-indentation) 4))
350 (python-tests-look-at "print (a)")
351 (should (eq (car (python-indent-context)) 'after-beginning-of-block))
352 (should (= (python-indent-calculate-indentation) 8))
353 (python-tests-look-at "elif b:")
354 (should (eq (car (python-indent-context)) 'after-line))
355 (should (= (python-indent-calculate-indentation) 4))
356 (python-tests-look-at "print (b)")
357 (should (eq (car (python-indent-context)) 'after-beginning-of-block))
358 (should (= (python-indent-calculate-indentation) 8))
359 (python-tests-look-at "else:")
360 (should (eq (car (python-indent-context)) 'after-line))
361 (should (= (python-indent-calculate-indentation) 4))
362 (python-tests-look-at "try:")
363 (should (eq (car (python-indent-context)) 'after-beginning-of-block))
364 (should (= (python-indent-calculate-indentation) 8))
365 (python-tests-look-at "print (c.pop())")
366 (should (eq (car (python-indent-context)) 'after-beginning-of-block))
367 (should (= (python-indent-calculate-indentation) 12))
368 (python-tests-look-at "except (IndexError, AttributeError):")
369 (should (eq (car (python-indent-context)) 'after-line))
370 (should (= (python-indent-calculate-indentation) 8))
371 (python-tests-look-at "print (c)")
372 (should (eq (car (python-indent-context)) 'after-beginning-of-block))
373 (should (= (python-indent-calculate-indentation) 12))
374 (python-tests-look-at "finally:")
375 (should (eq (car (python-indent-context)) 'after-line))
376 (should (= (python-indent-calculate-indentation) 8))
377 (python-tests-look-at "print ('nor a, nor b are true')")
378 (should (eq (car (python-indent-context)) 'after-beginning-of-block))
379 (should (= (python-indent-calculate-indentation) 12))))
380
381(ert-deftest python-indent-after-backslash-1 ()
382 "The most common case."
383 (python-tests-with-temp-buffer
384 "
385from foo.bar.baz import something, something_1 \\\\
386 something_2 something_3, \\\\
387 something_4, something_5
388"
389 (python-tests-look-at "from foo.bar.baz import something, something_1")
390 (should (eq (car (python-indent-context)) 'after-line))
391 (should (= (python-indent-calculate-indentation) 0))
392 (python-tests-look-at "something_2 something_3,")
393 (should (eq (car (python-indent-context)) 'after-backslash))
394 (should (= (python-indent-calculate-indentation) 4))
395 (python-tests-look-at "something_4, something_5")
396 (should (eq (car (python-indent-context)) 'after-backslash))
397 (should (= (python-indent-calculate-indentation) 4))
398 (goto-char (point-max))
399 (should (eq (car (python-indent-context)) 'after-line))
400 (should (= (python-indent-calculate-indentation) 0))))
401
402(ert-deftest python-indent-after-backslash-2 ()
403 "A pretty extreme complicated case."
404 (python-tests-with-temp-buffer
405 "
406objects = Thing.objects.all() \\\\
407 .filter(
408 type='toy',
409 status='bought'
410 ) \\\\
411 .aggregate(
412 Sum('amount')
413 ) \\\\
414 .values_list()
415"
416 (python-tests-look-at "objects = Thing.objects.all()")
417 (should (eq (car (python-indent-context)) 'after-line))
418 (should (= (python-indent-calculate-indentation) 0))
419 (python-tests-look-at ".filter(")
420 (should (eq (car (python-indent-context)) 'after-backslash))
421 (should (= (python-indent-calculate-indentation) 23))
422 (python-tests-look-at "type='toy',")
423 (should (eq (car (python-indent-context)) 'inside-paren))
424 (should (= (python-indent-calculate-indentation) 27))
425 (python-tests-look-at "status='bought'")
426 (should (eq (car (python-indent-context)) 'inside-paren))
427 (should (= (python-indent-calculate-indentation) 27))
428 (python-tests-look-at ") \\\\")
429 (should (eq (car (python-indent-context)) 'inside-paren))
430 (should (= (python-indent-calculate-indentation) 23))
431 (python-tests-look-at ".aggregate(")
432 (should (eq (car (python-indent-context)) 'after-backslash))
433 (should (= (python-indent-calculate-indentation) 23))
434 (python-tests-look-at "Sum('amount')")
435 (should (eq (car (python-indent-context)) 'inside-paren))
436 (should (= (python-indent-calculate-indentation) 27))
437 (python-tests-look-at ") \\\\")
438 (should (eq (car (python-indent-context)) 'inside-paren))
439 (should (= (python-indent-calculate-indentation) 23))
440 (python-tests-look-at ".values_list()")
441 (should (eq (car (python-indent-context)) 'after-backslash))
442 (should (= (python-indent-calculate-indentation) 23))
443 (forward-line 1)
444 (should (eq (car (python-indent-context)) 'after-line))
445 (should (= (python-indent-calculate-indentation) 0))))
446
447
448;;; Navigation
449
450(ert-deftest python-nav-beginning-of-defun-1 ()
451 (python-tests-with-temp-buffer
452 "
453def decoratorFunctionWithArguments(arg1, arg2, arg3):
454 '''print decorated function call data to stdout.
455
456 Usage:
457
458 @decoratorFunctionWithArguments('arg1', 'arg2')
459 def func(a, b, c=True):
460 pass
461 '''
462
463 def wwrap(f):
464 print 'Inside wwrap()'
465 def wrapped_f(*args):
466 print 'Inside wrapped_f()'
467 print 'Decorator arguments:', arg1, arg2, arg3
468 f(*args)
469 print 'After f(*args)'
470 return wrapped_f
471 return wwrap
472"
473 (python-tests-look-at "return wrap")
474 (should (= (save-excursion
475 (python-nav-beginning-of-defun)
476 (point))
477 (save-excursion
478 (python-tests-look-at "def wrapped_f(*args):" -1)
479 (beginning-of-line)
480 (point))))
481 (python-tests-look-at "def wrapped_f(*args):" -1)
482 (should (= (save-excursion
483 (python-nav-beginning-of-defun)
484 (point))
485 (save-excursion
486 (python-tests-look-at "def wwrap(f):" -1)
487 (beginning-of-line)
488 (point))))
489 (python-tests-look-at "def wwrap(f):" -1)
490 (should (= (save-excursion
491 (python-nav-beginning-of-defun)
492 (point))
493 (save-excursion
494 (python-tests-look-at "def decoratorFunctionWithArguments" -1)
495 (beginning-of-line)
496 (point))))))
497
498(ert-deftest python-nav-beginning-of-defun-2 ()
499 (python-tests-with-temp-buffer
500 "
501class C(object):
502
503 def m(self):
504 self.c()
505
506 def b():
507 pass
508
509 def a():
510 pass
511
512 def c(self):
513 pass
514"
515 ;; Nested defuns, are handled with care.
516 (python-tests-look-at "def c(self):")
517 (should (= (save-excursion
518 (python-nav-beginning-of-defun)
519 (point))
520 (save-excursion
521 (python-tests-look-at "def m(self):" -1)
522 (beginning-of-line)
523 (point))))
524 ;; Defuns on same levels should be respected.
525 (python-tests-look-at "def a():" -1)
526 (should (= (save-excursion
527 (python-nav-beginning-of-defun)
528 (point))
529 (save-excursion
530 (python-tests-look-at "def b():" -1)
531 (beginning-of-line)
532 (point))))
533 ;; Jump to a top level defun.
534 (python-tests-look-at "def b():" -1)
535 (should (= (save-excursion
536 (python-nav-beginning-of-defun)
537 (point))
538 (save-excursion
539 (python-tests-look-at "def m(self):" -1)
540 (beginning-of-line)
541 (point))))
542 ;; Jump to a top level defun again.
543 (python-tests-look-at "def m(self):" -1)
544 (should (= (save-excursion
545 (python-nav-beginning-of-defun)
546 (point))
547 (save-excursion
548 (python-tests-look-at "class C(object):" -1)
549 (beginning-of-line)
550 (point))))))
551
552(ert-deftest python-nav-end-of-defun-1 ()
553 (python-tests-with-temp-buffer
554 "
555class C(object):
556
557 def m(self):
558 self.c()
559
560 def b():
561 pass
562
563 def a():
564 pass
565
566 def c(self):
567 pass
568"
569 (should (= (save-excursion
570 (python-tests-look-at "class C(object):")
571 (python-nav-end-of-defun)
572 (point))
573 (save-excursion
574 (point-max))))
575 (should (= (save-excursion
576 (python-tests-look-at "def m(self):")
577 (python-nav-end-of-defun)
578 (point))
579 (save-excursion
580 (python-tests-look-at "def c(self):")
581 (forward-line -1)
582 (point))))
583 (should (= (save-excursion
584 (python-tests-look-at "def b():")
585 (python-nav-end-of-defun)
586 (point))
587 (save-excursion
588 (python-tests-look-at "def b():")
589 (forward-line 2)
590 (point))))
591 (should (= (save-excursion
592 (python-tests-look-at "def c(self):")
593 (python-nav-end-of-defun)
594 (point))
595 (save-excursion
596 (point-max))))))
597
598(ert-deftest python-nav-end-of-defun-2 ()
599 (python-tests-with-temp-buffer
600 "
601def decoratorFunctionWithArguments(arg1, arg2, arg3):
602 '''print decorated function call data to stdout.
603
604 Usage:
605
606 @decoratorFunctionWithArguments('arg1', 'arg2')
607 def func(a, b, c=True):
608 pass
609 '''
610
611 def wwrap(f):
612 print 'Inside wwrap()'
613 def wrapped_f(*args):
614 print 'Inside wrapped_f()'
615 print 'Decorator arguments:', arg1, arg2, arg3
616 f(*args)
617 print 'After f(*args)'
618 return wrapped_f
619 return wwrap
620"
621 (should (= (save-excursion
622 (python-tests-look-at "def decoratorFunctionWithArguments")
623 (python-nav-end-of-defun)
624 (point))
625 (save-excursion
626 (point-max))))
627 (should (= (save-excursion
628 (python-tests-look-at "@decoratorFunctionWithArguments")
629 (python-nav-end-of-defun)
630 (point))
631 (save-excursion
632 (point-max))))
633 (should (= (save-excursion
634 (python-tests-look-at "def wwrap(f):")
635 (python-nav-end-of-defun)
636 (point))
637 (save-excursion
638 (python-tests-look-at "return wwrap")
639 (line-beginning-position))))
640 (should (= (save-excursion
641 (python-tests-look-at "def wrapped_f(*args):")
642 (python-nav-end-of-defun)
643 (point))
644 (save-excursion
645 (python-tests-look-at "return wrapped_f")
646 (line-beginning-position))))
647 (should (= (save-excursion
648 (python-tests-look-at "f(*args)")
649 (python-nav-end-of-defun)
650 (point))
651 (save-excursion
652 (python-tests-look-at "return wrapped_f")
653 (line-beginning-position))))))
654
655
656(ert-deftest python-nav-beginning-of-statement-1 ()
657 (python-tests-with-temp-buffer
658 "
659v1 = 123 + \
660 456 + \
661 789
662v2 = (value1,
663 value2,
664
665 value3,
666 value4)
667v3 = ('this is a string'
668
669 'that is continued'
670 'between lines'
671 'within a paren',
672 # this is a comment, yo
673 'continue previous line')
674v4 = '''
675a very long
676string
677'''
678"
679 (python-tests-look-at "v2 =")
680 (python-util-forward-comment -1)
681 (should (= (save-excursion
682 (python-nav-beginning-of-statement)
683 (point))
684 (python-tests-look-at "v1 =" -1 t)))
685 (python-tests-look-at "v3 =")
686 (python-util-forward-comment -1)
687 (should (= (save-excursion
688 (python-nav-beginning-of-statement)
689 (point))
690 (python-tests-look-at "v2 =" -1 t)))
691 (python-tests-look-at "v4 =")
692 (python-util-forward-comment -1)
693 (should (= (save-excursion
694 (python-nav-beginning-of-statement)
695 (point))
696 (python-tests-look-at "v3 =" -1 t)))
697 (goto-char (point-max))
698 (python-util-forward-comment -1)
699 (should (= (save-excursion
700 (python-nav-beginning-of-statement)
701 (point))
702 (python-tests-look-at "v4 =" -1 t)))))
703
704(ert-deftest python-nav-end-of-statement-1 ()
705 (python-tests-with-temp-buffer
706 "
707v1 = 123 + \
708 456 + \
709 789
710v2 = (value1,
711 value2,
712
713 value3,
714 value4)
715v3 = ('this is a string'
716
717 'that is continued'
718 'between lines'
719 'within a paren',
720 # this is a comment, yo
721 'continue previous line')
722v4 = '''
723a very long
724string
725'''
726"
727 (python-tests-look-at "v1 =")
728 (should (= (save-excursion
729 (python-nav-end-of-statement)
730 (point))
731 (save-excursion
732 (python-tests-look-at "789")
733 (line-end-position))))
734 (python-tests-look-at "v2 =")
735 (should (= (save-excursion
736 (python-nav-end-of-statement)
737 (point))
738 (save-excursion
739 (python-tests-look-at "value4)")
740 (line-end-position))))
741 (python-tests-look-at "v3 =")
742 (should (= (save-excursion
743 (python-nav-end-of-statement)
744 (point))
745 (save-excursion
746 (python-tests-look-at
747 "'continue previous line')")
748 (line-end-position))))
749 (python-tests-look-at "v4 =")
750 (should (= (save-excursion
751 (python-nav-end-of-statement)
752 (point))
753 (save-excursion
754 (goto-char (point-max))
755 (python-util-forward-comment -1)
756 (point))))))
757
758(ert-deftest python-nav-forward-statement-1 ()
759 (python-tests-with-temp-buffer
760 "
761v1 = 123 + \
762 456 + \
763 789
764v2 = (value1,
765 value2,
766
767 value3,
768 value4)
769v3 = ('this is a string'
770
771 'that is continued'
772 'between lines'
773 'within a paren',
774 # this is a comment, yo
775 'continue previous line')
776v4 = '''
777a very long
778string
779'''
780"
781 (python-tests-look-at "v1 =")
782 (should (= (save-excursion
783 (python-nav-forward-statement)
784 (point))
785 (python-tests-look-at "v2 =")))
786 (should (= (save-excursion
787 (python-nav-forward-statement)
788 (point))
789 (python-tests-look-at "v3 =")))
790 (should (= (save-excursion
791 (python-nav-forward-statement)
792 (point))
793 (python-tests-look-at "v4 =")))
794 (should (= (save-excursion
795 (python-nav-forward-statement)
796 (point))
797 (point-max)))))
798
799(ert-deftest python-nav-backward-statement-1 ()
800 (python-tests-with-temp-buffer
801 "
802v1 = 123 + \
803 456 + \
804 789
805v2 = (value1,
806 value2,
807
808 value3,
809 value4)
810v3 = ('this is a string'
811
812 'that is continued'
813 'between lines'
814 'within a paren',
815 # this is a comment, yo
816 'continue previous line')
817v4 = '''
818a very long
819string
820'''
821"
822 (goto-char (point-max))
823 (should (= (save-excursion
824 (python-nav-backward-statement)
825 (point))
826 (python-tests-look-at "v4 =" -1)))
827 (should (= (save-excursion
828 (python-nav-backward-statement)
829 (point))
830 (python-tests-look-at "v3 =" -1)))
831 (should (= (save-excursion
832 (python-nav-backward-statement)
833 (point))
834 (python-tests-look-at "v2 =" -1)))
835 (should (= (save-excursion
836 (python-nav-backward-statement)
837 (point))
838 (python-tests-look-at "v1 =" -1)))))
839
840(ert-deftest python-nav-backward-statement-2 ()
841 :expected-result :failed
842 (python-tests-with-temp-buffer
843 "
844v1 = 123 + \
845 456 + \
846 789
847v2 = (value1,
848 value2,
849
850 value3,
851 value4)
852"
853 ;; FIXME: For some reason `python-nav-backward-statement' is moving
854 ;; back two sentences when starting from 'value4)'.
855 (goto-char (point-max))
856 (python-util-forward-comment -1)
857 (should (= (save-excursion
858 (python-nav-backward-statement)
859 (point))
860 (python-tests-look-at "v2 =" -1 t)))))
861
862(ert-deftest python-nav-beginning-of-block-1 ()
863 (python-tests-with-temp-buffer
864 "
865def decoratorFunctionWithArguments(arg1, arg2, arg3):
866 '''print decorated function call data to stdout.
867
868 Usage:
869
870 @decoratorFunctionWithArguments('arg1', 'arg2')
871 def func(a, b, c=True):
872 pass
873 '''
874
875 def wwrap(f):
876 print 'Inside wwrap()'
877 def wrapped_f(*args):
878 print 'Inside wrapped_f()'
879 print 'Decorator arguments:', arg1, arg2, arg3
880 f(*args)
881 print 'After f(*args)'
882 return wrapped_f
883 return wwrap
884"
885 (python-tests-look-at "return wwrap")
886 (should (= (save-excursion
887 (python-nav-beginning-of-block)
888 (point))
889 (python-tests-look-at "def decoratorFunctionWithArguments" -1)))
890 (python-tests-look-at "print 'Inside wwrap()'")
891 (should (= (save-excursion
892 (python-nav-beginning-of-block)
893 (point))
894 (python-tests-look-at "def wwrap(f):" -1)))
895 (python-tests-look-at "print 'After f(*args)'")
896 (end-of-line)
897 (should (= (save-excursion
898 (python-nav-beginning-of-block)
899 (point))
900 (python-tests-look-at "def wrapped_f(*args):" -1)))
901 (python-tests-look-at "return wrapped_f")
902 (should (= (save-excursion
903 (python-nav-beginning-of-block)
904 (point))
905 (python-tests-look-at "def wwrap(f):" -1)))))
906
907(ert-deftest python-nav-end-of-block-1 ()
908 (python-tests-with-temp-buffer
909 "
910def decoratorFunctionWithArguments(arg1, arg2, arg3):
911 '''print decorated function call data to stdout.
912
913 Usage:
914
915 @decoratorFunctionWithArguments('arg1', 'arg2')
916 def func(a, b, c=True):
917 pass
918 '''
919
920 def wwrap(f):
921 print 'Inside wwrap()'
922 def wrapped_f(*args):
923 print 'Inside wrapped_f()'
924 print 'Decorator arguments:', arg1, arg2, arg3
925 f(*args)
926 print 'After f(*args)'
927 return wrapped_f
928 return wwrap
929"
930 (python-tests-look-at "def decoratorFunctionWithArguments")
931 (should (= (save-excursion
932 (python-nav-end-of-block)
933 (point))
934 (save-excursion
935 (goto-char (point-max))
936 (python-util-forward-comment -1)
937 (point))))
938 (python-tests-look-at "def wwrap(f):")
939 (should (= (save-excursion
940 (python-nav-end-of-block)
941 (point))
942 (save-excursion
943 (python-tests-look-at "return wrapped_f")
944 (line-end-position))))
945 (end-of-line)
946 (should (= (save-excursion
947 (python-nav-end-of-block)
948 (point))
949 (save-excursion
950 (python-tests-look-at "return wrapped_f")
951 (line-end-position))))
952 (python-tests-look-at "f(*args)")
953 (should (= (save-excursion
954 (python-nav-end-of-block)
955 (point))
956 (save-excursion
957 (python-tests-look-at "print 'After f(*args)'")
958 (line-end-position))))))
959
960(ert-deftest python-nav-forward-block-1 ()
961 "This also accounts as a test for `python-nav-backward-block'."
962 (python-tests-with-temp-buffer
963 "
964if request.user.is_authenticated():
965 # def block():
966 # pass
967 try:
968 profile = request.user.get_profile()
969 except Profile.DoesNotExist:
970 profile = Profile.objects.create(user=request.user)
971 else:
972 if profile.stats:
973 profile.recalculate_stats()
974 else:
975 profile.clear_stats()
976 finally:
977 profile.views += 1
978 profile.save()
979"
980 (should (= (save-excursion (python-nav-forward-block))
981 (python-tests-look-at "if request.user.is_authenticated():")))
982 (should (= (save-excursion (python-nav-forward-block))
983 (python-tests-look-at "try:")))
984 (should (= (save-excursion (python-nav-forward-block))
985 (python-tests-look-at "except Profile.DoesNotExist:")))
986 (should (= (save-excursion (python-nav-forward-block))
987 (python-tests-look-at "else:")))
988 (should (= (save-excursion (python-nav-forward-block))
989 (python-tests-look-at "if profile.stats:")))
990 (should (= (save-excursion (python-nav-forward-block))
991 (python-tests-look-at "else:")))
992 (should (= (save-excursion (python-nav-forward-block))
993 (python-tests-look-at "finally:")))
994 ;; When point is at the last block, leave it there and return nil
995 (should (not (save-excursion (python-nav-forward-block))))
996 ;; Move backwards, and even if the number of moves is less than the
997 ;; provided argument return the point.
998 (should (= (save-excursion (python-nav-forward-block -10))
999 (python-tests-look-at
1000 "if request.user.is_authenticated():" -1)))))
1001
1002(ert-deftest python-nav-lisp-forward-sexp-safe-1 ()
1003 (python-tests-with-temp-buffer
1004 "
1005profile = Profile.objects.create(user=request.user)
1006profile.notify()
1007"
1008 (python-tests-look-at "profile =")
1009 (python-nav-lisp-forward-sexp-safe 4)
1010 (should (looking-at "(user=request.user)"))
1011 (python-tests-look-at "user=request.user")
1012 (python-nav-lisp-forward-sexp-safe -1)
1013 (should (looking-at "(user=request.user)"))
1014 (python-nav-lisp-forward-sexp-safe -4)
1015 (should (looking-at "profile ="))
1016 (python-tests-look-at "user=request.user")
1017 (python-nav-lisp-forward-sexp-safe 3)
1018 (should (looking-at ")"))
1019 (python-nav-lisp-forward-sexp-safe 1)
1020 (should (looking-at "$"))
1021 (python-nav-lisp-forward-sexp-safe 1)
1022 (should (looking-at ".notify()"))))
1023
1024(ert-deftest python-nav-forward-sexp-1 ()
1025 (python-tests-with-temp-buffer
1026 "
1027a()
1028b()
1029c()
1030"
1031 (python-tests-look-at "a()")
1032 (python-nav-forward-sexp)
1033 (should (looking-at "$"))
1034 (should (save-excursion
1035 (beginning-of-line)
1036 (looking-at "a()")))
1037 (python-nav-forward-sexp)
1038 (should (looking-at "$"))
1039 (should (save-excursion
1040 (beginning-of-line)
1041 (looking-at "b()")))
1042 (python-nav-forward-sexp)
1043 (should (looking-at "$"))
1044 (should (save-excursion
1045 (beginning-of-line)
1046 (looking-at "c()")))
1047 ;; Movement next to a paren should do what lisp does and
1048 ;; unfortunately It can't change, because otherwise
1049 ;; `blink-matching-open' breaks.
1050 (python-nav-forward-sexp -1)
1051 (should (looking-at "()"))
1052 (should (save-excursion
1053 (beginning-of-line)
1054 (looking-at "c()")))
1055 (python-nav-forward-sexp -1)
1056 (should (looking-at "c()"))
1057 (python-nav-forward-sexp -1)
1058 (should (looking-at "b()"))
1059 (python-nav-forward-sexp -1)
1060 (should (looking-at "a()"))))
1061
1062(ert-deftest python-nav-forward-sexp-2 ()
1063 (python-tests-with-temp-buffer
1064 "
1065def func():
1066 if True:
1067 aaa = bbb
1068 ccc = ddd
1069 eee = fff
1070 return ggg
1071"
1072 (python-tests-look-at "aa =")
1073 (python-nav-forward-sexp)
1074 (should (looking-at " = bbb"))
1075 (python-nav-forward-sexp)
1076 (should (looking-at "$"))
1077 (should (save-excursion
1078 (back-to-indentation)
1079 (looking-at "aaa = bbb")))
1080 (python-nav-forward-sexp)
1081 (should (looking-at "$"))
1082 (should (save-excursion
1083 (back-to-indentation)
1084 (looking-at "ccc = ddd")))
1085 (python-nav-forward-sexp)
1086 (should (looking-at "$"))
1087 (should (save-excursion
1088 (back-to-indentation)
1089 (looking-at "eee = fff")))
1090 (python-nav-forward-sexp)
1091 (should (looking-at "$"))
1092 (should (save-excursion
1093 (back-to-indentation)
1094 (looking-at "return ggg")))
1095 (python-nav-forward-sexp -1)
1096 (should (looking-at "def func():"))))
1097
1098(ert-deftest python-nav-forward-sexp-3 ()
1099 (python-tests-with-temp-buffer
1100 "
1101from some_module import some_sub_module
1102from another_module import another_sub_module
1103
1104def another_statement():
1105 pass
1106"
1107 (python-tests-look-at "some_module")
1108 (python-nav-forward-sexp)
1109 (should (looking-at " import"))
1110 (python-nav-forward-sexp)
1111 (should (looking-at " some_sub_module"))
1112 (python-nav-forward-sexp)
1113 (should (looking-at "$"))
1114 (should
1115 (save-excursion
1116 (back-to-indentation)
1117 (looking-at
1118 "from some_module import some_sub_module")))
1119 (python-nav-forward-sexp)
1120 (should (looking-at "$"))
1121 (should
1122 (save-excursion
1123 (back-to-indentation)
1124 (looking-at
1125 "from another_module import another_sub_module")))
1126 (python-nav-forward-sexp)
1127 (should (looking-at "$"))
1128 (should
1129 (save-excursion
1130 (back-to-indentation)
1131 (looking-at
1132 "pass")))
1133 (python-nav-forward-sexp -1)
1134 (should (looking-at "def another_statement():"))
1135 (python-nav-forward-sexp -1)
1136 (should (looking-at "from another_module import another_sub_module"))
1137 (python-nav-forward-sexp -1)
1138 (should (looking-at "from some_module import some_sub_module"))))
1139
1140(ert-deftest python-nav-up-list-1 ()
1141 (python-tests-with-temp-buffer
1142 "
1143def f():
1144 if True:
1145 return [i for i in range(3)]
1146"
1147 (python-tests-look-at "3)]")
1148 (python-nav-up-list)
1149 (should (looking-at "]"))
1150 (python-nav-up-list)
1151 (should (looking-at "$"))))
1152
1153(ert-deftest python-nav-backward-up-list-1 ()
1154 :expected-result :failed
1155 (python-tests-with-temp-buffer
1156 "
1157def f():
1158 if True:
1159 return [i for i in range(3)]
1160"
1161 (python-tests-look-at "3)]")
1162 (python-nav-backward-up-list)
1163 (should (looking-at "(3)\\]"))
1164 (python-nav-backward-up-list)
1165 (should (looking-at
1166 "\\[i for i in range(3)\\]"))
1167 ;; FIXME: Need to move to beginning-of-statement.
1168 (python-nav-backward-up-list)
1169 (should (looking-at
1170 "return \\[i for i in range(3)\\]"))
1171 (python-nav-backward-up-list)
1172 (should (looking-at "if True:"))
1173 (python-nav-backward-up-list)
1174 (should (looking-at "def f():"))))
1175
1176
1177;;; Shell integration
1178
1179(defvar python-tests-shell-interpreter "python")
1180
1181(ert-deftest python-shell-get-process-name-1 ()
1182 "Check process name calculation on different scenarios."
1183 (python-tests-with-temp-buffer
1184 ""
1185 (should (string= (python-shell-get-process-name nil)
1186 python-shell-buffer-name))
1187 ;; When the `current-buffer' doesn't have `buffer-file-name', even
1188 ;; if dedicated flag is non-nil should not include its name.
1189 (should (string= (python-shell-get-process-name t)
1190 python-shell-buffer-name)))
1191 (python-tests-with-temp-file
1192 ""
1193 ;; `buffer-file-name' is non-nil but the dedicated flag is nil and
1194 ;; should be respected.
1195 (should (string= (python-shell-get-process-name nil)
1196 python-shell-buffer-name))
1197 (should (string=
1198 (python-shell-get-process-name t)
1199 (format "%s[%s]" python-shell-buffer-name buffer-file-name)))))
1200
1201(ert-deftest python-shell-internal-get-process-name-1 ()
1202 "Check the internal process name is config-unique."
1203 (let* ((python-shell-interpreter python-tests-shell-interpreter)
1204 (python-shell-interpreter-args "")
1205 (python-shell-prompt-regexp ">>> ")
1206 (python-shell-prompt-block-regexp "[.][.][.] ")
1207 (python-shell-setup-codes "")
1208 (python-shell-process-environment "")
1209 (python-shell-extra-pythonpaths "")
1210 (python-shell-exec-path "")
1211 (python-shell-virtualenv-path "")
1212 (expected (python-tests-with-temp-buffer
1213 "" (python-shell-internal-get-process-name))))
1214 ;; Same configurations should match.
1215 (should
1216 (string= expected
1217 (python-tests-with-temp-buffer
1218 "" (python-shell-internal-get-process-name))))
1219 (let ((python-shell-interpreter-args "-B"))
1220 ;; A minimal change should generate different names.
1221 (should
1222 (not (string=
1223 expected
1224 (python-tests-with-temp-buffer
1225 "" (python-shell-internal-get-process-name))))))))
1226
1227(ert-deftest python-shell-parse-command-1 ()
1228 "Check the command to execute is calculated correctly.
1229Using `python-shell-interpreter' and
1230`python-shell-interpreter-args'."
1231 :expected-result (if (executable-find python-tests-shell-interpreter)
1232 :passed
1233 :failed)
1234 (let ((python-shell-interpreter (executable-find
1235 python-tests-shell-interpreter))
1236 (python-shell-interpreter-args "-B"))
1237 (should (string=
1238 (format "%s %s"
1239 python-shell-interpreter
1240 python-shell-interpreter-args)
1241 (python-shell-parse-command)))))
1242
1243(ert-deftest python-shell-calculate-process-environment-1 ()
1244 "Test `python-shell-process-environment' modification."
1245 (let* ((original-process-environment process-environment)
1246 (python-shell-process-environment
1247 '("TESTVAR1=value1" "TESTVAR2=value2"))
1248 (process-environment
1249 (python-shell-calculate-process-environment)))
1250 (should (equal (getenv "TESTVAR1") "value1"))
1251 (should (equal (getenv "TESTVAR2") "value2"))))
1252
1253(ert-deftest python-shell-calculate-process-environment-2 ()
1254 "Test `python-shell-extra-pythonpaths' modification."
1255 (let* ((original-process-environment process-environment)
1256 (original-pythonpath (getenv "PYTHONPATH"))
1257 (paths '("path1" "path2"))
1258 (python-shell-extra-pythonpaths paths)
1259 (process-environment
1260 (python-shell-calculate-process-environment)))
1261 (should (equal (getenv "PYTHONPATH")
1262 (concat
1263 (mapconcat 'identity paths path-separator)
1264 path-separator original-pythonpath)))))
1265
1266(ert-deftest python-shell-calculate-process-environment-3 ()
1267 "Test `python-shell-virtualenv-path' modification."
1268 (let* ((original-process-environment process-environment)
1269 (original-path (or (getenv "PATH") ""))
1270 (python-shell-virtualenv-path
1271 (directory-file-name user-emacs-directory))
1272 (process-environment
1273 (python-shell-calculate-process-environment)))
1274 (should (not (getenv "PYTHONHOME")))
1275 (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-path))
1276 (should (equal (getenv "PATH")
1277 (format "%s/bin%s%s"
1278 python-shell-virtualenv-path
1279 path-separator original-path)))))
1280
1281(ert-deftest python-shell-calculate-exec-path-1 ()
1282 "Test `python-shell-exec-path' modification."
1283 (let* ((original-exec-path exec-path)
1284 (python-shell-exec-path '("path1" "path2"))
1285 (exec-path (python-shell-calculate-exec-path)))
1286 (should (equal
1287 exec-path
1288 (append python-shell-exec-path
1289 original-exec-path)))))
1290
1291(ert-deftest python-shell-calculate-exec-path-2 ()
1292 "Test `python-shell-exec-path' modification."
1293 (let* ((original-exec-path exec-path)
1294 (python-shell-virtualenv-path
1295 (directory-file-name user-emacs-directory))
1296 (exec-path (python-shell-calculate-exec-path)))
1297 (should (equal
1298 exec-path
1299 (append (cons
1300 (format "%s/bin" python-shell-virtualenv-path)
1301 original-exec-path))))))
1302
1303(ert-deftest python-shell-make-comint-1 ()
1304 "Check comint creation for global shell buffer."
1305 :expected-result (if (executable-find python-tests-shell-interpreter)
1306 :passed
1307 :failed)
1308 (let* ((python-shell-interpreter
1309 (executable-find python-tests-shell-interpreter))
1310 (proc-name (python-shell-get-process-name nil))
1311 (shell-buffer
1312 (python-tests-with-temp-buffer
1313 "" (python-shell-make-comint
1314 (python-shell-parse-command) proc-name)))
1315 (process (get-buffer-process shell-buffer)))
1316 (unwind-protect
1317 (progn
1318 (set-process-query-on-exit-flag process nil)
1319 (should (process-live-p process))
1320 (with-current-buffer shell-buffer
1321 (should (eq major-mode 'inferior-python-mode))
1322 (should (string= (buffer-name) (format "*%s*" proc-name)))))
1323 (kill-buffer shell-buffer))))
1324
1325(ert-deftest python-shell-make-comint-2 ()
1326 "Check comint creation for internal shell buffer."
1327 :expected-result (if (executable-find python-tests-shell-interpreter)
1328 :passed
1329 :failed)
1330 (let* ((python-shell-interpreter
1331 (executable-find python-tests-shell-interpreter))
1332 (proc-name (python-shell-internal-get-process-name))
1333 (shell-buffer
1334 (python-tests-with-temp-buffer
1335 "" (python-shell-make-comint
1336 (python-shell-parse-command) proc-name nil t)))
1337 (process (get-buffer-process shell-buffer)))
1338 (unwind-protect
1339 (progn
1340 (set-process-query-on-exit-flag process nil)
1341 (should (process-live-p process))
1342 (with-current-buffer shell-buffer
1343 (should (eq major-mode 'inferior-python-mode))
1344 (should (string= (buffer-name) (format " *%s*" proc-name)))))
1345 (kill-buffer shell-buffer))))
1346
1347(ert-deftest python-shell-get-process-1 ()
1348 "Check dedicated shell process preference over global."
1349 :expected-result (if (executable-find python-tests-shell-interpreter)
1350 :passed
1351 :failed)
1352 (python-tests-with-temp-file
1353 ""
1354 (let* ((python-shell-interpreter
1355 (executable-find python-tests-shell-interpreter))
1356 (global-proc-name (python-shell-get-process-name nil))
1357 (dedicated-proc-name (python-shell-get-process-name t))
1358 (global-shell-buffer
1359 (python-shell-make-comint
1360 (python-shell-parse-command) global-proc-name))
1361 (dedicated-shell-buffer
1362 (python-shell-make-comint
1363 (python-shell-parse-command) dedicated-proc-name))
1364 (global-process (get-buffer-process global-shell-buffer))
1365 (dedicated-process (get-buffer-process dedicated-shell-buffer)))
1366 (unwind-protect
1367 (progn
1368 (set-process-query-on-exit-flag global-process nil)
1369 (set-process-query-on-exit-flag dedicated-process nil)
1370 ;; Prefer dedicated if global also exists.
1371 (should (equal (python-shell-get-process) dedicated-process))
1372 (kill-buffer dedicated-shell-buffer)
1373 ;; If there's only global, use it.
1374 (should (equal (python-shell-get-process) global-process))
1375 (kill-buffer global-shell-buffer)
1376 ;; No buffer available.
1377 (should (not (python-shell-get-process))))
1378 (ignore-errors (kill-buffer global-shell-buffer))
1379 (ignore-errors (kill-buffer dedicated-shell-buffer))))))
1380
1381(ert-deftest python-shell-get-or-create-process-1 ()
1382 "Check shell process creation fallback."
1383 :expected-result :failed
1384 (python-tests-with-temp-file
1385 ""
1386 ;; XXX: Break early until we can skip stuff. We need to mimic
1387 ;; user interaction because `python-shell-get-or-create-process'
1388 ;; asks for all arguments interactively when a shell process
1389 ;; doesn't exist.
1390 (should nil)
1391 (let* ((python-shell-interpreter
1392 (executable-find python-tests-shell-interpreter))
1393 (use-dialog-box)
1394 (dedicated-process-name (python-shell-get-process-name t))
1395 (dedicated-process (python-shell-get-or-create-process))
1396 (dedicated-shell-buffer (process-buffer dedicated-process)))
1397 (unwind-protect
1398 (progn
1399 (set-process-query-on-exit-flag dedicated-process nil)
1400 ;; Prefer dedicated if not buffer exist.
1401 (should (equal (process-name dedicated-process)
1402 dedicated-process-name))
1403 (kill-buffer dedicated-shell-buffer)
1404 ;; No buffer available.
1405 (should (not (python-shell-get-process))))
1406 (ignore-errors (kill-buffer dedicated-shell-buffer))))))
1407
1408(ert-deftest python-shell-internal-get-or-create-process-1 ()
1409 "Check internal shell process creation fallback."
1410 :expected-result (if (executable-find python-tests-shell-interpreter)
1411 :passed
1412 :failed)
1413 (python-tests-with-temp-file
1414 ""
1415 (should (not (process-live-p (python-shell-internal-get-process-name))))
1416 (let* ((python-shell-interpreter
1417 (executable-find python-tests-shell-interpreter))
1418 (internal-process-name (python-shell-internal-get-process-name))
1419 (internal-process (python-shell-internal-get-or-create-process))
1420 (internal-shell-buffer (process-buffer internal-process)))
1421 (unwind-protect
1422 (progn
1423 (set-process-query-on-exit-flag internal-process nil)
1424 (should (equal (process-name internal-process)
1425 internal-process-name))
1426 (should (equal internal-process
1427 (python-shell-internal-get-or-create-process)))
1428 ;; No user buffer available.
1429 (should (not (python-shell-get-process)))
1430 (kill-buffer internal-shell-buffer))
1431 (ignore-errors (kill-buffer internal-shell-buffer))))))
1432
1433
1434;;; Shell completion
1435
1436
1437;;; PDB Track integration
1438
1439
1440;;; Symbol completion
1441
1442
1443;;; Fill paragraph
1444
1445
1446;;; Skeletons
1447
1448
1449;;; FFAP
1450
1451
1452;;; Code check
1453
1454
1455;;; Eldoc
1456
1457
1458;;; Imenu
1459(ert-deftest python-imenu-prev-index-position-1 ()
1460 (require 'imenu)
1461 (python-tests-with-temp-buffer
1462 "
1463def decoratorFunctionWithArguments(arg1, arg2, arg3):
1464 '''print decorated function call data to stdout.
1465
1466 Usage:
1467
1468 @decoratorFunctionWithArguments('arg1', 'arg2')
1469 def func(a, b, c=True):
1470 pass
1471 '''
1472
1473 def wwrap(f):
1474 print 'Inside wwrap()'
1475 def wrapped_f(*args):
1476 print 'Inside wrapped_f()'
1477 print 'Decorator arguments:', arg1, arg2, arg3
1478 f(*args)
1479 print 'After f(*args)'
1480 return wrapped_f
1481 return wwrap
1482
1483def test(): # Some comment
1484 'This is a test function'
1485 print 'test'
1486
1487class C(object):
1488
1489 def m(self):
1490 self.c()
1491
1492 def b():
1493 pass
1494
1495 def a():
1496 pass
1497
1498 def c(self):
1499 pass
1500"
1501 (let ((expected
1502 '(("*Rescan*" . -99)
1503 ("decoratorFunctionWithArguments" . 2)
1504 ("decoratorFunctionWithArguments.wwrap" . 224)
1505 ("decoratorFunctionWithArguments.wwrap.wrapped_f" . 273)
1506 ("test" . 500)
1507 ("C" . 575)
1508 ("C.m" . 593)
1509 ("C.m.b" . 628)
1510 ("C.m.a" . 663)
1511 ("C.c" . 698))))
1512 (mapc
1513 (lambda (elt)
1514 (should (= (cdr (assoc-string (car elt) expected))
1515 (if (markerp (cdr elt))
1516 (marker-position (cdr elt))
1517 (cdr elt)))))
1518 (imenu--make-index-alist)))))
1519
1520
1521;;; Misc helpers
1522
1523(ert-deftest python-info-current-defun-1 ()
1524 (python-tests-with-temp-buffer
1525 "
1526def foo(a, b):
1527"
1528 (forward-line 1)
1529 (should (string= "foo" (python-info-current-defun)))
1530 (should (string= "def foo" (python-info-current-defun t)))
1531 (forward-line 1)
1532 (should (not (python-info-current-defun)))
1533 (indent-for-tab-command)
1534 (should (string= "foo" (python-info-current-defun)))
1535 (should (string= "def foo" (python-info-current-defun t)))))
1536
1537(ert-deftest python-info-current-defun-2 ()
1538 (python-tests-with-temp-buffer
1539 "
1540class C(object):
1541
1542 def m(self):
1543 if True:
1544 return [i for i in range(3)]
1545 else:
1546 return []
1547
1548 def b():
1549 pass
1550
1551 def a():
1552 pass
1553
1554 def c(self):
1555 pass
1556"
1557 (forward-line 1)
1558 (should (string= "C" (python-info-current-defun)))
1559 (should (string= "class C" (python-info-current-defun t)))
1560 (python-tests-look-at "return [i for ")
1561 (should (string= "C.m" (python-info-current-defun)))
1562 (should (string= "def C.m" (python-info-current-defun t)))
1563 (python-tests-look-at "def b():")
1564 (should (string= "C.m.b" (python-info-current-defun)))
1565 (should (string= "def C.m.b" (python-info-current-defun t)))
1566 (forward-line 2)
1567 (indent-for-tab-command)
1568 (python-indent-dedent-line-backspace 1)
1569 (should (string= "C.m" (python-info-current-defun)))
1570 (should (string= "def C.m" (python-info-current-defun t)))
1571 (python-tests-look-at "def c(self):")
1572 (forward-line -1)
1573 (indent-for-tab-command)
1574 (should (string= "C.m.a" (python-info-current-defun)))
1575 (should (string= "def C.m.a" (python-info-current-defun t)))
1576 (python-indent-dedent-line-backspace 1)
1577 (should (string= "C.m" (python-info-current-defun)))
1578 (should (string= "def C.m" (python-info-current-defun t)))
1579 (python-indent-dedent-line-backspace 1)
1580 (should (string= "C" (python-info-current-defun)))
1581 (should (string= "class C" (python-info-current-defun t)))
1582 (python-tests-look-at "def c(self):")
1583 (should (string= "C.c" (python-info-current-defun)))
1584 (should (string= "def C.c" (python-info-current-defun t)))
1585 (python-tests-look-at "pass")
1586 (should (string= "C.c" (python-info-current-defun)))
1587 (should (string= "def C.c" (python-info-current-defun t)))))
1588
1589(ert-deftest python-info-current-defun-3 ()
1590 (python-tests-with-temp-buffer
1591 "
1592def decoratorFunctionWithArguments(arg1, arg2, arg3):
1593 '''print decorated function call data to stdout.
1594
1595 Usage:
1596
1597 @decoratorFunctionWithArguments('arg1', 'arg2')
1598 def func(a, b, c=True):
1599 pass
1600 '''
1601
1602 def wwrap(f):
1603 print 'Inside wwrap()'
1604 def wrapped_f(*args):
1605 print 'Inside wrapped_f()'
1606 print 'Decorator arguments:', arg1, arg2, arg3
1607 f(*args)
1608 print 'After f(*args)'
1609 return wrapped_f
1610 return wwrap
1611"
1612 (python-tests-look-at "def wwrap(f):")
1613 (forward-line -1)
1614 (should (not (python-info-current-defun)))
1615 (indent-for-tab-command 1)
1616 (should (string= (python-info-current-defun)
1617 "decoratorFunctionWithArguments"))
1618 (should (string= (python-info-current-defun t)
1619 "def decoratorFunctionWithArguments"))
1620 (python-tests-look-at "def wrapped_f(*args):")
1621 (should (string= (python-info-current-defun)
1622 "decoratorFunctionWithArguments.wwrap.wrapped_f"))
1623 (should (string= (python-info-current-defun t)
1624 "def decoratorFunctionWithArguments.wwrap.wrapped_f"))
1625 (python-tests-look-at "return wrapped_f")
1626 (should (string= (python-info-current-defun)
1627 "decoratorFunctionWithArguments.wwrap"))
1628 (should (string= (python-info-current-defun t)
1629 "def decoratorFunctionWithArguments.wwrap"))
1630 (end-of-line 1)
1631 (python-tests-look-at "return wwrap")
1632 (should (string= (python-info-current-defun)
1633 "decoratorFunctionWithArguments"))
1634 (should (string= (python-info-current-defun t)
1635 "def decoratorFunctionWithArguments"))))
1636
1637(ert-deftest python-info-current-symbol-1 ()
1638 (python-tests-with-temp-buffer
1639 "
1640class C(object):
1641
1642 def m(self):
1643 self.c()
1644
1645 def c(self):
1646 print ('a')
1647"
1648 (python-tests-look-at "self.c()")
1649 (should (string= "self.c" (python-info-current-symbol)))
1650 (should (string= "C.c" (python-info-current-symbol t)))))
1651
1652(ert-deftest python-info-current-symbol-2 ()
1653 (python-tests-with-temp-buffer
1654 "
1655class C(object):
1656
1657 class M(object):
1658
1659 def a(self):
1660 self.c()
1661
1662 def c(self):
1663 pass
1664"
1665 (python-tests-look-at "self.c()")
1666 (should (string= "self.c" (python-info-current-symbol)))
1667 (should (string= "C.M.c" (python-info-current-symbol t)))))
1668
1669(ert-deftest python-info-current-symbol-3 ()
1670 "Keywords should not be considered symbols."
1671 :expected-result :failed
1672 (python-tests-with-temp-buffer
1673 "
1674class C(object):
1675 pass
1676"
1677 ;; FIXME: keywords are not symbols.
1678 (python-tests-look-at "class C")
1679 (should (not (python-info-current-symbol)))
1680 (should (not (python-info-current-symbol t)))
1681 (python-tests-look-at "C(object)")
1682 (should (string= "C" (python-info-current-symbol)))
1683 (should (string= "class C" (python-info-current-symbol t)))))
1684
1685(ert-deftest python-info-statement-starts-block-p-1 ()
1686 (python-tests-with-temp-buffer
1687 "
1688def long_function_name(
1689 var_one, var_two, var_three,
1690 var_four):
1691 print (var_one)
1692"
1693 (python-tests-look-at "def long_function_name")
1694 (should (python-info-statement-starts-block-p))
1695 (python-tests-look-at "print (var_one)")
1696 (python-util-forward-comment -1)
1697 (should (python-info-statement-starts-block-p))))
1698
1699(ert-deftest python-info-statement-starts-block-p-2 ()
1700 (python-tests-with-temp-buffer
1701 "
1702if width == 0 and height == 0 and \\\\
1703 color == 'red' and emphasis == 'strong' or \\\\
1704 highlight > 100:
1705 raise ValueError('sorry, you lose')
1706"
1707 (python-tests-look-at "if width == 0 and")
1708 (should (python-info-statement-starts-block-p))
1709 (python-tests-look-at "raise ValueError(")
1710 (python-util-forward-comment -1)
1711 (should (python-info-statement-starts-block-p))))
1712
1713(ert-deftest python-info-statement-ends-block-p-1 ()
1714 (python-tests-with-temp-buffer
1715 "
1716def long_function_name(
1717 var_one, var_two, var_three,
1718 var_four):
1719 print (var_one)
1720"
1721 (python-tests-look-at "print (var_one)")
1722 (should (python-info-statement-ends-block-p))))
1723
1724(ert-deftest python-info-statement-ends-block-p-2 ()
1725 (python-tests-with-temp-buffer
1726 "
1727if width == 0 and height == 0 and \\\\
1728 color == 'red' and emphasis == 'strong' or \\\\
1729 highlight > 100:
1730 raise ValueError(
1731'sorry, you lose'
1732
1733)
1734"
1735 (python-tests-look-at "raise ValueError(")
1736 (should (python-info-statement-ends-block-p))))
1737
1738(ert-deftest python-info-beginning-of-statement-p-1 ()
1739 (python-tests-with-temp-buffer
1740 "
1741def long_function_name(
1742 var_one, var_two, var_three,
1743 var_four):
1744 print (var_one)
1745"
1746 (python-tests-look-at "def long_function_name")
1747 (should (python-info-beginning-of-statement-p))
1748 (forward-char 10)
1749 (should (not (python-info-beginning-of-statement-p)))
1750 (python-tests-look-at "print (var_one)")
1751 (should (python-info-beginning-of-statement-p))
1752 (goto-char (line-beginning-position))
1753 (should (not (python-info-beginning-of-statement-p)))))
1754
1755(ert-deftest python-info-beginning-of-statement-p-2 ()
1756 (python-tests-with-temp-buffer
1757 "
1758if width == 0 and height == 0 and \\\\
1759 color == 'red' and emphasis == 'strong' or \\\\
1760 highlight > 100:
1761 raise ValueError(
1762'sorry, you lose'
1763
1764)
1765"
1766 (python-tests-look-at "if width == 0 and")
1767 (should (python-info-beginning-of-statement-p))
1768 (forward-char 10)
1769 (should (not (python-info-beginning-of-statement-p)))
1770 (python-tests-look-at "raise ValueError(")
1771 (should (python-info-beginning-of-statement-p))
1772 (goto-char (line-beginning-position))
1773 (should (not (python-info-beginning-of-statement-p)))))
1774
1775(ert-deftest python-info-end-of-statement-p-1 ()
1776 (python-tests-with-temp-buffer
1777 "
1778def long_function_name(
1779 var_one, var_two, var_three,
1780 var_four):
1781 print (var_one)
1782"
1783 (python-tests-look-at "def long_function_name")
1784 (should (not (python-info-end-of-statement-p)))
1785 (end-of-line)
1786 (should (not (python-info-end-of-statement-p)))
1787 (python-tests-look-at "print (var_one)")
1788 (python-util-forward-comment -1)
1789 (should (python-info-end-of-statement-p))
1790 (python-tests-look-at "print (var_one)")
1791 (should (not (python-info-end-of-statement-p)))
1792 (end-of-line)
1793 (should (python-info-end-of-statement-p))))
1794
1795(ert-deftest python-info-end-of-statement-p-2 ()
1796 (python-tests-with-temp-buffer
1797 "
1798if width == 0 and height == 0 and \\\\
1799 color == 'red' and emphasis == 'strong' or \\\\
1800 highlight > 100:
1801 raise ValueError(
1802'sorry, you lose'
1803
1804)
1805"
1806 (python-tests-look-at "if width == 0 and")
1807 (should (not (python-info-end-of-statement-p)))
1808 (end-of-line)
1809 (should (not (python-info-end-of-statement-p)))
1810 (python-tests-look-at "raise ValueError(")
1811 (python-util-forward-comment -1)
1812 (should (python-info-end-of-statement-p))
1813 (python-tests-look-at "raise ValueError(")
1814 (should (not (python-info-end-of-statement-p)))
1815 (end-of-line)
1816 (should (not (python-info-end-of-statement-p)))
1817 (goto-char (point-max))
1818 (python-util-forward-comment -1)
1819 (should (python-info-end-of-statement-p))))
1820
1821(ert-deftest python-info-beginning-of-block-p-1 ()
1822 (python-tests-with-temp-buffer
1823 "
1824def long_function_name(
1825 var_one, var_two, var_three,
1826 var_four):
1827 print (var_one)
1828"
1829 (python-tests-look-at "def long_function_name")
1830 (should (python-info-beginning-of-block-p))
1831 (python-tests-look-at "var_one, var_two, var_three,")
1832 (should (not (python-info-beginning-of-block-p)))
1833 (python-tests-look-at "print (var_one)")
1834 (should (not (python-info-beginning-of-block-p)))))
1835
1836(ert-deftest python-info-beginning-of-block-p-2 ()
1837 (python-tests-with-temp-buffer
1838 "
1839if width == 0 and height == 0 and \\\\
1840 color == 'red' and emphasis == 'strong' or \\\\
1841 highlight > 100:
1842 raise ValueError(
1843'sorry, you lose'
1844
1845)
1846"
1847 (python-tests-look-at "if width == 0 and")
1848 (should (python-info-beginning-of-block-p))
1849 (python-tests-look-at "color == 'red' and emphasis")
1850 (should (not (python-info-beginning-of-block-p)))
1851 (python-tests-look-at "raise ValueError(")
1852 (should (not (python-info-beginning-of-block-p)))))
1853
1854(ert-deftest python-info-end-of-block-p-1 ()
1855 (python-tests-with-temp-buffer
1856 "
1857def long_function_name(
1858 var_one, var_two, var_three,
1859 var_four):
1860 print (var_one)
1861"
1862 (python-tests-look-at "def long_function_name")
1863 (should (not (python-info-end-of-block-p)))
1864 (python-tests-look-at "var_one, var_two, var_three,")
1865 (should (not (python-info-end-of-block-p)))
1866 (python-tests-look-at "var_four):")
1867 (end-of-line)
1868 (should (not (python-info-end-of-block-p)))
1869 (python-tests-look-at "print (var_one)")
1870 (should (not (python-info-end-of-block-p)))
1871 (end-of-line 1)
1872 (should (python-info-end-of-block-p))))
1873
1874(ert-deftest python-info-end-of-block-p-2 ()
1875 (python-tests-with-temp-buffer
1876 "
1877if width == 0 and height == 0 and \\\\
1878 color == 'red' and emphasis == 'strong' or \\\\
1879 highlight > 100:
1880 raise ValueError(
1881'sorry, you lose'
1882
1883)
1884"
1885 (python-tests-look-at "if width == 0 and")
1886 (should (not (python-info-end-of-block-p)))
1887 (python-tests-look-at "color == 'red' and emphasis == 'strong' or")
1888 (should (not (python-info-end-of-block-p)))
1889 (python-tests-look-at "highlight > 100:")
1890 (end-of-line)
1891 (should (not (python-info-end-of-block-p)))
1892 (python-tests-look-at "raise ValueError(")
1893 (should (not (python-info-end-of-block-p)))
1894 (end-of-line 1)
1895 (should (not (python-info-end-of-block-p)))
1896 (goto-char (point-max))
1897 (python-util-forward-comment -1)
1898 (should (python-info-end-of-block-p))))
1899
1900(ert-deftest python-info-closing-block-1 ()
1901 (python-tests-with-temp-buffer
1902 "
1903if request.user.is_authenticated():
1904 try:
1905 profile = request.user.get_profile()
1906 except Profile.DoesNotExist:
1907 profile = Profile.objects.create(user=request.user)
1908 else:
1909 if profile.stats:
1910 profile.recalculate_stats()
1911 else:
1912 profile.clear_stats()
1913 finally:
1914 profile.views += 1
1915 profile.save()
1916"
1917 (python-tests-look-at "try:")
1918 (should (not (python-info-closing-block)))
1919 (python-tests-look-at "except Profile.DoesNotExist:")
1920 (should (= (python-tests-look-at "try:" -1 t)
1921 (python-info-closing-block)))
1922 (python-tests-look-at "else:")
1923 (should (= (python-tests-look-at "except Profile.DoesNotExist:" -1 t)
1924 (python-info-closing-block)))
1925 (python-tests-look-at "if profile.stats:")
1926 (should (not (python-info-closing-block)))
1927 (python-tests-look-at "else:")
1928 (should (= (python-tests-look-at "if profile.stats:" -1 t)
1929 (python-info-closing-block)))
1930 (python-tests-look-at "finally:")
1931 (should (= (python-tests-look-at "else:" -2 t)
1932 (python-info-closing-block)))))
1933
1934(ert-deftest python-info-closing-block-2 ()
1935 (python-tests-with-temp-buffer
1936 "
1937if request.user.is_authenticated():
1938 profile = Profile.objects.get_or_create(user=request.user)
1939 if profile.stats:
1940 profile.recalculate_stats()
1941
1942data = {
1943 'else': 'do it'
1944}
1945 'else'
1946"
1947 (python-tests-look-at "'else': 'do it'")
1948 (should (not (python-info-closing-block)))
1949 (python-tests-look-at "'else'")
1950 (should (not (python-info-closing-block)))))
1951
1952(ert-deftest python-info-line-ends-backslash-p-1 ()
1953 (python-tests-with-temp-buffer
1954 "
1955objects = Thing.objects.all() \\\\
1956 .filter(
1957 type='toy',
1958 status='bought'
1959 ) \\\\
1960 .aggregate(
1961 Sum('amount')
1962 ) \\\\
1963 .values_list()
1964"
1965 (should (python-info-line-ends-backslash-p 2)) ; .filter(...
1966 (should (python-info-line-ends-backslash-p 3))
1967 (should (python-info-line-ends-backslash-p 4))
1968 (should (python-info-line-ends-backslash-p 5))
1969 (should (python-info-line-ends-backslash-p 6)) ; ) \...
1970 (should (python-info-line-ends-backslash-p 7))
1971 (should (python-info-line-ends-backslash-p 8))
1972 (should (python-info-line-ends-backslash-p 9))
1973 (should (not (python-info-line-ends-backslash-p 10))))) ; .values_list()...
1974
1975(ert-deftest python-info-beginning-of-backslash-1 ()
1976 (python-tests-with-temp-buffer
1977 "
1978objects = Thing.objects.all() \\\\
1979 .filter(
1980 type='toy',
1981 status='bought'
1982 ) \\\\
1983 .aggregate(
1984 Sum('amount')
1985 ) \\\\
1986 .values_list()
1987"
1988 (let ((first 2)
1989 (second (python-tests-look-at ".filter("))
1990 (third (python-tests-look-at ".aggregate(")))
1991 (should (= first (python-info-beginning-of-backslash 2)))
1992 (should (= second (python-info-beginning-of-backslash 3)))
1993 (should (= second (python-info-beginning-of-backslash 4)))
1994 (should (= second (python-info-beginning-of-backslash 5)))
1995 (should (= second (python-info-beginning-of-backslash 6)))
1996 (should (= third (python-info-beginning-of-backslash 7)))
1997 (should (= third (python-info-beginning-of-backslash 8)))
1998 (should (= third (python-info-beginning-of-backslash 9)))
1999 (should (not (python-info-beginning-of-backslash 10))))))
2000
2001(ert-deftest python-info-continuation-line-p-1 ()
2002 (python-tests-with-temp-buffer
2003 "
2004if width == 0 and height == 0 and \\\\
2005 color == 'red' and emphasis == 'strong' or \\\\
2006 highlight > 100:
2007 raise ValueError(
2008'sorry, you lose'
2009
2010)
2011"
2012 (python-tests-look-at "if width == 0 and height == 0 and")
2013 (should (not (python-info-continuation-line-p)))
2014 (python-tests-look-at "color == 'red' and emphasis == 'strong' or")
2015 (should (python-info-continuation-line-p))
2016 (python-tests-look-at "highlight > 100:")
2017 (should (python-info-continuation-line-p))
2018 (python-tests-look-at "raise ValueError(")
2019 (should (not (python-info-continuation-line-p)))
2020 (python-tests-look-at "'sorry, you lose'")
2021 (should (python-info-continuation-line-p))
2022 (forward-line 1)
2023 (should (python-info-continuation-line-p))
2024 (python-tests-look-at ")")
2025 (should (python-info-continuation-line-p))
2026 (forward-line 1)
2027 (should (not (python-info-continuation-line-p)))))
2028
2029(ert-deftest python-info-block-continuation-line-p-1 ()
2030 (python-tests-with-temp-buffer
2031 "
2032if width == 0 and height == 0 and \\\\
2033 color == 'red' and emphasis == 'strong' or \\\\
2034 highlight > 100:
2035 raise ValueError(
2036'sorry, you lose'
2037
2038)
2039"
2040 (python-tests-look-at "if width == 0 and")
2041 (should (not (python-info-block-continuation-line-p)))
2042 (python-tests-look-at "color == 'red' and emphasis == 'strong' or")
2043 (should (= (python-info-block-continuation-line-p)
2044 (python-tests-look-at "if width == 0 and" -1 t)))
2045 (python-tests-look-at "highlight > 100:")
2046 (should (not (python-info-block-continuation-line-p)))))
2047
2048(ert-deftest python-info-block-continuation-line-p-2 ()
2049 (python-tests-with-temp-buffer
2050 "
2051def foo(a,
2052 b,
2053 c):
2054 pass
2055"
2056 (python-tests-look-at "def foo(a,")
2057 (should (not (python-info-block-continuation-line-p)))
2058 (python-tests-look-at "b,")
2059 (should (= (python-info-block-continuation-line-p)
2060 (python-tests-look-at "def foo(a," -1 t)))
2061 (python-tests-look-at "c):")
2062 (should (not (python-info-block-continuation-line-p)))))
2063
2064(ert-deftest python-info-assignment-continuation-line-p-1 ()
2065 (python-tests-with-temp-buffer
2066 "
2067data = foo(), bar() \\\\
2068 baz(), 4 \\\\
2069 5, 6
2070"
2071 (python-tests-look-at "data = foo(), bar()")
2072 (should (not (python-info-assignment-continuation-line-p)))
2073 (python-tests-look-at "baz(), 4")
2074 (should (= (python-info-assignment-continuation-line-p)
2075 (python-tests-look-at "foo()," -1 t)))
2076 (python-tests-look-at "5, 6")
2077 (should (not (python-info-assignment-continuation-line-p)))))
2078
2079(ert-deftest python-info-assignment-continuation-line-p-2 ()
2080 (python-tests-with-temp-buffer
2081 "
2082data = (foo(), bar()
2083 baz(), 4
2084 5, 6)
2085"
2086 (python-tests-look-at "data = (foo(), bar()")
2087 (should (not (python-info-assignment-continuation-line-p)))
2088 (python-tests-look-at "baz(), 4")
2089 (should (= (python-info-assignment-continuation-line-p)
2090 (python-tests-look-at "(foo()," -1 t)))
2091 (python-tests-look-at "5, 6)")
2092 (should (not (python-info-assignment-continuation-line-p)))))
2093
2094(ert-deftest python-info-looking-at-beginning-of-defun-1 ()
2095 (python-tests-with-temp-buffer
2096 "
2097def decorat0r(deff):
2098 '''decorates stuff.
2099
2100 @decorat0r
2101 def foo(arg):
2102 ...
2103 '''
2104 def wrap():
2105 deff()
2106 return wwrap
2107"
2108 (python-tests-look-at "def decorat0r(deff):")
2109 (should (python-info-looking-at-beginning-of-defun))
2110 (python-tests-look-at "def foo(arg):")
2111 (should (not (python-info-looking-at-beginning-of-defun)))
2112 (python-tests-look-at "def wrap():")
2113 (should (python-info-looking-at-beginning-of-defun))
2114 (python-tests-look-at "deff()")
2115 (should (not (python-info-looking-at-beginning-of-defun)))))
2116
2117(ert-deftest python-info-current-line-comment-p-1 ()
2118 (python-tests-with-temp-buffer
2119 "
2120# this is a comment
2121foo = True # another comment
2122'#this is a string'
2123if foo:
2124 # more comments
2125 print ('bar') # print bar
2126"
2127 (python-tests-look-at "# this is a comment")
2128 (should (python-info-current-line-comment-p))
2129 (python-tests-look-at "foo = True # another comment")
2130 (should (not (python-info-current-line-comment-p)))
2131 (python-tests-look-at "'#this is a string'")
2132 (should (not (python-info-current-line-comment-p)))
2133 (python-tests-look-at "# more comments")
2134 (should (python-info-current-line-comment-p))
2135 (python-tests-look-at "print ('bar') # print bar")
2136 (should (not (python-info-current-line-comment-p)))))
2137
2138(ert-deftest python-info-current-line-empty-p ()
2139 (python-tests-with-temp-buffer
2140 "
2141# this is a comment
2142
2143foo = True # another comment
2144"
2145 (should (python-info-current-line-empty-p))
2146 (python-tests-look-at "# this is a comment")
2147 (should (not (python-info-current-line-empty-p)))
2148 (forward-line 1)
2149 (should (python-info-current-line-empty-p))))
2150
2151
2152;;; Utility functions
2153
2154(ert-deftest python-util-goto-line-1 ()
2155 (python-tests-with-temp-buffer
2156 (concat
2157 "# a comment
2158# another comment
2159def foo(a, b, c):
2160 pass" (make-string 20 ?\n))
2161 (python-util-goto-line 10)
2162 (should (= (line-number-at-pos) 10))
2163 (python-util-goto-line 20)
2164 (should (= (line-number-at-pos) 20))))
2165
2166(ert-deftest python-util-clone-local-variables-1 ()
2167 (let ((buffer (generate-new-buffer
2168 "python-util-clone-local-variables-1"))
2169 (varcons
2170 '((python-fill-docstring-style . django)
2171 (python-shell-interpreter . "python")
2172 (python-shell-interpreter-args . "manage.py shell")
2173 (python-shell-prompt-regexp . "In \\[[0-9]+\\]: ")
2174 (python-shell-prompt-output-regexp . "Out\\[[0-9]+\\]: ")
2175 (python-shell-extra-pythonpaths "/home/user/pylib/")
2176 (python-shell-completion-setup-code
2177 . "from IPython.core.completerlib import module_completion")
2178 (python-shell-completion-module-string-code
2179 . "';'.join(module_completion('''%s'''))\n")
2180 (python-shell-completion-string-code
2181 . "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
2182 (python-shell-virtualenv-path
2183 . "/home/user/.virtualenvs/project"))))
2184 (with-current-buffer buffer
2185 (kill-all-local-variables)
2186 (dolist (ccons varcons)
2187 (set (make-local-variable (car ccons)) (cdr ccons))))
2188 (python-tests-with-temp-buffer
2189 ""
2190 (python-util-clone-local-variables buffer)
2191 (dolist (ccons varcons)
2192 (should
2193 (equal (symbol-value (car ccons)) (cdr ccons)))))
2194 (kill-buffer buffer)))
2195
2196(ert-deftest python-util-forward-comment-1 ()
2197 (python-tests-with-temp-buffer
2198 (concat
2199 "# a comment
2200# another comment
2201 # bad indented comment
2202# more comments" (make-string 9999 ?\n))
2203 (python-util-forward-comment 1)
2204 (should (= (point) (point-max)))
2205 (python-util-forward-comment -1)
2206 (should (= (point) (point-min)))))
2207
2208
2209(provide 'python-tests)
2210
2211;; Local Variables:
2212;; coding: utf-8
2213;; indent-tabs-mode: nil
2214;; End:
2215
2216;;; python-tests.el ends here
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
index ad48413b030..0ebe6d44e34 100644
--- a/test/automated/ruby-mode-tests.el
+++ b/test/automated/ruby-mode-tests.el
@@ -1,6 +1,6 @@
1;;; ruby-mode-tests.el --- Test suite for ruby-mode 1;;; ruby-mode-tests.el --- Test suite for ruby-mode
2 2
3;; Copyright (C) 2012 Free Software Foundation, Inc. 3;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6
@@ -25,9 +25,7 @@
25 25
26(defun ruby-should-indent (content column) 26(defun ruby-should-indent (content column)
27 "Assert indentation COLUMN on the last line of CONTENT." 27 "Assert indentation COLUMN on the last line of CONTENT."
28 (with-temp-buffer 28 (ruby-with-temp-buffer content
29 (insert content)
30 (ruby-mode)
31 (ruby-indent-line) 29 (ruby-indent-line)
32 (should (= (current-indentation) column)))) 30 (should (= (current-indentation) column))))
33 31
@@ -35,33 +33,33 @@
35 "Assert that CONTENT turns into EXPECTED after the buffer is re-indented. 33 "Assert that CONTENT turns into EXPECTED after the buffer is re-indented.
36 34
37The whitespace before and including \"|\" on each line is removed." 35The whitespace before and including \"|\" on each line is removed."
38 (with-temp-buffer 36 (ruby-with-temp-buffer (ruby-test-string content)
39 (insert (ruby-test-string content))
40 (ruby-mode)
41 (indent-region (point-min) (point-max)) 37 (indent-region (point-min) (point-max))
42 (should (string= (ruby-test-string expected) (buffer-string))))) 38 (should (string= (ruby-test-string expected) (buffer-string)))))
43 39
40(defmacro ruby-with-temp-buffer (contents &rest body)
41 (declare (indent 1) (debug t))
42 `(with-temp-buffer
43 (insert ,contents)
44 (ruby-mode)
45 ,@body))
46
44(defun ruby-test-string (s &rest args) 47(defun ruby-test-string (s &rest args)
45 (apply 'format (replace-regexp-in-string "^[ \t]*|" "" s) args)) 48 (apply 'format (replace-regexp-in-string "^[ \t]*|" "" s) args))
46 49
47(defun ruby-assert-state (content &rest values-plist) 50(defun ruby-assert-state (content index value &optional point)
48 "Assert syntax state values at the end of CONTENT. 51 "Assert syntax state values at the end of CONTENT.
49 52
50VALUES-PLIST is a list with alternating index and value elements." 53VALUES-PLIST is a list with alternating index and value elements."
51 (with-temp-buffer 54 (ruby-with-temp-buffer content
52 (insert content) 55 (when point (goto-char point))
53 (ruby-mode)
54 (syntax-propertize (point)) 56 (syntax-propertize (point))
55 (while values-plist 57 (should (eq (nth index
56 (should (eq (nth (car values-plist) 58 (parse-partial-sexp (point-min) (point)))
57 (parse-partial-sexp (point-min) (point))) 59 value))))
58 (cadr values-plist)))
59 (setq values-plist (cddr values-plist)))))
60 60
61(defun ruby-assert-face (content pos face) 61(defun ruby-assert-face (content pos face)
62 (with-temp-buffer 62 (ruby-with-temp-buffer content
63 (insert content)
64 (ruby-mode)
65 (font-lock-fontify-buffer) 63 (font-lock-fontify-buffer)
66 (should (eq face (get-text-property pos 'face))))) 64 (should (eq face (get-text-property pos 'face)))))
67 65
@@ -105,6 +103,12 @@ VALUES-PLIST is a list with alternating index and value elements."
105 (ruby-should-indent "a = %w[abc\n def]\n " 0) 103 (ruby-should-indent "a = %w[abc\n def]\n " 0)
106 (ruby-should-indent "a = \"abc\n def\"\n " 0)) 104 (ruby-should-indent "a = \"abc\n def\"\n " 0))
107 105
106(ert-deftest ruby-regexp-doesnt-start-in-string ()
107 (ruby-assert-state "'(/', /\d+/" 3 nil))
108
109(ert-deftest ruby-regexp-starts-after-string ()
110 (ruby-assert-state "'(/', /\d+/" 3 ?/ 8))
111
108(ert-deftest ruby-indent-simple () 112(ert-deftest ruby-indent-simple ()
109 (ruby-should-indent-buffer 113 (ruby-should-indent-buffer
110 "if foo 114 "if foo
@@ -225,18 +229,39 @@ VALUES-PLIST is a list with alternating index and value elements."
225 | end 229 | end
226 |")) 230 |"))
227 231
232(ert-deftest ruby-indent-after-block-in-continued-expression ()
233 (ruby-should-indent-buffer
234 "var =
235 | begin
236 | val
237 | end
238 |statement"
239 "var =
240 |begin
241 |val
242 |end
243 |statement"))
244
245(ert-deftest ruby-indent-spread-args-in-parens ()
246 (let ((ruby-deep-indent-paren '(?\()))
247 (ruby-should-indent-buffer
248 "foo(1,
249 | 2,
250 | 3)
251 |"
252 "foo(1,
253 | 2,
254 | 3)
255 |")))
256
228(ert-deftest ruby-move-to-block-stops-at-indentation () 257(ert-deftest ruby-move-to-block-stops-at-indentation ()
229 (with-temp-buffer 258 (ruby-with-temp-buffer "def f\nend"
230 (insert "def f\nend")
231 (beginning-of-line) 259 (beginning-of-line)
232 (ruby-mode)
233 (ruby-move-to-block -1) 260 (ruby-move-to-block -1)
234 (should (looking-at "^def")))) 261 (should (looking-at "^def"))))
235 262
236(ert-deftest ruby-toggle-block-to-do-end () 263(ert-deftest ruby-toggle-block-to-do-end ()
237 (with-temp-buffer 264 (ruby-with-temp-buffer "foo {|b|\n}"
238 (insert "foo {|b|\n}")
239 (ruby-mode)
240 (beginning-of-line) 265 (beginning-of-line)
241 (ruby-toggle-block) 266 (ruby-toggle-block)
242 (should (string= "foo do |b|\nend" (buffer-string))))) 267 (should (string= "foo do |b|\nend" (buffer-string)))))
@@ -254,9 +279,7 @@ VALUES-PLIST is a list with alternating index and value elements."
254 (should (string= (cdr pair) (buffer-string)))))))) 279 (should (string= (cdr pair) (buffer-string))))))))
255 280
256(ert-deftest ruby-toggle-block-to-multiline () 281(ert-deftest ruby-toggle-block-to-multiline ()
257 (with-temp-buffer 282 (ruby-with-temp-buffer "foo {|b| b + 1}"
258 (insert "foo {|b| b + 1}")
259 (ruby-mode)
260 (beginning-of-line) 283 (beginning-of-line)
261 (ruby-toggle-block) 284 (ruby-toggle-block)
262 (should (string= "foo do |b|\n b + 1\nend" (buffer-string))))) 285 (should (string= "foo do |b|\n b + 1\nend" (buffer-string)))))
@@ -276,13 +299,32 @@ VALUES-PLIST is a list with alternating index and value elements."
276 (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16 299 (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16
277 font-lock-variable-name-face)) 300 font-lock-variable-name-face))
278 301
279(ert-deftest ruby-interpolation-suppresses-syntax-inside () 302(ert-deftest ruby-interpolation-suppresses-quotes-inside ()
280 (let ((s "\"<ul><li>#{@files.join(\"</li><li>\")}</li></ul>\"")) 303 (let ((s "\"<ul><li>#{@files.join(\"</li><li>\")}</li></ul>\""))
281 (ruby-assert-state s 8 nil) 304 (ruby-assert-state s 8 nil)
282 (ruby-assert-face s 9 font-lock-string-face) 305 (ruby-assert-face s 9 font-lock-string-face)
283 (ruby-assert-face s 10 font-lock-variable-name-face) 306 (ruby-assert-face s 10 font-lock-variable-name-face)
284 (ruby-assert-face s 41 font-lock-string-face))) 307 (ruby-assert-face s 41 font-lock-string-face)))
285 308
309(ert-deftest ruby-interpolation-suppresses-one-double-quote ()
310 (let ((s "\"foo#{'\"'}\""))
311 (ruby-assert-state s 8 nil)
312 (ruby-assert-face s 8 font-lock-variable-name-face)
313 (ruby-assert-face s 11 font-lock-string-face)))
314
315(ert-deftest ruby-interpolation-suppresses-one-backtick ()
316 (let ((s "`as#{'`'}das`"))
317 (ruby-assert-state s 8 nil)))
318
319(ert-deftest ruby-interpolation-keeps-non-quote-syntax ()
320 (let ((s "\"foo#{baz.tee}bar\""))
321 (ruby-with-temp-buffer s
322 (goto-char (point-min))
323 (ruby-mode)
324 (font-lock-fontify-buffer)
325 (search-forward "tee")
326 (should (string= (thing-at-point 'symbol) "tee")))))
327
286(ert-deftest ruby-interpolation-inside-percent-literal-with-paren () 328(ert-deftest ruby-interpolation-inside-percent-literal-with-paren ()
287 :expected-result :failed 329 :expected-result :failed
288 (let ((s "%(^#{\")\"}^)")) 330 (let ((s "%(^#{\")\"}^)"))
@@ -296,21 +338,70 @@ VALUES-PLIST is a list with alternating index and value elements."
296 (let ((pairs '(("foo" . "#foo") 338 (let ((pairs '(("foo" . "#foo")
297 ("C.foo" . ".foo") 339 ("C.foo" . ".foo")
298 ("self.foo" . ".foo")))) 340 ("self.foo" . ".foo"))))
299 (loop for (name . value) in pairs 341 (dolist (pair pairs)
300 do (with-temp-buffer 342 (let ((name (car pair))
301 (insert (ruby-test-string 343 (value (cdr pair)))
302 "module M 344 (ruby-with-temp-buffer (ruby-test-string
303 | class C 345 "module M
304 | def %s 346 | class C
305 | end 347 | def %s
306 | end 348 | _
307 |end" 349 | end
308 name)) 350 | end
309 (ruby-mode) 351 |end"
310 (search-backward "def") 352 name)
311 (forward-line) 353 (search-backward "_")
312 (should (string= (ruby-add-log-current-method) 354 (forward-line)
313 (format "M::C%s" value))))))) 355 (should (string= (ruby-add-log-current-method)
356 (format "M::C%s" value))))))))
357
358(ert-deftest ruby-add-log-current-method-outside-of-method ()
359 (ruby-with-temp-buffer (ruby-test-string
360 "module M
361 | class C
362 | def foo
363 | end
364 | _
365 | end
366 |end")
367 (search-backward "_")
368 (should (string= (ruby-add-log-current-method)"M::C"))))
369
370(ert-deftest ruby-add-log-current-method-in-singleton-class ()
371 (ruby-with-temp-buffer (ruby-test-string
372 "class C
373 | class << self
374 | def foo
375 | _
376 | end
377 | end
378 |end")
379 (search-backward "_")
380 (should (string= (ruby-add-log-current-method) "C.foo"))))
381
382(ert-deftest ruby-add-log-current-method-namespace-shorthand ()
383 (ruby-with-temp-buffer (ruby-test-string
384 "class C::D
385 | def foo
386 | _
387 | end
388 |end")
389 (search-backward "_")
390 (should (string= (ruby-add-log-current-method) "C::D#foo"))))
391
392(ert-deftest ruby-add-log-current-method-after-inner-class ()
393 (ruby-with-temp-buffer (ruby-test-string
394 "module M
395 | class C
396 | class D
397 | end
398 | def foo
399 | _
400 | end
401 | end
402 |end")
403 (search-backward "_")
404 (should (string= (ruby-add-log-current-method) "M::C#foo"))))
314 405
315(defvar ruby-block-test-example 406(defvar ruby-block-test-example
316 (ruby-test-string 407 (ruby-test-string
@@ -324,7 +415,8 @@ VALUES-PLIST is a list with alternating index and value elements."
324 | end 415 | end
325 | 416 |
326 | def baz 417 | def baz
327 | some do 418 |some do
419 |3
328 | end 420 | end
329 | end 421 | end
330 |end")) 422 |end"))
@@ -341,7 +433,7 @@ VALUES-PLIST is a list with alternating index and value elements."
341(ruby-deftest-move-to-block works-on-do 433(ruby-deftest-move-to-block works-on-do
342 (goto-line 11) 434 (goto-line 11)
343 (ruby-end-of-block) 435 (ruby-end-of-block)
344 (should (= 12 (line-number-at-pos))) 436 (should (= 13 (line-number-at-pos)))
345 (ruby-beginning-of-block) 437 (ruby-beginning-of-block)
346 (should (= 11 (line-number-at-pos)))) 438 (should (= 11 (line-number-at-pos))))
347 439
@@ -353,13 +445,48 @@ VALUES-PLIST is a list with alternating index and value elements."
353(ruby-deftest-move-to-block ok-with-three 445(ruby-deftest-move-to-block ok-with-three
354 (goto-line 2) 446 (goto-line 2)
355 (ruby-move-to-block 3) 447 (ruby-move-to-block 3)
356 (should (= 13 (line-number-at-pos)))) 448 (should (= 14 (line-number-at-pos))))
357 449
358(ruby-deftest-move-to-block ok-with-minus-two 450(ruby-deftest-move-to-block ok-with-minus-two
359 (goto-line 10) 451 (goto-line 10)
360 (ruby-move-to-block -2) 452 (ruby-move-to-block -2)
361 (should (= 2 (line-number-at-pos)))) 453 (should (= 2 (line-number-at-pos))))
362 454
455(ert-deftest ruby-move-to-block-skips-percent-literal ()
456 (dolist (s (list (ruby-test-string
457 "foo do
458 | a = %%w(
459 | def yaa
460 | )
461 |end")
462 (ruby-test-string
463 "foo do
464 | a = %%w|
465 | end
466 | |
467 |end")))
468 (ruby-with-temp-buffer s
469 (goto-line 1)
470 (ruby-end-of-block)
471 (should (= 5 (line-number-at-pos)))
472 (ruby-beginning-of-block)
473 (should (= 1 (line-number-at-pos))))))
474
475(ert-deftest ruby-move-to-block-skips-heredoc ()
476 (ruby-with-temp-buffer
477 (ruby-test-string
478 "if something_wrong?
479 | ActiveSupport::Deprecation.warn(<<-eowarn)
480 | boo hoo
481 | end
482 | eowarn
483 |end")
484 (goto-line 1)
485 (ruby-end-of-block)
486 (should (= 6 (line-number-at-pos)))
487 (ruby-beginning-of-block)
488 (should (= 1 (line-number-at-pos)))))
489
363(provide 'ruby-mode-tests) 490(provide 'ruby-mode-tests)
364 491
365;;; ruby-mode-tests.el ends here 492;;; ruby-mode-tests.el ends here
diff --git a/test/automated/thingatpt.el b/test/automated/thingatpt.el
new file mode 100644
index 00000000000..f33a8f4b0e6
--- /dev/null
+++ b/test/automated/thingatpt.el
@@ -0,0 +1,88 @@
1;;; thingatpt.el --- tests for thing-at-point.
2
3;; Copyright (C) 2013 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(defvar thing-at-point-test-data
25 '(("http://1.gnu.org" 1 url "http://1.gnu.org")
26 ("http://2.gnu.org" 6 url "http://2.gnu.org")
27 ("http://3.gnu.org" 19 url "http://3.gnu.org")
28 ("https://4.gnu.org" 1 url "https://4.gnu.org")
29 ("bzr://savannah.gnu.org" 1 url "bzr://savannah.gnu.org")
30 ("A geo URI (geo:3.14159,-2.71828)." 12 url "geo:3.14159,-2.71828")
31 ("Visit http://5.gnu.org now." 5 url nil)
32 ("Visit http://6.gnu.org now." 7 url "http://6.gnu.org")
33 ("Visit http://7.gnu.org now." 22 url "http://7.gnu.org")
34 ("Visit http://8.gnu.org now." 22 url "http://8.gnu.org")
35 ("Visit http://9.gnu.org now." 24 url nil)
36 ;; Invalid URIs
37 ("<<<<" 2 url nil)
38 ("<>" 1 url nil)
39 ("<url:>" 1 url nil)
40 ("http://" 1 url nil)
41 ;; Invalid schema
42 ("foo://www.gnu.org" 1 url nil)
43 ("foohttp://www.gnu.org" 1 url nil)
44 ;; Non alphanumeric characters can be found in URIs
45 ("ftp://example.net/~foo!;#bar=baz&goo=bob" 3 url "ftp://example.net/~foo!;#bar=baz&goo=bob")
46 ("bzr+ssh://user@example.net:5/a%20d,5" 34 url "bzr+ssh://user@example.net:5/a%20d,5")
47 ;; <url:...> markup
48 ("Url: <url:foo://1.example.com>..." 8 url "foo://1.example.com")
49 ("Url: <url:foo://2.example.com>..." 30 url "foo://2.example.com")
50 ("Url: <url:foo://www.gnu.org/a bc>..." 20 url "foo://www.gnu.org/a bc")
51 ;; Hack used by thing-at-point: drop punctuation at end of URI.
52 ("Go to http://www.gnu.org, for details" 7 url "http://www.gnu.org")
53 ("Go to http://www.gnu.org." 24 url "http://www.gnu.org")
54 ;; Standard URI delimiters
55 ("Go to \"http://10.gnu.org\"." 8 url "http://10.gnu.org")
56 ("Go to \"http://11.gnu.org/\"." 26 url "http://11.gnu.org/")
57 ("Go to <http://12.gnu.org> now." 8 url "http://12.gnu.org")
58 ("Go to <http://13.gnu.org> now." 24 url "http://13.gnu.org")
59 ;; Parenthesis handling (non-standard)
60 ("http://example.com/a(b)c" 21 url "http://example.com/a(b)c")
61 ("http://example.com/a(b)" 21 url "http://example.com/a(b)")
62 ("(http://example.com/abc)" 2 url "http://example.com/abc")
63 ("This (http://example.com/a(b))" 7 url "http://example.com/a(b)")
64 ("This (http://example.com/a(b))" 30 url "http://example.com/a(b)")
65 ("This (http://example.com/a(b))" 5 url nil)
66 ("http://example.com/ab)c" 4 url "http://example.com/ab)c")
67 ;; URL markup, lacking schema
68 ("<url:foo@example.com>" 1 url "mailto:foo@example.com")
69 ("<url:ftp.example.net/abc/>" 1 url "ftp://ftp.example.net/abc/"))
70 "List of thing-at-point tests.
71Each list element should have the form
72
73 (STRING POS THING RESULT)
74
75where STRING is a string of buffer contents, POS is the value of
76point, THING is a symbol argument for `thing-at-point', and
77RESULT should be the result of calling `thing-at-point' from that
78position to retrieve THING.")
79
80(ert-deftest thing-at-point-tests ()
81 "Test the file-local variables implementation."
82 (dolist (test thing-at-point-test-data)
83 (with-temp-buffer
84 (insert (nth 0 test))
85 (goto-char (nth 1 test))
86 (should (equal (thing-at-point (nth 2 test)) (nth 3 test))))))
87
88;;; thingatpt.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
diff --git a/test/automated/url-future-tests.el b/test/automated/url-future-tests.el
index d499da6dbe2..02ed3285479 100644
--- a/test/automated/url-future-tests.el
+++ b/test/automated/url-future-tests.el
@@ -1,6 +1,6 @@
1;;; url-future-tests.el --- Test suite for url-future. 1;;; url-future-tests.el --- Test suite for url-future.
2 2
3;; Copyright (C) 2011-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5;; Author: Teodor Zlatanov <tzz@lifelogs.com> 5;; Author: Teodor Zlatanov <tzz@lifelogs.com>
6;; Keywords: data 6;; Keywords: data
diff --git a/test/automated/url-util-tests.el b/test/automated/url-util-tests.el
index 65eb37ce926..3955b078dab 100644
--- a/test/automated/url-util-tests.el
+++ b/test/automated/url-util-tests.el
@@ -1,6 +1,6 @@
1;;; url-util-tests.el --- Test suite for url-util. 1;;; url-util-tests.el --- Test suite for url-util.
2 2
3;; Copyright (C) 2012 Free Software Foundation, Inc. 3;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 4
5;; Author: Teodor Zlatanov <tzz@lifelogs.com> 5;; Author: Teodor Zlatanov <tzz@lifelogs.com>
6;; Keywords: data 6;; Keywords: data
diff --git a/test/automated/vc-bzr.el b/test/automated/vc-bzr.el
index 94f8502b882..2776435be82 100644
--- a/test/automated/vc-bzr.el
+++ b/test/automated/vc-bzr.el
@@ -1,6 +1,6 @@
1;;; vc-bzr.el --- tests for vc/vc-bzr.el 1;;; vc-bzr.el --- tests for vc/vc-bzr.el
2 2
3;; Copyright (C) 2011-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5;; Author: Glenn Morris <rgm@gnu.org> 5;; Author: Glenn Morris <rgm@gnu.org>
6 6
diff --git a/test/automated/xml-parse-tests.el b/test/automated/xml-parse-tests.el
index 35009ed36a2..874ae01affb 100644
--- a/test/automated/xml-parse-tests.el
+++ b/test/automated/xml-parse-tests.el
@@ -1,6 +1,6 @@
1;;; xml-parse-tests.el --- Test suite for XML parsing. 1;;; xml-parse-tests.el --- Test suite for XML parsing.
2 2
3;; Copyright (C) 2012 Free Software Foundation, Inc. 3;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 4
5;; Author: Chong Yidong <cyd@stupidchicken.com> 5;; Author: Chong Yidong <cyd@stupidchicken.com>
6;; Keywords: internal 6;; Keywords: internal
diff --git a/test/cedet/cedet-utests.el b/test/cedet/cedet-utests.el
index f5df51dc4c9..0a6fc63e6e8 100644
--- a/test/cedet/cedet-utests.el
+++ b/test/cedet/cedet-utests.el
@@ -1,6 +1,6 @@
1;;; cedet-utests.el --- Run all unit tests in the CEDET suite. 1;;; cedet-utests.el --- Run all unit tests in the CEDET suite.
2 2
3;; Copyright (C) 2008-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
4 4
5;; Author: Eric M. Ludlam <eric@siege-engine.com> 5;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/ede-tests.el b/test/cedet/ede-tests.el
index f73e4bed63f..1aa8b403bc3 100644
--- a/test/cedet/ede-tests.el
+++ b/test/cedet/ede-tests.el
@@ -1,6 +1,6 @@
1;;; ede-tests.el --- Some tests for the Emacs Development Environment 1;;; ede-tests.el --- Some tests for the Emacs Development Environment
2 2
3;; Copyright (C) 2008-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
4 4
5;; Author: Eric M. Ludlam <eric@siege-engine.com> 5;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/semantic-ia-utest.el b/test/cedet/semantic-ia-utest.el
index c523e103669..9907dd9860e 100644
--- a/test/cedet/semantic-ia-utest.el
+++ b/test/cedet/semantic-ia-utest.el
@@ -1,6 +1,6 @@
1;;; semantic-ia-utest.el --- Analyzer unit tests 1;;; semantic-ia-utest.el --- Analyzer unit tests
2 2
3;; Copyright (C) 2008-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
4 4
5;; Author: Eric M. Ludlam <eric@siege-engine.com> 5;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/semantic-tests.el b/test/cedet/semantic-tests.el
index 22b959016c1..c8a4a4cc6ad 100644
--- a/test/cedet/semantic-tests.el
+++ b/test/cedet/semantic-tests.el
@@ -1,6 +1,6 @@
1;;; semantic-utest.el --- Miscellaneous Semantic tests. 1;;; semantic-utest.el --- Miscellaneous Semantic tests.
2 2
3;;; Copyright (C) 2003-2004, 2007-2012 Free Software Foundation, Inc. 3;;; Copyright (C) 2003-2004, 2007-2013 Free Software Foundation, Inc.
4 4
5;; Author: Eric M. Ludlam <zappo@gnu.org> 5;; Author: Eric M. Ludlam <zappo@gnu.org>
6 6
diff --git a/test/cedet/semantic-utest-c.el b/test/cedet/semantic-utest-c.el
index c500f543187..bd94f8536d7 100644
--- a/test/cedet/semantic-utest-c.el
+++ b/test/cedet/semantic-utest-c.el
@@ -1,6 +1,6 @@
1;;; semantic-utest-c.el --- C based parsing tests. 1;;; semantic-utest-c.el --- C based parsing tests.
2 2
3;; Copyright (C) 2008-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
4 4
5;; Author: Eric M. Ludlam <eric@siege-engine.com> 5;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/semantic-utest.el b/test/cedet/semantic-utest.el
index 728106d863c..adfa31dec4e 100644
--- a/test/cedet/semantic-utest.el
+++ b/test/cedet/semantic-utest.el
@@ -1,6 +1,6 @@
1;;; semantic-utest.el --- Tests for semantic's parsing system. 1;;; semantic-utest.el --- Tests for semantic's parsing system.
2 2
3;;; Copyright (C) 2003-2004, 2007-2012 Free Software Foundation, Inc. 3;;; Copyright (C) 2003-2004, 2007-2013 Free Software Foundation, Inc.
4 4
5;; Author: Eric M. Ludlam <zappo@gnu.org> 5;; Author: Eric M. Ludlam <zappo@gnu.org>
6 6
diff --git a/test/cedet/srecode-tests.el b/test/cedet/srecode-tests.el
index d0239f627b3..7ab301898c1 100644
--- a/test/cedet/srecode-tests.el
+++ b/test/cedet/srecode-tests.el
@@ -1,6 +1,6 @@
1;;; srecode-tests.el --- Some tests for CEDET's srecode 1;;; srecode-tests.el --- Some tests for CEDET's srecode
2 2
3;; Copyright (C) 2008-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
4 4
5;; Author: Eric M. Ludlam <eric@siege-engine.com> 5;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/test.c b/test/cedet/tests/test.c
index b2d9971ff4f..d3104ea8272 100644
--- a/test/cedet/tests/test.c
+++ b/test/cedet/tests/test.c
@@ -1,6 +1,6 @@
1/* test.c --- Semantic unit test for C. 1/* test.c --- Semantic unit test for C.
2 2
3 Copyright (C) 2001-2012 Free Software Foundation, Inc. 3 Copyright (C) 2001-2013 Free Software Foundation, Inc.
4 4
5 Author: Eric M. Ludlam <eric@siege-engine.com> 5 Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/test.el b/test/cedet/tests/test.el
index a07a9316f35..f67004aab3e 100644
--- a/test/cedet/tests/test.el
+++ b/test/cedet/tests/test.el
@@ -1,6 +1,6 @@
1;;; test.el --- Unit test file for Semantic Emacs Lisp support. 1;;; test.el --- Unit test file for Semantic Emacs Lisp support.
2 2
3;; Copyright (C) 2005-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2005-2013 Free Software Foundation, Inc.
4 4
5;; Author: Eric M. Ludlam <eric@siege-engine.com> 5;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/test.make b/test/cedet/tests/test.make
index cc9d450c1e0..57b58b58599 100644
--- a/test/cedet/tests/test.make
+++ b/test/cedet/tests/test.make
@@ -1,6 +1,6 @@
1# test.make --- Semantic unit test for Make -*- makefile -*- 1# test.make --- Semantic unit test for Make -*- makefile -*-
2 2
3# Copyright (C) 2001-2002, 2010-2012 Free Software Foundation, Inc. 3# Copyright (C) 2001-2002, 2010-2013 Free Software Foundation, Inc.
4 4
5# Author: Eric M. Ludlam <eric@siege-engine.com> 5# Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/testdoublens.cpp b/test/cedet/tests/testdoublens.cpp
index 72a7e10dc5a..e398f1c8261 100644
--- a/test/cedet/tests/testdoublens.cpp
+++ b/test/cedet/tests/testdoublens.cpp
@@ -1,6 +1,6 @@
1// testdoublens.cpp --- semantic-ia-utest completion engine unit tests 1// testdoublens.cpp --- semantic-ia-utest completion engine unit tests
2 2
3// Copyright (C) 2008-2012 Free Software Foundation, Inc. 3// Copyright (C) 2008-2013 Free Software Foundation, Inc.
4 4
5// Author: Eric M. Ludlam <eric@siege-engine.com> 5// Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/testdoublens.hpp b/test/cedet/tests/testdoublens.hpp
index 69475ee3c19..5dbe12cdf4b 100644
--- a/test/cedet/tests/testdoublens.hpp
+++ b/test/cedet/tests/testdoublens.hpp
@@ -1,6 +1,6 @@
1// testdoublens.hpp --- Header file used in one of the Semantic tests 1// testdoublens.hpp --- Header file used in one of the Semantic tests
2 2
3// Copyright (C) 2008-2012 Free Software Foundation, Inc. 3// Copyright (C) 2008-2013 Free Software Foundation, Inc.
4 4
5// Author: Eric M. Ludlam <eric@siege-engine.com> 5// Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/testjavacomp.java b/test/cedet/tests/testjavacomp.java
index 54b9f4aa004..f716c9ad2d3 100644
--- a/test/cedet/tests/testjavacomp.java
+++ b/test/cedet/tests/testjavacomp.java
@@ -1,6 +1,6 @@
1// testjavacomp.java --- Semantic unit test for Java 1// testjavacomp.java --- Semantic unit test for Java
2 2
3// Copyright (C) 2009-2012 Free Software Foundation, Inc. 3// Copyright (C) 2009-2013 Free Software Foundation, Inc.
4 4
5// Author: Eric M. Ludlam <eric@siege-engine.com> 5// Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/testpolymorph.cpp b/test/cedet/tests/testpolymorph.cpp
index 2108da14e56..f21b3ef57f7 100644
--- a/test/cedet/tests/testpolymorph.cpp
+++ b/test/cedet/tests/testpolymorph.cpp
@@ -1,6 +1,6 @@
1/** testpolymorph.cpp --- A sequence of polymorphism examples. 1/** testpolymorph.cpp --- A sequence of polymorphism examples.
2 * 2 *
3 * Copyright (C) 2009-2012 Free Software Foundation, Inc. 3 * Copyright (C) 2009-2013 Free Software Foundation, Inc.
4 * 4 *
5 * Author: Eric M. Ludlam <eric@siege-engine.com> 5 * Author: Eric M. Ludlam <eric@siege-engine.com>
6 * 6 *
diff --git a/test/cedet/tests/testspp.c b/test/cedet/tests/testspp.c
index 1fbabd62d14..f63dec0c407 100644
--- a/test/cedet/tests/testspp.c
+++ b/test/cedet/tests/testspp.c
@@ -1,6 +1,6 @@
1/* testspp.cpp --- Semantic unit test for the C preprocessor 1/* testspp.cpp --- Semantic unit test for the C preprocessor
2 2
3 Copyright (C) 2007-2012 Free Software Foundation, Inc. 3 Copyright (C) 2007-2013 Free Software Foundation, Inc.
4 4
5 Author: Eric M. Ludlam <eric@siege-engine.com> 5 Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/testsppreplace.c b/test/cedet/tests/testsppreplace.c
index 36b4cb5fa57..629128c8d8f 100644
--- a/test/cedet/tests/testsppreplace.c
+++ b/test/cedet/tests/testsppreplace.c
@@ -1,5 +1,5 @@
1/* testsppreplace.c --- unit test for CPP/SPP Replacement 1/* testsppreplace.c --- unit test for CPP/SPP Replacement
2 Copyright (C) 2007-2012 Free Software Foundation, Inc. 2 Copyright (C) 2007-2013 Free Software Foundation, Inc.
3 3
4 Author: Eric M. Ludlam <eric@siege-engine.com> 4 Author: Eric M. Ludlam <eric@siege-engine.com>
5 5
diff --git a/test/cedet/tests/testsppreplaced.c b/test/cedet/tests/testsppreplaced.c
index 19e3b7ec869..3c2b1a04f5b 100644
--- a/test/cedet/tests/testsppreplaced.c
+++ b/test/cedet/tests/testsppreplaced.c
@@ -1,5 +1,5 @@
1/* testsppreplaced.c --- unit test for CPP/SPP Replacement 1/* testsppreplaced.c --- unit test for CPP/SPP Replacement
2 Copyright (C) 2007-2012 Free Software Foundation, Inc. 2 Copyright (C) 2007-2013 Free Software Foundation, Inc.
3 3
4 Author: Eric M. Ludlam <eric@siege-engine.com> 4 Author: Eric M. Ludlam <eric@siege-engine.com>
5 5
diff --git a/test/cedet/tests/testsubclass.cpp b/test/cedet/tests/testsubclass.cpp
index 3fb61053a41..a3b4ec4db2a 100644
--- a/test/cedet/tests/testsubclass.cpp
+++ b/test/cedet/tests/testsubclass.cpp
@@ -1,6 +1,6 @@
1// testsubclass.cpp --- unit test for analyzer and complex C++ inheritance 1// testsubclass.cpp --- unit test for analyzer and complex C++ inheritance
2 2
3// Copyright (C) 2007-2012 Free Software Foundation, Inc. 3// Copyright (C) 2007-2013 Free Software Foundation, Inc.
4 4
5// Author: Eric M. Ludlam <eric@siege-engine.com> 5// Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/testsubclass.hh b/test/cedet/tests/testsubclass.hh
index dee470b899f..125e801b69d 100644
--- a/test/cedet/tests/testsubclass.hh
+++ b/test/cedet/tests/testsubclass.hh
@@ -1,6 +1,6 @@
1// testsubclass.hh --- unit test for analyzer and complex C++ inheritance 1// testsubclass.hh --- unit test for analyzer and complex C++ inheritance
2 2
3// Copyright (C) 2007-2012 Free Software Foundation, Inc. 3// Copyright (C) 2007-2013 Free Software Foundation, Inc.
4 4
5// Author: Eric M. Ludlam <eric@siege-engine.com> 5// Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/testtypedefs.cpp b/test/cedet/tests/testtypedefs.cpp
index f3666bea316..ce59b6de0df 100644
--- a/test/cedet/tests/testtypedefs.cpp
+++ b/test/cedet/tests/testtypedefs.cpp
@@ -1,6 +1,6 @@
1// testtypedefs.cpp --- Sample with some fake bits out of std::string 1// testtypedefs.cpp --- Sample with some fake bits out of std::string
2 2
3// Copyright (C) 2008-2012 Free Software Foundation, Inc. 3// Copyright (C) 2008-2013 Free Software Foundation, Inc.
4 4
5// Author: Eric M. Ludlam <eric@siege-engine.com> 5// Author: Eric M. Ludlam <eric@siege-engine.com>
6 6
diff --git a/test/cedet/tests/testvarnames.c b/test/cedet/tests/testvarnames.c
index 5cade2f0bd8..a252b9d9925 100644
--- a/test/cedet/tests/testvarnames.c
+++ b/test/cedet/tests/testvarnames.c
@@ -1,7 +1,7 @@
1/* testvarnames.cpp 1/* testvarnames.cpp
2 Test variable and function names, lists of variables on one line, etc. 2 Test variable and function names, lists of variables on one line, etc.
3 3
4 Copyright (C) 2008-2012 Free Software Foundation, Inc. 4 Copyright (C) 2008-2013 Free Software Foundation, Inc.
5 5
6 Author: Eric M. Ludlam <eric@siege-engine.com> 6 Author: Eric M. Ludlam <eric@siege-engine.com>
7 7
diff --git a/test/eshell.el b/test/eshell.el
index 4d6480c81bb..7baeb58a56a 100644
--- a/test/eshell.el
+++ b/test/eshell.el
@@ -1,6 +1,6 @@
1;;; esh-test.el --- Eshell test suite 1;;; esh-test.el --- Eshell test suite
2 2
3;; Copyright (C) 1999-2012 Free Software Foundation, Inc. 3;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
4 4
5;; Author: John Wiegley <johnw@gnu.org> 5;; Author: John Wiegley <johnw@gnu.org>
6 6
diff --git a/test/indent/octave.m b/test/indent/octave.m
index 4c2fa6c8435..bc7784f1ba2 100644
--- a/test/indent/octave.m
+++ b/test/indent/octave.m
@@ -1,4 +1,4 @@
1## -*- octave -*- 1## -*- mode: octave; coding: utf-8 -*-
2 2
3function res = tcomp (fn) 3function res = tcomp (fn)
4 %% res = tcomp (fn) 4 %% res = tcomp (fn)
@@ -35,7 +35,7 @@ function res = tcomp (fn)
35 35
36endfunction 36endfunction
37 37
38## Copyright (C) 2005, 2006, 2007, 2008, 2009 Sren Hauberg 38## Copyright (C) 2005, 2006, 2007, 2008, 2009 Søren Hauberg
39## 39##
40## This file is part of Octave. 40## This file is part of Octave.
41## 41##
diff --git a/test/indent/pascal.pas b/test/indent/pascal.pas
index 07a21f23c3c..0dda0c47fef 100644
--- a/test/indent/pascal.pas
+++ b/test/indent/pascal.pas
@@ -1,6 +1,6 @@
1{ GPC demo program for the CRT unit. 1{ GPC demo program for the CRT unit.
2 2
3Copyright (C) 1999-2006 Free Software Foundation, Inc. 3Copyright (C) 1999-2006, 2013 Free Software Foundation, Inc.
4 4
5Author: Frank Heckenbach <frank@pascal.gnu.de> 5Author: Frank Heckenbach <frank@pascal.gnu.de>
6 6
@@ -14,9 +14,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details. 14General Public License for more details.
15 15
16You should have received a copy of the GNU General Public License 16You should have received a copy of the GNU General Public License
17along with this program; see the file COPYING. If not, write to 17along with this program. If not, see <http://www.gnu.org/licenses/>.
18the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA.
20 18
21As a special exception, if you incorporate even large parts of the 19As a special exception, if you incorporate even large parts of the
22code of this demo program into another program with substantially 20code of this demo program into another program with substantially
@@ -27,6 +25,8 @@ by the GNU General Public License. }
27 25
28{$gnu-pascal,I+} 26{$gnu-pascal,I+}
29 27
28// Free-pascal style comment.
29
30program CRTDemo; 30program CRTDemo;
31 31
32uses GPC, CRT; 32uses GPC, CRT;
diff --git a/test/indent/shell.sh b/test/indent/shell.sh
index 6f3447c3aa9..790656501d1 100755
--- a/test/indent/shell.sh
+++ b/test/indent/shell.sh
@@ -5,6 +5,18 @@ setlock -n /tmp/getmail.lock && echo getmail isn\'t running
5 5
6# adsgsdg 6# adsgsdg
7 7
8case $X in
9 foo)
10 do_something
11 ;;
12 arg=*) # bug#12953
13 do_something_else_based_on_arg
14 ;;
15 *)
16 default
17 ;;
18esac
19
8echo -n $(( 5 << 2 )) 20echo -n $(( 5 << 2 ))
9# This should not be treated as a heredoc (bug#12770). 21# This should not be treated as a heredoc (bug#12770).
102 222
diff --git a/test/redisplay-testsuite.el b/test/redisplay-testsuite.el
index 39f81a13c60..a710bc87a39 100644
--- a/test/redisplay-testsuite.el
+++ b/test/redisplay-testsuite.el
@@ -1,6 +1,6 @@
1;;; redisplay-testsuite.el --- Test suite for redisplay. 1;;; redisplay-testsuite.el --- Test suite for redisplay.
2 2
3;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
4 4
5;; Author: Chong Yidong <cyd@stupidchicken.com> 5;; Author: Chong Yidong <cyd@stupidchicken.com>
6;; Keywords: internal 6;; Keywords: internal
diff --git a/test/rmailmm.el b/test/rmailmm.el
index 6844eb8187b..8f33b1d11f9 100644
--- a/test/rmailmm.el
+++ b/test/rmailmm.el
@@ -1,6 +1,6 @@
1;;; rmailmm.el --- tests for mail/rmailmm.el 1;;; rmailmm.el --- tests for mail/rmailmm.el
2 2
3;; Copyright (C) 2006-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2006-2013 Free Software Foundation, Inc.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
6 6