aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKenichi Handa2012-11-23 23:36:24 +0900
committerKenichi Handa2012-11-23 23:36:24 +0900
commit2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9 (patch)
tree3711b97807201b7eeaa066003b1c3a4ce929e5bb /test
parente1d276cbf9e18f13101328f56bed1a1c0a66e63a (diff)
parente7d0e5ee247a155a268ffbf80bedbe25e15b5032 (diff)
downloademacs-2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9.tar.gz
emacs-2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9.zip
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog15
-rw-r--r--test/automated/advice-tests.el129
-rw-r--r--test/automated/ert-tests.el132
-rw-r--r--test/automated/ert-x-tests.el50
4 files changed, 176 insertions, 150 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index f11325d0318..b66c2925287 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,14 @@
12012-11-20 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * automated/advice-tests.el (advice-tests--data): Remove.
4 (advice-tests): Move the tests directly here instead.
5 Add called-interactively-p tests.
6
72012-11-19 Stefan Monnier <monnier@iro.umontreal.ca>
8
9 * automated/ert-x-tests.el: Use cl-lib.
10 * automated/ert-tests.el: Use lexical-binding and cl-lib.
11
12012-11-14 Dmitry Gutov <dgutov@yandex.ru> 122012-11-14 Dmitry Gutov <dgutov@yandex.ru>
2 13
3 * automated/ruby-mode-tests.el (ruby-indent-singleton-class): Pass. 14 * automated/ruby-mode-tests.el (ruby-indent-singleton-class): Pass.
@@ -5,8 +16,8 @@
5 (ruby-indent-inside-heredoc-after-space): New tests. 16 (ruby-indent-inside-heredoc-after-space): New tests.
6 Change direct font-lock face references to var references. 17 Change direct font-lock face references to var references.
7 (ruby-interpolation-suppresses-syntax-inside): New test. 18 (ruby-interpolation-suppresses-syntax-inside): New test.
8 (ruby-interpolation-inside-percent-literal-with-paren): New 19 (ruby-interpolation-inside-percent-literal-with-paren):
9 failing test. 20 New failing test.
10 21
112012-11-13 Dmitry Gutov <dgutov@yandex.ru> 222012-11-13 Dmitry Gutov <dgutov@yandex.ru>
12 23
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el
index 80321f8f3f9..94f69e77e43 100644
--- a/test/automated/advice-tests.el
+++ b/test/automated/advice-tests.el
@@ -21,81 +21,94 @@
21 21
22;;; Code: 22;;; Code:
23 23
24(defvar advice-tests--data 24(ert-deftest advice-tests ()
25 '(((defun sm-test1 (x) (+ x 4)) 25 "Test advice code."
26 (sm-test1 6) 10) 26 (with-temp-buffer
27 ((advice-add 'sm-test1 :around (lambda (f y) (* (funcall f y) 5))) 27 (defun sm-test1 (x) (+ x 4))
28 (sm-test1 6) 50) 28 (should (equal (sm-test1 6) 10))
29 ((defun sm-test1 (x) (+ x 14)) 29 (advice-add 'sm-test1 :around (lambda (f y) (* (funcall f y) 5)))
30 (sm-test1 6) 100) 30 (should (equal (sm-test1 6) 50))
31 ((null (get 'sm-test1 'defalias-fset-function)) nil) 31 (defun sm-test1 (x) (+ x 14))
32 ((advice-remove 'sm-test1 (lambda (f y) (* (funcall f y) 5))) 32 (should (equal (sm-test1 6) 100))
33 (sm-test1 6) 20) 33 (should (equal (null (get 'sm-test1 'defalias-fset-function)) nil))
34 ((null (get 'sm-test1 'defalias-fset-function)) t) 34 (advice-remove 'sm-test1 (lambda (f y) (* (funcall f y) 5)))
35 35 (should (equal (sm-test1 6) 20))
36 ((defun sm-test2 (x) (+ x 4)) 36 (should (equal (null (get 'sm-test1 'defalias-fset-function)) t))
37 (sm-test2 6) 10) 37
38 ((defadvice sm-test2 (around sm-test activate) 38 (defun sm-test2 (x) (+ x 4))
39 (should (equal (sm-test2 6) 10))
40 (defadvice sm-test2 (around sm-test activate)
39 ad-do-it (setq ad-return-value (* ad-return-value 5))) 41 ad-do-it (setq ad-return-value (* ad-return-value 5)))
40 (sm-test2 6) 50) 42 (should (equal (sm-test2 6) 50))
41 ((ad-deactivate 'sm-test2) 43 (ad-deactivate 'sm-test2)
42 (sm-test2 6) 10) 44 (should (equal (sm-test2 6) 10))
43 ((ad-activate 'sm-test2) 45 (ad-activate 'sm-test2)
44 (sm-test2 6) 50) 46 (should (equal (sm-test2 6) 50))
45 ((defun sm-test2 (x) (+ x 14)) 47 (defun sm-test2 (x) (+ x 14))
46 (sm-test2 6) 100) 48 (should (equal (sm-test2 6) 100))
47 ((null (get 'sm-test2 'defalias-fset-function)) nil) 49 (should (equal (null (get 'sm-test2 'defalias-fset-function)) nil))
48 ((ad-remove-advice 'sm-test2 'around 'sm-test) 50 (ad-remove-advice 'sm-test2 'around 'sm-test)
49 (sm-test2 6) 100) 51 (should (equal (sm-test2 6) 100))
50 ((ad-activate 'sm-test2) 52 (ad-activate 'sm-test2)
51 (sm-test2 6) 20) 53 (should (equal (sm-test2 6) 20))
52 ((null (get 'sm-test2 'defalias-fset-function)) t) 54 (should (equal (null (get 'sm-test2 'defalias-fset-function)) t))
53 55
54 ((advice-add 'sm-test3 :around 56 (advice-add 'sm-test3 :around
55 (lambda (f &rest args) `(toto ,(apply f args))) 57 (lambda (f &rest args) `(toto ,(apply f args)))
56 '((name . wrap-with-toto))) 58 '((name . wrap-with-toto)))
57 (defmacro sm-test3 (x) `(call-test3 ,x)) 59 (defmacro sm-test3 (x) `(call-test3 ,x))
58 (macroexpand '(sm-test3 56)) (toto (call-test3 56))) 60 (should (equal (macroexpand '(sm-test3 56)) '(toto (call-test3 56))))
59 61
60 ((defadvice sm-test4 (around wrap-with-toto activate) 62 (defadvice sm-test4 (around wrap-with-toto activate)
61 ad-do-it (setq ad-return-value `(toto ,ad-return-value))) 63 ad-do-it (setq ad-return-value `(toto ,ad-return-value)))
62 (defmacro sm-test4 (x) `(call-test4 ,x)) 64 (defmacro sm-test4 (x) `(call-test4 ,x))
63 (macroexpand '(sm-test4 56)) (toto (call-test4 56))) 65 (should (equal (macroexpand '(sm-test4 56)) '(toto (call-test4 56))))
64 ((defmacro sm-test4 (x) `(call-testq ,x)) 66 (defmacro sm-test4 (x) `(call-testq ,x))
65 (macroexpand '(sm-test4 56)) (toto (call-testq 56))) 67 (should (equal (macroexpand '(sm-test4 56)) '(toto (call-testq 56))))
66 68
67 ;; Combining old style and new style advices. 69 ;; Combining old style and new style advices.
68 ((defun sm-test5 (x) (+ x 4)) 70 (defun sm-test5 (x) (+ x 4))
69 (sm-test5 6) 10) 71 (should (equal (sm-test5 6) 10))
70 ((advice-add 'sm-test5 :around (lambda (f y) (* (funcall f y) 5))) 72 (advice-add 'sm-test5 :around (lambda (f y) (* (funcall f y) 5)))
71 (sm-test5 6) 50) 73 (should (equal (sm-test5 6) 50))
72 ((defadvice sm-test5 (around test activate) 74 (defadvice sm-test5 (around test activate)
73 ad-do-it (setq ad-return-value (+ ad-return-value 0.1))) 75 ad-do-it (setq ad-return-value (+ ad-return-value 0.1)))
74 (sm-test5 5) 45.1) 76 (should (equal (sm-test5 5) 45.1))
75 ((ad-deactivate 'sm-test5) 77 (ad-deactivate 'sm-test5)
76 (sm-test5 6) 50) 78 (should (equal (sm-test5 6) 50))
77 ((ad-activate 'sm-test5) 79 (ad-activate 'sm-test5)
78 (sm-test5 6) 50.1) 80 (should (equal (sm-test5 6) 50.1))
79 ((defun sm-test5 (x) (+ x 14)) 81 (defun sm-test5 (x) (+ x 14))
80 (sm-test5 6) 100.1) 82 (should (equal (sm-test5 6) 100.1))
81 ((advice-remove 'sm-test5 (lambda (f y) (* (funcall f y) 5))) 83 (advice-remove 'sm-test5 (lambda (f y) (* (funcall f y) 5)))
82 (sm-test5 6) 20.1) 84 (should (equal (sm-test5 6) 20.1))
83 85
84 ;; This used to signal an error (bug#12858). 86 ;; This used to signal an error (bug#12858).
85 ((autoload 'sm-test6 "foo") 87 (autoload 'sm-test6 "foo")
86 (defadvice sm-test6 (around test activate) 88 (defadvice sm-test6 (around test activate)
87 ad-do-it) 89 ad-do-it)
88 t t)
89 90
91 ;; Check interaction between advice and called-interactively-p.
92 (defun sm-test7 (&optional x) (interactive) (+ (or x 7) 4))
93 (advice-add 'sm-test7 :around
94 (lambda (f &rest args)
95 (list (cons 1 (called-interactively-p)) (apply f args))))
96 (should (equal (sm-test7) '((1 . nil) 11)))
97 (should (equal (call-interactively 'sm-test7) '((1 . t) 11)))
98 (let ((smi 7))
99 (advice-add 'sm-test7 :before
100 (lambda (&rest args)
101 (setq smi (called-interactively-p))))
102 (should (equal (list (sm-test7) smi)
103 '(((1 . nil) 11) nil)))
104 (should (equal (list (call-interactively 'sm-test7) smi)
105 '(((1 . t) 11) t))))
106 (advice-add 'sm-test7 :around
107 (lambda (f &rest args)
108 (cons (cons 2 (called-interactively-p)) (apply f args))))
109 (should (equal (call-interactively 'sm-test7) '((2 . t) (1 . t) 11)))
90 )) 110 ))
91 111
92(ert-deftest advice-tests ()
93 "Test advice code."
94 (with-temp-buffer
95 (dolist (test advice-tests--data)
96 (let ((res (eval `(progn ,@(butlast test)))))
97 (should (equal (car (last test)) res))))))
98
99;; Local Variables: 112;; Local Variables:
100;; no-byte-compile: t 113;; no-byte-compile: t
101;; End: 114;; End:
diff --git a/test/automated/ert-tests.el b/test/automated/ert-tests.el
index 1778afea802..1aef1921871 100644
--- a/test/automated/ert-tests.el
+++ b/test/automated/ert-tests.el
@@ -1,4 +1,4 @@
1;;; ert-tests.el --- ERT's self-tests 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-2012 Free Software Foundation, Inc.
4 4
@@ -27,7 +27,7 @@
27;;; Code: 27;;; Code:
28 28
29(eval-when-compile 29(eval-when-compile
30 (require 'cl)) 30 (require 'cl-lib))
31(require 'ert) 31(require 'ert)
32 32
33 33
@@ -45,7 +45,7 @@
45 ;; The buffer name chosen here should not compete with the default 45 ;; The buffer name chosen here should not compete with the default
46 ;; results buffer name for completion in `switch-to-buffer'. 46 ;; results buffer name for completion in `switch-to-buffer'.
47 (let ((stats (ert-run-tests-interactively "^ert-" " *ert self-tests*"))) 47 (let ((stats (ert-run-tests-interactively "^ert-" " *ert self-tests*")))
48 (assert ert--test-body-was-run) 48 (cl-assert ert--test-body-was-run)
49 (if (zerop (ert-stats-completed-unexpected stats)) 49 (if (zerop (ert-stats-completed-unexpected stats))
50 ;; Hide results window only when everything went well. 50 ;; Hide results window only when everything went well.
51 (set-window-configuration window-configuration) 51 (set-window-configuration window-configuration)
@@ -71,26 +71,26 @@ failed or if there was a problem."
71 71
72(ert-deftest ert-test-nested-test-body-runs () 72(ert-deftest ert-test-nested-test-body-runs ()
73 "Test that nested test bodies run." 73 "Test that nested test bodies run."
74 (lexical-let ((was-run nil)) 74 (let ((was-run nil))
75 (let ((test (make-ert-test :body (lambda () 75 (let ((test (make-ert-test :body (lambda ()
76 (setq was-run t))))) 76 (setq was-run t)))))
77 (assert (not was-run)) 77 (cl-assert (not was-run))
78 (ert-run-test test) 78 (ert-run-test test)
79 (assert was-run)))) 79 (cl-assert was-run))))
80 80
81 81
82;;; Test that pass/fail works. 82;;; Test that pass/fail works.
83(ert-deftest ert-test-pass () 83(ert-deftest ert-test-pass ()
84 (let ((test (make-ert-test :body (lambda ())))) 84 (let ((test (make-ert-test :body (lambda ()))))
85 (let ((result (ert-run-test test))) 85 (let ((result (ert-run-test test)))
86 (assert (ert-test-passed-p result))))) 86 (cl-assert (ert-test-passed-p result)))))
87 87
88(ert-deftest ert-test-fail () 88(ert-deftest ert-test-fail ()
89 (let ((test (make-ert-test :body (lambda () (ert-fail "failure message"))))) 89 (let ((test (make-ert-test :body (lambda () (ert-fail "failure message")))))
90 (let ((result (let ((ert-debug-on-error nil)) 90 (let ((result (let ((ert-debug-on-error nil))
91 (ert-run-test test)))) 91 (ert-run-test test))))
92 (assert (ert-test-failed-p result) t) 92 (cl-assert (ert-test-failed-p result) t)
93 (assert (equal (ert-test-result-with-condition-condition result) 93 (cl-assert (equal (ert-test-result-with-condition-condition result)
94 '(ert-test-failed "failure message")) 94 '(ert-test-failed "failure message"))
95 t)))) 95 t))))
96 96
@@ -100,50 +100,50 @@ failed or if there was a problem."
100 (progn 100 (progn
101 (let ((ert-debug-on-error t)) 101 (let ((ert-debug-on-error t))
102 (ert-run-test test)) 102 (ert-run-test test))
103 (assert nil)) 103 (cl-assert nil))
104 ((error) 104 ((error)
105 (assert (equal condition '(ert-test-failed "failure message")) t))))) 105 (cl-assert (equal condition '(ert-test-failed "failure message")) t)))))
106 106
107(ert-deftest ert-test-fail-debug-with-debugger-1 () 107(ert-deftest ert-test-fail-debug-with-debugger-1 ()
108 (let ((test (make-ert-test :body (lambda () (ert-fail "failure message"))))) 108 (let ((test (make-ert-test :body (lambda () (ert-fail "failure message")))))
109 (let ((debugger (lambda (&rest debugger-args) 109 (let ((debugger (lambda (&rest _args)
110 (assert nil)))) 110 (cl-assert nil))))
111 (let ((ert-debug-on-error nil)) 111 (let ((ert-debug-on-error nil))
112 (ert-run-test test))))) 112 (ert-run-test test)))))
113 113
114(ert-deftest ert-test-fail-debug-with-debugger-2 () 114(ert-deftest ert-test-fail-debug-with-debugger-2 ()
115 (let ((test (make-ert-test :body (lambda () (ert-fail "failure message"))))) 115 (let ((test (make-ert-test :body (lambda () (ert-fail "failure message")))))
116 (block nil 116 (cl-block nil
117 (let ((debugger (lambda (&rest debugger-args) 117 (let ((debugger (lambda (&rest _args)
118 (return-from nil nil)))) 118 (cl-return-from nil nil))))
119 (let ((ert-debug-on-error t)) 119 (let ((ert-debug-on-error t))
120 (ert-run-test test)) 120 (ert-run-test test))
121 (assert nil))))) 121 (cl-assert nil)))))
122 122
123(ert-deftest ert-test-fail-debug-nested-with-debugger () 123(ert-deftest ert-test-fail-debug-nested-with-debugger ()
124 (let ((test (make-ert-test :body (lambda () 124 (let ((test (make-ert-test :body (lambda ()
125 (let ((ert-debug-on-error t)) 125 (let ((ert-debug-on-error t))
126 (ert-fail "failure message")))))) 126 (ert-fail "failure message"))))))
127 (let ((debugger (lambda (&rest debugger-args) 127 (let ((debugger (lambda (&rest _args)
128 (assert nil nil "Assertion a")))) 128 (cl-assert nil nil "Assertion a"))))
129 (let ((ert-debug-on-error nil)) 129 (let ((ert-debug-on-error nil))
130 (ert-run-test test)))) 130 (ert-run-test test))))
131 (let ((test (make-ert-test :body (lambda () 131 (let ((test (make-ert-test :body (lambda ()
132 (let ((ert-debug-on-error nil)) 132 (let ((ert-debug-on-error nil))
133 (ert-fail "failure message")))))) 133 (ert-fail "failure message"))))))
134 (block nil 134 (cl-block nil
135 (let ((debugger (lambda (&rest debugger-args) 135 (let ((debugger (lambda (&rest _args)
136 (return-from nil nil)))) 136 (cl-return-from nil nil))))
137 (let ((ert-debug-on-error t)) 137 (let ((ert-debug-on-error t))
138 (ert-run-test test)) 138 (ert-run-test test))
139 (assert nil nil "Assertion b"))))) 139 (cl-assert nil nil "Assertion b")))))
140 140
141(ert-deftest ert-test-error () 141(ert-deftest ert-test-error ()
142 (let ((test (make-ert-test :body (lambda () (error "Error message"))))) 142 (let ((test (make-ert-test :body (lambda () (error "Error message")))))
143 (let ((result (let ((ert-debug-on-error nil)) 143 (let ((result (let ((ert-debug-on-error nil))
144 (ert-run-test test)))) 144 (ert-run-test test))))
145 (assert (ert-test-failed-p result) t) 145 (cl-assert (ert-test-failed-p result) t)
146 (assert (equal (ert-test-result-with-condition-condition result) 146 (cl-assert (equal (ert-test-result-with-condition-condition result)
147 '(error "Error message")) 147 '(error "Error message"))
148 t)))) 148 t))))
149 149
@@ -153,9 +153,9 @@ failed or if there was a problem."
153 (progn 153 (progn
154 (let ((ert-debug-on-error t)) 154 (let ((ert-debug-on-error t))
155 (ert-run-test test)) 155 (ert-run-test test))
156 (assert nil)) 156 (cl-assert nil))
157 ((error) 157 ((error)
158 (assert (equal condition '(error "Error message")) t))))) 158 (cl-assert (equal condition '(error "Error message")) t)))))
159 159
160 160
161;;; Test that `should' works. 161;;; Test that `should' works.
@@ -163,13 +163,13 @@ failed or if there was a problem."
163 (let ((test (make-ert-test :body (lambda () (should nil))))) 163 (let ((test (make-ert-test :body (lambda () (should nil)))))
164 (let ((result (let ((ert-debug-on-error nil)) 164 (let ((result (let ((ert-debug-on-error nil))
165 (ert-run-test test)))) 165 (ert-run-test test))))
166 (assert (ert-test-failed-p result) t) 166 (cl-assert (ert-test-failed-p result) t)
167 (assert (equal (ert-test-result-with-condition-condition result) 167 (cl-assert (equal (ert-test-result-with-condition-condition result)
168 '(ert-test-failed ((should nil) :form nil :value nil))) 168 '(ert-test-failed ((should nil) :form nil :value nil)))
169 t))) 169 t)))
170 (let ((test (make-ert-test :body (lambda () (should t))))) 170 (let ((test (make-ert-test :body (lambda () (should t)))))
171 (let ((result (ert-run-test test))) 171 (let ((result (ert-run-test test)))
172 (assert (ert-test-passed-p result) t)))) 172 (cl-assert (ert-test-passed-p result) t))))
173 173
174(ert-deftest ert-test-should-value () 174(ert-deftest ert-test-should-value ()
175 (should (eql (should 'foo) 'foo)) 175 (should (eql (should 'foo) 'foo))
@@ -179,17 +179,18 @@ failed or if there was a problem."
179 (let ((test (make-ert-test :body (lambda () (should-not t))))) 179 (let ((test (make-ert-test :body (lambda () (should-not t)))))
180 (let ((result (let ((ert-debug-on-error nil)) 180 (let ((result (let ((ert-debug-on-error nil))
181 (ert-run-test test)))) 181 (ert-run-test test))))
182 (assert (ert-test-failed-p result) t) 182 (cl-assert (ert-test-failed-p result) t)
183 (assert (equal (ert-test-result-with-condition-condition result) 183 (cl-assert (equal (ert-test-result-with-condition-condition result)
184 '(ert-test-failed ((should-not t) :form t :value t))) 184 '(ert-test-failed ((should-not t) :form t :value t)))
185 t))) 185 t)))
186 (let ((test (make-ert-test :body (lambda () (should-not nil))))) 186 (let ((test (make-ert-test :body (lambda () (should-not nil)))))
187 (let ((result (ert-run-test test))) 187 (let ((result (ert-run-test test)))
188 (assert (ert-test-passed-p result))))) 188 (cl-assert (ert-test-passed-p result)))))
189
189 190
190(ert-deftest ert-test-should-with-macrolet () 191(ert-deftest ert-test-should-with-macrolet ()
191 (let ((test (make-ert-test :body (lambda () 192 (let ((test (make-ert-test :body (lambda ()
192 (macrolet ((foo () `(progn t nil))) 193 (cl-macrolet ((foo () `(progn t nil)))
193 (should (foo))))))) 194 (should (foo)))))))
194 (let ((result (let ((ert-debug-on-error nil)) 195 (let ((result (let ((ert-debug-on-error nil))
195 (ert-run-test test)))) 196 (ert-run-test test))))
@@ -303,32 +304,33 @@ This macro is used to test if macroexpansion in `should' works."
303 304
304(ert-deftest ert-test-should-failure-debugging () 305(ert-deftest ert-test-should-failure-debugging ()
305 "Test that `should' errors contain the information we expect them to." 306 "Test that `should' errors contain the information we expect them to."
306 (loop for (body expected-condition) in 307 (cl-loop
307 `((,(lambda () (let ((x nil)) (should x))) 308 for (body expected-condition) in
308 (ert-test-failed ((should x) :form x :value nil))) 309 `((,(lambda () (let ((x nil)) (should x)))
309 (,(lambda () (let ((x t)) (should-not x))) 310 (ert-test-failed ((should x) :form x :value nil)))
310 (ert-test-failed ((should-not x) :form x :value t))) 311 (,(lambda () (let ((x t)) (should-not x)))
311 (,(lambda () (let ((x t)) (should (not x)))) 312 (ert-test-failed ((should-not x) :form x :value t)))
312 (ert-test-failed ((should (not x)) :form (not t) :value nil))) 313 (,(lambda () (let ((x t)) (should (not x))))
313 (,(lambda () (let ((x nil)) (should-not (not x)))) 314 (ert-test-failed ((should (not x)) :form (not t) :value nil)))
314 (ert-test-failed ((should-not (not x)) :form (not nil) :value t))) 315 (,(lambda () (let ((x nil)) (should-not (not x))))
315 (,(lambda () (let ((x t) (y nil)) (should-not 316 (ert-test-failed ((should-not (not x)) :form (not nil) :value t)))
316 (ert--test-my-list x y)))) 317 (,(lambda () (let ((x t) (y nil)) (should-not
317 (ert-test-failed 318 (ert--test-my-list x y))))
318 ((should-not (ert--test-my-list x y)) 319 (ert-test-failed
319 :form (list t nil) 320 ((should-not (ert--test-my-list x y))
320 :value (t nil)))) 321 :form (list t nil)
321 (,(lambda () (let ((x t)) (should (error "Foo")))) 322 :value (t nil))))
322 (error "Foo"))) 323 (,(lambda () (let ((_x t)) (should (error "Foo"))))
323 do 324 (error "Foo")))
324 (let ((test (make-ert-test :body body))) 325 do
325 (condition-case actual-condition 326 (let ((test (make-ert-test :body body)))
326 (progn 327 (condition-case actual-condition
327 (let ((ert-debug-on-error t)) 328 (progn
328 (ert-run-test test)) 329 (let ((ert-debug-on-error t))
329 (assert nil)) 330 (ert-run-test test))
330 ((error) 331 (cl-assert nil))
331 (should (equal actual-condition expected-condition))))))) 332 ((error)
333 (should (equal actual-condition expected-condition)))))))
332 334
333(ert-deftest ert-test-deftest () 335(ert-deftest ert-test-deftest ()
334 (should (equal (macroexpand '(ert-deftest abc () "foo" :tags '(bar))) 336 (should (equal (macroexpand '(ert-deftest abc () "foo" :tags '(bar)))
@@ -520,7 +522,7 @@ This macro is used to test if macroexpansion in `should' works."
520 (setf (cdr (last a)) (cddr a)) 522 (setf (cdr (last a)) (cddr a))
521 (should (not (ert--proper-list-p a)))) 523 (should (not (ert--proper-list-p a))))
522 (let ((a (list 1 2 3 4))) 524 (let ((a (list 1 2 3 4)))
523 (setf (cdr (last a)) (cdddr a)) 525 (setf (cdr (last a)) (cl-cdddr a))
524 (should (not (ert--proper-list-p a))))) 526 (should (not (ert--proper-list-p a)))))
525 527
526(ert-deftest ert-test-parse-keys-and-body () 528(ert-deftest ert-test-parse-keys-and-body ()
@@ -657,14 +659,14 @@ This macro is used to test if macroexpansion in `should' works."
657 (i 0)) 659 (i 0))
658 (let ((result (ert--remove-if-not (lambda (x) 660 (let ((result (ert--remove-if-not (lambda (x)
659 (should (eql x (nth i list))) 661 (should (eql x (nth i list)))
660 (incf i) 662 (cl-incf i)
661 (member i '(2 3))) 663 (member i '(2 3)))
662 list))) 664 list)))
663 (should (equal i 4)) 665 (should (equal i 4))
664 (should (equal result '(b c))) 666 (should (equal result '(b c)))
665 (should (equal list '(a b c d))))) 667 (should (equal list '(a b c d)))))
666 (should (equal '() 668 (should (equal '()
667 (ert--remove-if-not (lambda (x) (should nil)) '())))) 669 (ert--remove-if-not (lambda (_x) (should nil)) '()))))
668 670
669(ert-deftest ert-test-remove* () 671(ert-deftest ert-test-remove* ()
670 (let ((list (list 'a 'b 'c 'd)) 672 (let ((list (list 'a 'b 'c 'd))
@@ -676,13 +678,13 @@ This macro is used to test if macroexpansion in `should' works."
676 (should (eql x (nth key-index list))) 678 (should (eql x (nth key-index list)))
677 (prog1 679 (prog1
678 (list key-index x) 680 (list key-index x)
679 (incf key-index))) 681 (cl-incf key-index)))
680 :test 682 :test
681 (lambda (a b) 683 (lambda (a b)
682 (should (eql a 'foo)) 684 (should (eql a 'foo))
683 (should (equal b (list test-index 685 (should (equal b (list test-index
684 (nth test-index list)))) 686 (nth test-index list))))
685 (incf test-index) 687 (cl-incf test-index)
686 (member test-index '(2 3)))))) 688 (member test-index '(2 3))))))
687 (should (equal key-index 4)) 689 (should (equal key-index 4))
688 (should (equal test-index 4)) 690 (should (equal test-index 4))
diff --git a/test/automated/ert-x-tests.el b/test/automated/ert-x-tests.el
index 520502bb307..e03c8475442 100644
--- a/test/automated/ert-x-tests.el
+++ b/test/automated/ert-x-tests.el
@@ -28,7 +28,7 @@
28;;; Code: 28;;; Code:
29 29
30(eval-when-compile 30(eval-when-compile
31 (require 'cl)) 31 (require 'cl-lib))
32(require 'ert) 32(require 'ert)
33(require 'ert-x) 33(require 'ert-x)
34 34
@@ -233,8 +233,8 @@ desired effect."
233 (should (equal (buffer-string) "")) 233 (should (equal (buffer-string) ""))
234 (let ((message-log-max 2)) 234 (let ((message-log-max 2))
235 (let ((message-log-max t)) 235 (let ((message-log-max t))
236 (loop for i below 4 do 236 (cl-loop for i below 4 do
237 (message "%s" i)) 237 (message "%s" i))
238 (should (equal (buffer-string) "0\n1\n2\n3\n"))) 238 (should (equal (buffer-string) "0\n1\n2\n3\n")))
239 (should (equal (buffer-string) "0\n1\n2\n3\n")) 239 (should (equal (buffer-string) "0\n1\n2\n3\n"))
240 (message "") 240 (message "")
@@ -244,28 +244,28 @@ desired effect."
244 244
245(ert-deftest ert-test-force-message-log-buffer-truncation () 245(ert-deftest ert-test-force-message-log-buffer-truncation ()
246 :tags '(:causes-redisplay) 246 :tags '(:causes-redisplay)
247 (labels ((body () 247 (cl-labels ((body ()
248 (loop for i below 3 do 248 (cl-loop for i below 3 do
249 (message "%s" i))) 249 (message "%s" i)))
250 ;; Uses the implicit messages buffer truncation implemented 250 ;; Uses the implicit messages buffer truncation implemented
251 ;; in Emacs' C core. 251 ;; in Emacs' C core.
252 (c (x) 252 (c (x)
253 (ert-with-buffer-renamed ("*Messages*") 253 (ert-with-buffer-renamed ("*Messages*")
254 (let ((message-log-max x)) 254 (let ((message-log-max x))
255 (body)) 255 (body))
256 (with-current-buffer "*Messages*" 256 (with-current-buffer "*Messages*"
257 (buffer-string)))) 257 (buffer-string))))
258 ;; Uses our lisp reimplementation. 258 ;; Uses our lisp reimplementation.
259 (lisp (x) 259 (lisp (x)
260 (ert-with-buffer-renamed ("*Messages*") 260 (ert-with-buffer-renamed ("*Messages*")
261 (let ((message-log-max t)) 261 (let ((message-log-max t))
262 (body)) 262 (body))
263 (let ((message-log-max x)) 263 (let ((message-log-max x))
264 (ert--force-message-log-buffer-truncation)) 264 (ert--force-message-log-buffer-truncation))
265 (with-current-buffer "*Messages*" 265 (with-current-buffer "*Messages*"
266 (buffer-string))))) 266 (buffer-string)))))
267 (loop for x in '(0 1 2 3 4 t) do 267 (cl-loop for x in '(0 1 2 3 4 t) do
268 (should (equal (c x) (lisp x)))))) 268 (should (equal (c x) (lisp x))))))
269 269
270 270
271(provide 'ert-x-tests) 271(provide 'ert-x-tests)