diff options
author | Vladimir Kazanov <vekazanov@gmail.com> | 2024-03-31 18:32:59 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2024-04-01 11:13:12 +0200 |
commit | 3f9263f791fb8e4ff0507c8fde95fa19dabcab10 (patch) | |
tree | a087989fb07fd830e83d43c9f91e6a8340649926 /test/lisp/emacs-lisp | |
parent | 3f4486dd76c44c76c58605fb9a1643515133ff3f (diff) | |
download | emacs-3f9263f791fb8e4ff0507c8fde95fa19dabcab10.tar.gz emacs-3f9263f791fb8e4ff0507c8fde95fa19dabcab10.tar.bz2 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/lisp/emacs-lisp')
-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 @@ (goto-char (point-min)) ,@body)) +(defun ert-font-lock--wrap-begin-end (re) + (concat "^" re "$")) + +;;; Regexp tests +;;; + +(ert-deftest test-regexp--face-symbol-re () + (let ((re (ert-font-lock--wrap-begin-end + ert-font-lock--face-symbol-re))) + (should (string-match-p re "font-lock-keyword-face")) + (should (string-match-p re "-face")) + (should (string-match-p re "weird-package/-face")) + (should (string-match-p re "-")) + (should (string-match-p re "font-lock.face")) + (should-not (string-match-p re "face suffix-with")) + (should-not (string-match-p re "(")))) + +(ert-deftest test-regexp--face-symbol-list-re () + (let ((re (ert-font-lock--wrap-begin-end + ert-font-lock--face-symbol-list-re))) + (should (string-match-p re "(face1 face2)")) + (should (string-match-p re "(face1)")) + (should (string-match-p re "()")) + (should-not (string-match-p re ")")) + (should-not (string-match-p re "(")))) + +(ert-deftest test-regexp--assertion-line-re () + (let ((re (ert-font-lock--wrap-begin-end + ert-font-lock--assertion-line-re))) + (should (string-match-p re "^ something-face")) + (should (string-match-p re "^ !something-face")) + (should (string-match-p re "^ (face1 face2)")) + (should (string-match-p re "^ !(face1 face2)")) + (should (string-match-p re "^ ()")) + (should (string-match-p re "^ !()")) + (should (string-match-p re "^ nil")) + (should (string-match-p re "^ !nil")) + (should (string-match-p re "<- something-face")) + (should (string-match-p re "<- ^ something-face")) + (should (string-match-p re "^^ ^ something-face")) + (should (string-match-p re "^ ^something-face")) + (should-not (string-match-p re "^ <- ^something-face")))) + ;;; Comment parsing tests ;; (ert-deftest test-line-comment-p--fundamental () (with-temp-buffer-str-mode fundamental-mode - "// comment\n" - (should-not (ert-font-lock--line-comment-p)))) + "// comment\n" + (should-not (ert-font-lock--line-comment-p)))) (ert-deftest test-line-comment-p--emacs-lisp () (with-temp-buffer-str-mode emacs-lisp-mode |