diff options
| author | Vladimir Kazanov | 2024-03-31 18:32:59 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-04-01 11:13:12 +0200 |
| commit | 3f9263f791fb8e4ff0507c8fde95fa19dabcab10 (patch) | |
| tree | a087989fb07fd830e83d43c9f91e6a8340649926 /test | |
| parent | 3f4486dd76c44c76c58605fb9a1643515133ff3f (diff) | |
| download | emacs-3f9263f791fb8e4ff0507c8fde95fa19dabcab10.tar.gz emacs-3f9263f791fb8e4ff0507c8fde95fa19dabcab10.zip | |
Fix symbol list matching regexps.
Fix symbol list matching regexp performance
Allow empty face lists, improve the face list matching regexp (see
discussion in Bug#69714) based on relint's comments, add tests:
* test/lisp/emacs-lisp/ert-font-lock-tests.el: Add tests.
* lisp/emacs-lisp/ert-font-lock.el: Fix regexps.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/ert-font-lock-tests.el | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/test/lisp/emacs-lisp/ert-font-lock-tests.el b/test/lisp/emacs-lisp/ert-font-lock-tests.el index fa2e5dc4db7..33ef2c52288 100644 --- a/test/lisp/emacs-lisp/ert-font-lock-tests.el +++ b/test/lisp/emacs-lisp/ert-font-lock-tests.el | |||
| @@ -44,13 +44,56 @@ | |||
| 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) | ||
| 48 | (concat "^" re "$")) | ||
| 49 | |||
| 50 | ;;; Regexp tests | ||
| 51 | ;;; | ||
| 52 | |||
| 53 | (ert-deftest test-regexp--face-symbol-re () | ||
| 54 | (let ((re (ert-font-lock--wrap-begin-end | ||
| 55 | ert-font-lock--face-symbol-re))) | ||
| 56 | (should (string-match-p re "font-lock-keyword-face")) | ||
| 57 | (should (string-match-p re "-face")) | ||
| 58 | (should (string-match-p re "weird-package/-face")) | ||
| 59 | (should (string-match-p re "-")) | ||
| 60 | (should (string-match-p re "font-lock.face")) | ||
| 61 | (should-not (string-match-p re "face suffix-with")) | ||
| 62 | (should-not (string-match-p re "(")))) | ||
| 63 | |||
| 64 | (ert-deftest test-regexp--face-symbol-list-re () | ||
| 65 | (let ((re (ert-font-lock--wrap-begin-end | ||
| 66 | ert-font-lock--face-symbol-list-re))) | ||
| 67 | (should (string-match-p re "(face1 face2)")) | ||
| 68 | (should (string-match-p re "(face1)")) | ||
| 69 | (should (string-match-p re "()")) | ||
| 70 | (should-not (string-match-p re ")")) | ||
| 71 | (should-not (string-match-p re "(")))) | ||
| 72 | |||
| 73 | (ert-deftest test-regexp--assertion-line-re () | ||
| 74 | (let ((re (ert-font-lock--wrap-begin-end | ||
| 75 | ert-font-lock--assertion-line-re))) | ||
| 76 | (should (string-match-p re "^ something-face")) | ||
| 77 | (should (string-match-p re "^ !something-face")) | ||
| 78 | (should (string-match-p re "^ (face1 face2)")) | ||
| 79 | (should (string-match-p re "^ !(face1 face2)")) | ||
| 80 | (should (string-match-p re "^ ()")) | ||
| 81 | (should (string-match-p re "^ !()")) | ||
| 82 | (should (string-match-p re "^ nil")) | ||
| 83 | (should (string-match-p re "^ !nil")) | ||
| 84 | (should (string-match-p re "<- something-face")) | ||
| 85 | (should (string-match-p re "<- ^ something-face")) | ||
| 86 | (should (string-match-p re "^^ ^ something-face")) | ||
| 87 | (should (string-match-p re "^ ^something-face")) | ||
| 88 | (should-not (string-match-p re "^ <- ^something-face")))) | ||
| 89 | |||
| 47 | ;;; Comment parsing tests | 90 | ;;; Comment parsing tests |
| 48 | ;; | 91 | ;; |
| 49 | 92 | ||
| 50 | (ert-deftest test-line-comment-p--fundamental () | 93 | (ert-deftest test-line-comment-p--fundamental () |
| 51 | (with-temp-buffer-str-mode fundamental-mode | 94 | (with-temp-buffer-str-mode fundamental-mode |
| 52 | "// comment\n" | 95 | "// comment\n" |
| 53 | (should-not (ert-font-lock--line-comment-p)))) | 96 | (should-not (ert-font-lock--line-comment-p)))) |
| 54 | 97 | ||
| 55 | (ert-deftest test-line-comment-p--emacs-lisp () | 98 | (ert-deftest test-line-comment-p--emacs-lisp () |
| 56 | (with-temp-buffer-str-mode emacs-lisp-mode | 99 | (with-temp-buffer-str-mode emacs-lisp-mode |