diff options
| author | Stefan Monnier | 2012-11-19 12:24:12 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2012-11-19 12:24:12 -0500 |
| commit | 19dc72069c79865d5464737b4ce10ed25a3be49b (patch) | |
| tree | 58eb37bf96ecbb9659eba0b95f6fa42ea4551a5d /test | |
| parent | 855b17af8fd8a96e1ca66a652b88f34479df12d7 (diff) | |
| download | emacs-19dc72069c79865d5464737b4ce10ed25a3be49b.tar.gz emacs-19dc72069c79865d5464737b4ce10ed25a3be49b.zip | |
Use cl-lib instead of cl, and interactive-p => called-interactively-p.
* lisp/erc/erc-track.el, lisp/erc/erc-networks.el, lisp/erc/erc-netsplit.el:
* lisp/erc/erc-dcc.el, lisp/erc/erc-backend.el: Use cl-lib, nth, pcase, and
called-interactively-p instead of cl.
* lisp/erc/erc-speedbar.el, lisp/erc/erc-services.el:
* lisp/erc/erc-pcomplete.el, lisp/erc/erc-notify.el, lisp/erc/erc-match.el:
* lisp/erc/erc-log.el, lisp/erc/erc-join.el, lisp/erc/erc-ezbounce.el:
* lisp/erc/erc-capab.el: Don't require cl since we don't use it.
* lisp/erc/erc.el: Use cl-lib, nth, pcase, and called-interactively-p i.s.o cl.
(erc-lurker-ignore-chars, erc-common-server-suffixes): Move before first use.
* lisp/json.el: Don't require cl since we don't use it.
* lisp/color.el: Don't require cl.
(color-complement): `caddr' -> `nth 2'.
* test/automated/ert-x-tests.el: Use cl-lib.
* test/automated/ert-tests.el: Use lexical-binding and cl-lib.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 9 | ||||
| -rw-r--r-- | test/automated/ert-tests.el | 132 | ||||
| -rw-r--r-- | test/automated/ert-x-tests.el | 50 |
3 files changed, 99 insertions, 92 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index f11325d0318..75903ae3ef4 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-11-19 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * automated/ert-x-tests.el: Use cl-lib. | ||
| 4 | * automated/ert-tests.el: Use lexical-binding and cl-lib. | ||
| 5 | |||
| 1 | 2012-11-14 Dmitry Gutov <dgutov@yandex.ru> | 6 | 2012-11-14 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 7 | ||
| 3 | * automated/ruby-mode-tests.el (ruby-indent-singleton-class): Pass. | 8 | * automated/ruby-mode-tests.el (ruby-indent-singleton-class): Pass. |
| @@ -5,8 +10,8 @@ | |||
| 5 | (ruby-indent-inside-heredoc-after-space): New tests. | 10 | (ruby-indent-inside-heredoc-after-space): New tests. |
| 6 | Change direct font-lock face references to var references. | 11 | Change direct font-lock face references to var references. |
| 7 | (ruby-interpolation-suppresses-syntax-inside): New test. | 12 | (ruby-interpolation-suppresses-syntax-inside): New test. |
| 8 | (ruby-interpolation-inside-percent-literal-with-paren): New | 13 | (ruby-interpolation-inside-percent-literal-with-paren): |
| 9 | failing test. | 14 | New failing test. |
| 10 | 15 | ||
| 11 | 2012-11-13 Dmitry Gutov <dgutov@yandex.ru> | 16 | 2012-11-13 Dmitry Gutov <dgutov@yandex.ru> |
| 12 | 17 | ||
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) |