diff options
| author | Basil L. Contovounesios | 2025-02-20 10:29:54 +0100 |
|---|---|---|
| committer | Basil L. Contovounesios | 2025-02-25 11:02:55 +0100 |
| commit | 02c830ba22b0564f6725cd403beba4accb836061 (patch) | |
| tree | b7e74c0a1b57b0b2c9d4eaab61766a6cde91b249 /test | |
| parent | 0c6b8643aec24935f82c63d43219f26378e3e578 (diff) | |
| download | emacs-02c830ba22b0564f6725cd403beba4accb836061.tar.gz emacs-02c830ba22b0564f6725cd403beba4accb836061.zip | |
Fix ert-font-lock macro signatures
* doc/misc/ert.texi (Syntax Highlighting Tests):
* test/lisp/emacs-lisp/ert-font-lock-tests.el
(test-line-comment-p--emacs-lisp, test-line-comment-p--shell-script)
(test-line-comment-p--javascript, test-line-comment-p--python)
(test-line-comment-p--c, test-macro-test--correct-highlighting)
(test-macro-test--docstring, test-macro-test--failing)
(test-macro-test--file, test-macro-test--file-no-asserts)
(test-macro-test--file-failing): Reindent macro calls.
(with-temp-buffer-str-mode): Evaluate macro arguments left-to-right.
(ert-font-lock--wrap-begin-end): Use rx for more robust composition.
(test-line-comment-p--php): Require that php-mode is callable, not
already loaded.
* lisp/emacs-lisp/ert-font-lock.el (ert-font-lock-deftest)
(ert-font-lock-deftest-file): NAME is not followed by an empty list
like in ert-deftest, so the optional DOCSTRING is actually the
second argument. Adapt calling convention in docstring, and debug,
doc-string, and indent properties accordingly (bug#76372). Fix
docstring grammar, document MAJOR-MODE, and avoid referring to a
file name as a path.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/ert-font-lock-tests.el | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/test/lisp/emacs-lisp/ert-font-lock-tests.el b/test/lisp/emacs-lisp/ert-font-lock-tests.el index e410cf5fa13..0c3e4405562 100644 --- a/test/lisp/emacs-lisp/ert-font-lock-tests.el +++ b/test/lisp/emacs-lisp/ert-font-lock-tests.el | |||
| @@ -39,13 +39,13 @@ | |||
| 39 | "Create a buffer with STR contents and MODE. " | 39 | "Create a buffer with STR contents and MODE. " |
| 40 | (declare (indent 1) (debug t)) | 40 | (declare (indent 1) (debug t)) |
| 41 | `(with-temp-buffer | 41 | `(with-temp-buffer |
| 42 | (insert ,str) | ||
| 43 | (,mode) | 42 | (,mode) |
| 43 | (insert ,str) | ||
| 44 | (goto-char (point-min)) | 44 | (goto-char (point-min)) |
| 45 | ,@body)) | 45 | ,@body)) |
| 46 | 46 | ||
| 47 | (defun ert-font-lock--wrap-begin-end (re) | 47 | (defun ert-font-lock--wrap-begin-end (re) |
| 48 | (concat "^" re "$")) | 48 | (rx bol (regexp re) eol)) |
| 49 | 49 | ||
| 50 | ;;; Regexp tests | 50 | ;;; Regexp tests |
| 51 | ;;; | 51 | ;;; |
| @@ -97,89 +97,89 @@ | |||
| 97 | 97 | ||
| 98 | (ert-deftest test-line-comment-p--emacs-lisp () | 98 | (ert-deftest test-line-comment-p--emacs-lisp () |
| 99 | (with-temp-buffer-str-mode emacs-lisp-mode | 99 | (with-temp-buffer-str-mode emacs-lisp-mode |
| 100 | "not comment | 100 | "not comment |
| 101 | ;; comment | 101 | ;; comment |
| 102 | " | 102 | " |
| 103 | (should-not (ert-font-lock--line-comment-p)) | 103 | (should-not (ert-font-lock--line-comment-p)) |
| 104 | (forward-line) | 104 | (forward-line) |
| 105 | (should (ert-font-lock--line-comment-p)) | 105 | (should (ert-font-lock--line-comment-p)) |
| 106 | (forward-line) | 106 | (forward-line) |
| 107 | (should-not (ert-font-lock--line-comment-p)))) | 107 | (should-not (ert-font-lock--line-comment-p)))) |
| 108 | 108 | ||
| 109 | (ert-deftest test-line-comment-p--shell-script () | 109 | (ert-deftest test-line-comment-p--shell-script () |
| 110 | (with-temp-buffer-str-mode shell-script-mode | 110 | (with-temp-buffer-str-mode shell-script-mode |
| 111 | "echo Not a comment | 111 | "echo Not a comment |
| 112 | # comment | 112 | # comment |
| 113 | " | 113 | " |
| 114 | (should-not (ert-font-lock--line-comment-p)) | 114 | (should-not (ert-font-lock--line-comment-p)) |
| 115 | (forward-line) | 115 | (forward-line) |
| 116 | (should (ert-font-lock--line-comment-p)))) | 116 | (should (ert-font-lock--line-comment-p)))) |
| 117 | 117 | ||
| 118 | (declare-function php-mode "php-mode") | 118 | (declare-function php-mode "php-mode") |
| 119 | (ert-deftest test-line-comment-p--php () | 119 | (ert-deftest test-line-comment-p--php () |
| 120 | (skip-unless (featurep 'php-mode)) | 120 | (skip-unless (fboundp 'php-mode)) |
| 121 | 121 | ||
| 122 | (with-temp-buffer-str-mode php-mode | 122 | (with-temp-buffer-str-mode php-mode |
| 123 | "echo 'Not a comment' | 123 | "echo 'Not a comment' |
| 124 | // comment | 124 | // comment |
| 125 | /* comment */ | 125 | /* comment */ |
| 126 | " | 126 | " |
| 127 | (should-not (ert-font-lock--line-comment-p)) | 127 | (should-not (ert-font-lock--line-comment-p)) |
| 128 | (forward-line) | 128 | (forward-line) |
| 129 | (should (ert-font-lock--line-comment-p)) | 129 | (should (ert-font-lock--line-comment-p)) |
| 130 | (forward-line) | 130 | (forward-line) |
| 131 | (should (ert-font-lock--line-comment-p)))) | 131 | (should (ert-font-lock--line-comment-p)))) |
| 132 | 132 | ||
| 133 | 133 | ||
| 134 | (ert-deftest test-line-comment-p--javascript () | 134 | (ert-deftest test-line-comment-p--javascript () |
| 135 | (with-temp-buffer-str-mode javascript-mode | 135 | (with-temp-buffer-str-mode javascript-mode |
| 136 | "// comment | 136 | "// comment |
| 137 | 137 | ||
| 138 | // comment, after a blank line | 138 | // comment, after a blank line |
| 139 | 139 | ||
| 140 | var abc = function(d) {}; | 140 | var abc = function(d) {}; |
| 141 | " | 141 | " |
| 142 | (should (ert-font-lock--line-comment-p)) | 142 | (should (ert-font-lock--line-comment-p)) |
| 143 | 143 | ||
| 144 | (forward-line) | 144 | (forward-line) |
| 145 | (should-not (ert-font-lock--line-comment-p)) | 145 | (should-not (ert-font-lock--line-comment-p)) |
| 146 | 146 | ||
| 147 | (forward-line) | 147 | (forward-line) |
| 148 | (should (ert-font-lock--line-comment-p)) | 148 | (should (ert-font-lock--line-comment-p)) |
| 149 | 149 | ||
| 150 | (forward-line) | 150 | (forward-line) |
| 151 | (should-not (ert-font-lock--line-comment-p)) | 151 | (should-not (ert-font-lock--line-comment-p)) |
| 152 | 152 | ||
| 153 | (forward-line) | 153 | (forward-line) |
| 154 | (should-not (ert-font-lock--line-comment-p)))) | 154 | (should-not (ert-font-lock--line-comment-p)))) |
| 155 | 155 | ||
| 156 | (ert-deftest test-line-comment-p--python () | 156 | (ert-deftest test-line-comment-p--python () |
| 157 | 157 | ||
| 158 | (with-temp-buffer-str-mode python-mode | 158 | (with-temp-buffer-str-mode python-mode |
| 159 | "# comment | 159 | "# comment |
| 160 | 160 | ||
| 161 | # comment | 161 | # comment |
| 162 | print(\"Hello, world!\")" | 162 | print(\"Hello, world!\")" |
| 163 | (should (ert-font-lock--line-comment-p)) | 163 | (should (ert-font-lock--line-comment-p)) |
| 164 | 164 | ||
| 165 | (forward-line) | 165 | (forward-line) |
| 166 | (should-not (ert-font-lock--line-comment-p)) | 166 | (should-not (ert-font-lock--line-comment-p)) |
| 167 | 167 | ||
| 168 | (forward-line) | 168 | (forward-line) |
| 169 | (should (ert-font-lock--line-comment-p)) | 169 | (should (ert-font-lock--line-comment-p)) |
| 170 | 170 | ||
| 171 | (forward-line) | 171 | (forward-line) |
| 172 | (should-not (ert-font-lock--line-comment-p)))) | 172 | (should-not (ert-font-lock--line-comment-p)))) |
| 173 | 173 | ||
| 174 | (ert-deftest test-line-comment-p--c () | 174 | (ert-deftest test-line-comment-p--c () |
| 175 | 175 | ||
| 176 | (with-temp-buffer-str-mode c-mode | 176 | (with-temp-buffer-str-mode c-mode |
| 177 | "// comment | 177 | "// comment |
| 178 | /* also comment */" | 178 | /* also comment */" |
| 179 | (should (ert-font-lock--line-comment-p)) | 179 | (should (ert-font-lock--line-comment-p)) |
| 180 | 180 | ||
| 181 | (forward-line) | 181 | (forward-line) |
| 182 | (should (ert-font-lock--line-comment-p)))) | 182 | (should (ert-font-lock--line-comment-p)))) |
| 183 | 183 | ||
| 184 | (ert-deftest test-parse-comments--no-assertion-error () | 184 | (ert-deftest test-parse-comments--no-assertion-error () |
| 185 | (let* ((str " | 185 | (let* ((str " |
| @@ -568,14 +568,14 @@ var abc = function(d) { | |||
| 568 | ;; | 568 | ;; |
| 569 | 569 | ||
| 570 | (ert-font-lock-deftest test-macro-test--correct-highlighting | 570 | (ert-font-lock-deftest test-macro-test--correct-highlighting |
| 571 | emacs-lisp-mode | 571 | emacs-lisp-mode |
| 572 | " | 572 | " |
| 573 | (defun fun ()) | 573 | (defun fun ()) |
| 574 | ;; ^ font-lock-keyword-face | 574 | ;; ^ font-lock-keyword-face |
| 575 | ;; ^ font-lock-function-name-face") | 575 | ;; ^ font-lock-function-name-face") |
| 576 | 576 | ||
| 577 | (ert-font-lock-deftest test-macro-test--docstring | 577 | (ert-font-lock-deftest test-macro-test--docstring |
| 578 | "A test with a docstring." | 578 | "A test with a docstring." |
| 579 | emacs-lisp-mode | 579 | emacs-lisp-mode |
| 580 | " | 580 | " |
| 581 | (defun fun ()) | 581 | (defun fun ()) |
| @@ -583,7 +583,7 @@ var abc = function(d) { | |||
| 583 | ) | 583 | ) |
| 584 | 584 | ||
| 585 | (ert-font-lock-deftest test-macro-test--failing | 585 | (ert-font-lock-deftest test-macro-test--failing |
| 586 | "A failing test." | 586 | "A failing test." |
| 587 | :expected-result :failed | 587 | :expected-result :failed |
| 588 | emacs-lisp-mode | 588 | emacs-lisp-mode |
| 589 | " | 589 | " |
| @@ -591,18 +591,18 @@ var abc = function(d) { | |||
| 591 | ;; ^ wrong-face") | 591 | ;; ^ wrong-face") |
| 592 | 592 | ||
| 593 | (ert-font-lock-deftest-file test-macro-test--file | 593 | (ert-font-lock-deftest-file test-macro-test--file |
| 594 | "Test reading correct assertions from a file" | 594 | "Test reading correct assertions from a file." |
| 595 | javascript-mode | 595 | javascript-mode |
| 596 | "correct.js") | 596 | "correct.js") |
| 597 | 597 | ||
| 598 | (ert-font-lock-deftest-file test-macro-test--file-no-asserts | 598 | (ert-font-lock-deftest-file test-macro-test--file-no-asserts |
| 599 | "Check failing on files without assertions" | 599 | "Check failing on files without assertions." |
| 600 | :expected-result :failed | 600 | :expected-result :failed |
| 601 | javascript-mode | 601 | javascript-mode |
| 602 | "no-asserts.js") | 602 | "no-asserts.js") |
| 603 | 603 | ||
| 604 | (ert-font-lock-deftest-file test-macro-test--file-failing | 604 | (ert-font-lock-deftest-file test-macro-test--file-failing |
| 605 | "Test reading wrong assertions from a file" | 605 | "Test reading wrong assertions from a file." |
| 606 | :expected-result :failed | 606 | :expected-result :failed |
| 607 | javascript-mode | 607 | javascript-mode |
| 608 | "broken.js") | 608 | "broken.js") |