Skip to content

Commit 521019f

Browse files
committed
Add font-lock tests for docstrings and comment macro
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).
1 parent 55a9aad commit 521019f

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

test/clojure-ts-mode-font-lock-test.el

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,39 @@ DESCRIPTION is the description of the spec."
420420
:to-equal 'font-lock-function-name-face)
421421
(expect (get-text-property 25 'face)
422422
:to-equal 'font-lock-doc-face))))
423+
424+
;;;; Docstrings in various def forms
425+
426+
(describe "docstring-highlighting"
427+
(when-fontifying-it "should highlight docstrings in defmacro"
428+
("(defmacro my-macro\n \"A macro docstring.\"\n [& body] body)"
429+
(22 41 font-lock-doc-face)))
430+
431+
(when-fontifying-it "should highlight docstrings in defmulti"
432+
("(defmulti my-multi\n \"A multi docstring.\"\n :type)"
433+
(22 41 font-lock-doc-face)))
434+
435+
(when-fontifying-it "should highlight docstrings in defprotocol"
436+
("(defprotocol MyProto\n \"A protocol docstring.\"\n (foo [this]))"
437+
(24 46 font-lock-doc-face)))
438+
439+
(when-fontifying-it "should highlight docstrings in ns"
440+
("(ns my.ns\n \"A namespace docstring.\")"
441+
(13 36 font-lock-doc-face)))
442+
443+
(when-fontifying-it "should highlight docstrings in defprotocol methods"
444+
("(defprotocol P\n (foo [this]\n \"Method docstring.\"))"
445+
(34 52 font-lock-doc-face))))
446+
447+
;;;; Comment macro font-locking
448+
449+
(describe "clojure-ts-comment-macro-font-lock-body"
450+
(it "should not highlight comment body by default"
451+
(with-clojure-ts-buffer "(comment (+ 1 2))"
452+
(font-lock-ensure)
453+
;; comment symbol itself should be comment-delimiter-face
454+
(expect (get-text-property 2 'face)
455+
:to-equal 'font-lock-comment-delimiter-face)
456+
;; Body should NOT be comment-face (default is nil)
457+
(expect (get-text-property 10 'face)
458+
:not :to-equal 'font-lock-comment-face))))

0 commit comments

Comments
 (0)