Skip to content

Commit 289e683

Browse files
bbatsovkommen
authored andcommitted
Fix font-locking tests
1 parent 8368b51 commit 289e683

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

clojure-mode-font-lock-test.el

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@
4141
(goto-char (point-min))
4242
,@body))
4343

44+
(defmacro clojurex-test-with-temp-buffer (content &rest body)
45+
"Evaluate BODY in a temporary buffer with CONTENTS."
46+
(declare (debug t)
47+
(indent 1))
48+
`(with-temp-buffer
49+
(insert ,content)
50+
(clojurex-mode)
51+
(font-lock-fontify-buffer)
52+
(goto-char (point-min))
53+
,@body))
54+
4455
(defun clojure-get-face-at-range (start end)
4556
(let ((start-face (get-text-property start 'face))
4657
(all-faces (cl-loop for i from start to end collect (get-text-property i 'face))))
@@ -58,6 +69,16 @@ buffer."
5869
(clojure-get-face-at-range start end))
5970
(clojure-get-face-at-range start end)))
6071

72+
(defun clojurex-test-face-at (start end &optional content)
73+
"Get the face between START and END in CONTENT.
74+
75+
If CONTENT is not given, return the face at the specified range in the current
76+
buffer."
77+
(if content
78+
(clojurex-test-with-temp-buffer content
79+
(clojure-get-face-at-range start end))
80+
(clojure-get-face-at-range start end)))
81+
6182
(defconst clojure-test-syntax-classes
6283
[whitespace punctuation word symbol open-paren close-paren expression-prefix
6384
string-quote paired-delim escape character-quote comment-start
@@ -209,10 +230,10 @@ POS."
209230
(should (eq (clojure-test-face-at 1 2 "\\,") 'clojure-character-face))
210231
(should (eq (clojure-test-face-at 1 2 "\\;") 'clojure-character-face)))
211232

212-
(ert-deftest clojure-mode-syntax-table/cljx ()
233+
(ert-deftest clojurex-mode-syntax-table/cljx ()
213234
:tags '(fontification syntax-table)
214-
(should (eq (clojure-test-face-at 1 5 "#+clj x") 'font-lock-preprocessor-face))
215-
(should (eq (clojure-test-face-at 1 6 "#+cljs x") 'font-lock-preprocessor-face)))
235+
(should (eq (clojurex-test-face-at 1 5 "#+clj x") 'font-lock-preprocessor-face))
236+
(should (eq (clojurex-test-face-at 1 6 "#+cljs x") 'font-lock-preprocessor-face)))
216237

217238
(ert-deftest clojure-mode-syntax-table/refer-ns ()
218239
:tags '(fontification syntax-table)

0 commit comments

Comments
 (0)