diff options
| author | Stefan Kangas | 2020-04-26 00:27:47 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2020-04-26 00:30:37 +0200 |
| commit | 0e2cd5f5ab8e3e870fde7c70cbc75fdd2b405746 (patch) | |
| tree | 1a6b843911021ca5cef58b4305b1b7fc166098ad | |
| parent | eb65ac526c9dd350b8a6548f2f453a550dac5821 (diff) | |
| download | emacs-0e2cd5f5ab8e3e870fde7c70cbc75fdd2b405746.tar.gz emacs-0e2cd5f5ab8e3e870fde7c70cbc75fdd2b405746.zip | |
Use lexical-binding in misc.el and add tests
* lisp/misc.el: Use lexical-binding.
* test/lisp/misc-tests.el: New file.
| -rw-r--r-- | lisp/misc.el | 2 | ||||
| -rw-r--r-- | test/lisp/misc-tests.el | 77 |
2 files changed, 78 insertions, 1 deletions
diff --git a/lisp/misc.el b/lisp/misc.el index 3a0989bcab4..8c39492784b 100644 --- a/lisp/misc.el +++ b/lisp/misc.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; misc.el --- some nonstandard editing and utility commands for Emacs | 1 | ;;; misc.el --- some nonstandard editing and utility commands for Emacs -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1989, 2001-2020 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1989, 2001-2020 Free Software Foundation, Inc. |
| 4 | 4 | ||
diff --git a/test/lisp/misc-tests.el b/test/lisp/misc-tests.el new file mode 100644 index 00000000000..fbcbfb7d0cc --- /dev/null +++ b/test/lisp/misc-tests.el | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | ;;; misc-tests.el --- Tests for misc.el -*- lexical-binding:t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2020 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Stefan Kangas <stefankangas@gmail.com> | ||
| 6 | |||
| 7 | ;; This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 10 | ;; it under the terms of the GNU General Public License as published by | ||
| 11 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 12 | ;; (at your option) any later version. | ||
| 13 | |||
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ;; GNU General Public License for more details. | ||
| 18 | |||
| 19 | ;; You should have received a copy of the GNU General Public License | ||
| 20 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;;; Code: | ||
| 25 | |||
| 26 | (require 'ert) | ||
| 27 | |||
| 28 | (defmacro with-misc-test (original result &rest body) | ||
| 29 | (declare (indent 2)) | ||
| 30 | `(with-temp-buffer | ||
| 31 | (insert ,original) | ||
| 32 | ,@body | ||
| 33 | (should (equal (buffer-string) ,result)))) | ||
| 34 | |||
| 35 | (ert-deftest misc-test-copy-from-above-command () | ||
| 36 | (with-misc-test "abc\n" "abc\nabc" | ||
| 37 | (copy-from-above-command)) | ||
| 38 | (with-misc-test "abc\n" "abc\nab" | ||
| 39 | (copy-from-above-command 2))) | ||
| 40 | |||
| 41 | (ert-deftest misc-test-zap-up-to-char () | ||
| 42 | (with-misc-test "abcde" "cde" | ||
| 43 | (goto-char (point-min)) | ||
| 44 | (zap-up-to-char 1 ?c)) | ||
| 45 | (with-misc-test "abcde abc123" "c123" | ||
| 46 | (goto-char (point-min)) | ||
| 47 | (zap-up-to-char 2 ?c))) | ||
| 48 | |||
| 49 | (ert-deftest misc-test-upcase-char () | ||
| 50 | (with-misc-test "abcde" "aBCDe" | ||
| 51 | (goto-char (1+ (point-min))) | ||
| 52 | (upcase-char 3))) | ||
| 53 | |||
| 54 | (ert-deftest misc-test-forward-to-word () | ||
| 55 | (with-temp-buffer | ||
| 56 | (insert " - abc") | ||
| 57 | (goto-char (point-min)) | ||
| 58 | (forward-to-word 1) | ||
| 59 | (should (equal (point) 9))) | ||
| 60 | (with-temp-buffer | ||
| 61 | (insert "a b c") | ||
| 62 | (goto-char (point-min)) | ||
| 63 | (forward-to-word 3) | ||
| 64 | (should (equal (point) 6)))) | ||
| 65 | |||
| 66 | (ert-deftest misc-test-backward-to-word () | ||
| 67 | (with-temp-buffer | ||
| 68 | (insert "abc - ") | ||
| 69 | (backward-to-word 1) | ||
| 70 | (should (equal (point) 4))) | ||
| 71 | (with-temp-buffer | ||
| 72 | (insert "a b c") | ||
| 73 | (backward-to-word 3) | ||
| 74 | (should (equal (point) 1)))) | ||
| 75 | |||
| 76 | (provide 'misc-tests) | ||
| 77 | ;;; misc-tests.el ends here | ||