Skip to content

Improve font-lock test coverage#136

Merged
bbatsov merged 3 commits intomainfrom
improve-font-lock-test-coverage
Mar 24, 2026
Merged

Improve font-lock test coverage#136
bbatsov merged 3 commits intomainfrom
improve-font-lock-test-coverage

Conversation

@bbatsov
Copy link
Member

@bbatsov bbatsov commented Mar 24, 2026

Add tests for all previously untested font-lock features and switch to more readable substring-based face assertions.

  • Add tests for number, char, constant, keyword, string, comment, quote, regex, bracket, deref, function, and tagged-literals features
  • Add docstring tests for defmacro, defmulti, defprotocol, ns, and protocol method docstrings
  • Test the default behavior of clojure-ts-comment-macro-font-lock-body
  • Add substring-based face specs (("substring" face)) to the test helpers, alongside the existing positional form
  • Convert most tests from opaque numeric positions to readable substring form

bbatsov added 3 commits March 24, 2026 08:51
Cover all font-lock features that had no test coverage:
- number: integer, float, hex, ratio, bigint, bigdec, radix
- char: character literals (\a, \newline, \space, \tab, \u0041)
- constant: true, false, nil
- keyword: simple, auto-resolved, namespaced
- string: plain strings, escape sequences
- comment: line comments, discard expressions, comment macro
- quote: ', `, ~, ~@, #'
- regex: regex literal highlighting
- bracket: parens, brackets, braces, set literal (level 4)
- deref: @ operator (level 4)
- function: function calls (level 4)
- tagged-literals: #inst, #uuid (level 4)
Test docstring highlighting in forms that were previously uncovered:
defmacro, defmulti, defprotocol, ns, and defprotocol method
docstrings.

Test the default behavior of clojure-ts-comment-macro-font-lock-body
(comment symbol gets comment-delimiter-face, body is not highlighted
as comment).
Add support for ("substring" face) specs alongside the existing
(start end face) positional specs in the test helpers. Substring
specs use sequential search-forward, so repeated substrings resolve
naturally in document order.

Convert most existing and new font-lock tests from opaque numeric
positions to readable substring form, making the tests much easier
to understand and maintain.
@bbatsov bbatsov merged commit 9e7c54a into main Mar 24, 2026
10 checks passed
@bbatsov bbatsov deleted the improve-font-lock-test-coverage branch March 25, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant