Skip to content

Commit 0dcfdc5

Browse files
author
Vadim Rodionov
committed
Add more test cases for def forms font locking
1 parent a44e4f2 commit 0dcfdc5

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

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

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -776,24 +776,51 @@ DESCRIPTION is the description of the spec."
776776
(6 42 clojure-keyword-face)))
777777

778778
(when-fontifying-it "should handle namespaced defs"
779-
("(_c4/defconstrainedfn bar [] nil)"
779+
("(_c4/defn bar [] nil)"
780780
(2 4 font-lock-type-face)
781781
(5 5 nil)
782-
(6 18 font-lock-keyword-face)
783-
(23 25 font-lock-function-name-face))
782+
(6 9 font-lock-keyword-face)
783+
(11 13 font-lock-function-name-face))
784784

785-
("(clo/defbar foo nil)"
785+
("(clo/defrecord foo nil)"
786786
(2 4 font-lock-type-face)
787787
(5 5 nil)
788-
(6 11 font-lock-keyword-face)
789-
(13 15 font-lock-function-name-face))
788+
(6 14 font-lock-keyword-face)
789+
(16 18 font-lock-function-name-face))
790790

791791
("(s/def ::keyword)"
792792
(2 2 font-lock-type-face)
793793
(3 3 nil)
794794
(4 6 font-lock-keyword-face)
795795
(8 16 clojure-keyword-face)))
796796

797+
(when-fontifying-it "should handle any known def form"
798+
("(def a 1)" (2 4 font-lock-keyword-face))
799+
("(defonce a 1)" (2 8 font-lock-keyword-face))
800+
("(defn a [b])" (2 5 font-lock-keyword-face))
801+
("(defmacro a [b])" (2 9 font-lock-keyword-face))
802+
("(definline a [b])" (2 10 font-lock-keyword-face))
803+
("(defmulti a identity)" (2 9 font-lock-keyword-face))
804+
("(defmethod a :foo [b] (println \"bar\"))" (2 10 font-lock-keyword-face))
805+
("(defprotocol a (b [this] \"that\"))" (2 12 font-lock-keyword-face))
806+
("(definterface a (b [c]))" (2 13 font-lock-keyword-face))
807+
("(defrecord a [b c])" (2 10 font-lock-keyword-face))
808+
("(deftype a [b c])" (2 8 font-lock-keyword-face))
809+
("(defstruct a :b :c)" (2 10 font-lock-keyword-face))
810+
("(deftest a (is (= 1 1)))" (2 8 font-lock-keyword-face))
811+
("(defne [x y])" (2 6 font-lock-keyword-face))
812+
("(defnm a b)" (2 6 font-lock-keyword-face))
813+
("(defnu)" (2 6 font-lock-keyword-face))
814+
("(defnc [a])" (2 6 font-lock-keyword-face))
815+
("(defna)" (2 6 font-lock-keyword-face))
816+
("(deftask a)" (2 8 font-lock-keyword-face))
817+
("(defstate a :start \"b\" :stop \"c\")" (2 9 font-lock-keyword-face)))
818+
819+
(when-fontifying-it "should ignore unknown def forms"
820+
("(defbugproducer me)" (2 15 nil))
821+
("(default-user-settings {:a 1})" (2 24 nil))
822+
("(s/deftartar :foo)" (4 10 nil)))
823+
797824
(when-fontifying-it "should handle variables defined with def"
798825
("(def foo 10)"
799826
(2 4 font-lock-keyword-face)
@@ -845,23 +872,6 @@ DESCRIPTION is the description of the spec."
845872
(2 5 font-lock-keyword-face)
846873
(7 9 font-lock-function-name-face)))
847874

848-
(when-fontifying-it "should handle a custom def with special chars 1"
849-
("(defn* foo [x] x)"
850-
(2 6 font-lock-keyword-face)
851-
(8 10 font-lock-function-name-face)))
852-
853-
(when-fontifying-it "should handle a custom def with special chars 2"
854-
("(defsomething! foo [x] x)"
855-
(2 14 font-lock-keyword-face)
856-
(16 18 font-lock-function-name-face)))
857-
858-
(when-fontifying-it "should handle a custom def with special chars 3"
859-
("(def-something foo [x] x)"
860-
(2 14 font-lock-keyword-face))
861-
862-
("(def-something foo [x] x)"
863-
(16 18 font-lock-function-name-face)))
864-
865875
(when-fontifying-it "should handle fn"
866876
;; try to byte-recompile the clojure-mode.el when the face of 'fn' is 't'
867877
("(fn foo [x] x)"

0 commit comments

Comments
 (0)