diff options
| author | Simen Heggestøyl | 2019-07-18 20:39:47 +0200 |
|---|---|---|
| committer | Simen Heggestøyl | 2019-07-18 20:41:47 +0200 |
| commit | b4eaa7eaceeeec749b74e3c5ebbf900d5754b17d (patch) | |
| tree | 5030d5617def01a95f8e05a6645a030f9b2f0bec /test/lisp/progmodes | |
| parent | 71ce14a83e424b7524325e85d9fffde732943754 (diff) | |
| download | emacs-b4eaa7eaceeeec749b74e3c5ebbf900d5754b17d.tar.gz emacs-b4eaa7eaceeeec749b74e3c5ebbf900d5754b17d.zip | |
Use lexical-binding in asm-mode.el and add tests
* lisp/progmodes/asm-mode.el: Use lexical-binding.
(asm-comment-char): Remove redundant :group arg.
(asm-mode): Use `setq-local'.
(asm-calculate-indentation): Remove moot `or'.
* test/lisp/progmodes/asm-mode-tests.el: New file with tests for
asm-mode.el.
Diffstat (limited to 'test/lisp/progmodes')
| -rw-r--r-- | test/lisp/progmodes/asm-mode-tests.el | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/lisp/progmodes/asm-mode-tests.el b/test/lisp/progmodes/asm-mode-tests.el new file mode 100644 index 00000000000..a10add0680d --- /dev/null +++ b/test/lisp/progmodes/asm-mode-tests.el | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | ;;; asm-mode-tests.el --- Tests for asm-mode.el -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2019 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Simen Heggestøyl <simenheg@gmail.com> | ||
| 6 | ;; Keywords: | ||
| 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 <https://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;; | ||
| 26 | |||
| 27 | ;;; Code: | ||
| 28 | |||
| 29 | (require 'asm-mode) | ||
| 30 | (require 'ert) | ||
| 31 | |||
| 32 | (defmacro asm-mode-tests--with-temp-buffer (&rest body) | ||
| 33 | "Create a temporary Asm mode buffer and evaluate BODY there." | ||
| 34 | (declare (indent 0)) | ||
| 35 | `(with-temp-buffer | ||
| 36 | (let ((asm-comment-char ?\;)) | ||
| 37 | (asm-mode) | ||
| 38 | ,@body))) | ||
| 39 | |||
| 40 | (ert-deftest asm-mode-tests-colon () | ||
| 41 | (asm-mode-tests--with-temp-buffer | ||
| 42 | (let ((indent-tabs-mode t)) | ||
| 43 | (insert "\t label") | ||
| 44 | (let ((last-command-event ?:)) | ||
| 45 | (asm-colon)) | ||
| 46 | (should (equal (buffer-string) "label:\t"))))) | ||
| 47 | |||
| 48 | (ert-deftest asm-mode-tests-colon-inside-comment () | ||
| 49 | (asm-mode-tests--with-temp-buffer | ||
| 50 | (insert ";comment") | ||
| 51 | (let ((last-command-event ?:)) | ||
| 52 | (asm-colon)) | ||
| 53 | (should (equal (buffer-string) ";comment:")))) | ||
| 54 | |||
| 55 | (ert-deftest asm-mode-tests-comment () | ||
| 56 | (asm-mode-tests--with-temp-buffer | ||
| 57 | (insert "label:") | ||
| 58 | (goto-char (point-min)) | ||
| 59 | ;; First invocation | ||
| 60 | (asm-comment) | ||
| 61 | (should (string-match-p "label:[ \t]+;" (buffer-string))) | ||
| 62 | (should (= (current-column) (+ comment-column 1))) | ||
| 63 | ;; Second invocation | ||
| 64 | (asm-comment) | ||
| 65 | (should (string-match-p "[ \t]+;; \nlabel:" (buffer-string))) | ||
| 66 | (should (= (current-column) (+ tab-width 3))) | ||
| 67 | ;; Third invocation | ||
| 68 | (asm-comment) | ||
| 69 | (should (string-match-p ";;; \nlabel:" (buffer-string))) | ||
| 70 | (should (= (current-column) 4)))) | ||
| 71 | |||
| 72 | ;;; asm-mode-tests.el ends here | ||