]> code.delx.au - gnu-emacs-elpa/blob - test/context-coloring-test.el
Rename test.
[gnu-emacs-elpa] / test / context-coloring-test.el
1 ;;; test/context-coloring-test.el --- Tests for context coloring. -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
4
5 ;; This file is part of GNU Emacs.
6
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
11
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 ;;; Code:
21
22 (require 'ert-async)
23
24
25 ;;; Test running utilities
26
27 (defconst context-coloring-test-path
28 (file-name-directory (or load-file-name buffer-file-name))
29 "This file's directory.")
30
31 (defun context-coloring-test-read-file (path)
32 "Read a file's contents into a string."
33 (with-temp-buffer
34 (insert-file-contents (expand-file-name path context-coloring-test-path))
35 (buffer-string)))
36
37 (defun context-coloring-test-setup ()
38 "Preparation code to run before all tests."
39 (setq context-coloring-comments-and-strings nil))
40
41 (defun context-coloring-test-cleanup ()
42 "Cleanup code to run after all tests."
43 (setq context-coloring-comments-and-strings t)
44 (setq context-coloring-after-colorize-hook nil)
45 (setq context-coloring-js-block-scopes nil)
46 (context-coloring-set-colors-default))
47
48 (defmacro context-coloring-test-with-fixture (fixture &rest body)
49 "Evaluate BODY in a temporary buffer with the relative
50 FIXTURE."
51 `(with-temp-buffer
52 (unwind-protect
53 (progn
54 (context-coloring-test-setup)
55 (insert (context-coloring-test-read-file ,fixture))
56 ,@body)
57 (context-coloring-test-cleanup))))
58
59 (defun context-coloring-test-with-temp-buffer-async (callback)
60 "Create a temporary buffer, and evaluate CALLBACK there. A
61 teardown callback is passed to CALLBACK for it to invoke when it
62 is done."
63 (let ((temp-buffer (make-symbol "temp-buffer")))
64 (let ((previous-buffer (current-buffer))
65 (temp-buffer (generate-new-buffer " *temp*")))
66 (set-buffer temp-buffer)
67 (funcall
68 callback
69 (lambda ()
70 (and (buffer-name temp-buffer)
71 (kill-buffer temp-buffer))
72 (set-buffer previous-buffer))))))
73
74 (defun context-coloring-test-with-fixture-async (fixture callback &optional setup)
75 "Evaluate CALLBACK in a temporary buffer with the relative
76 FIXTURE. A teardown callback is passed to CALLBACK for it to
77 invoke when it is done. An optional SETUP callback can be passed
78 to run arbitrary code before the mode is invoked."
79 (context-coloring-test-with-temp-buffer-async
80 (lambda (done-with-temp-buffer)
81 (context-coloring-test-setup)
82 (if setup (funcall setup))
83 (insert (context-coloring-test-read-file fixture))
84 (funcall
85 callback
86 (lambda ()
87 (context-coloring-test-cleanup)
88 (funcall done-with-temp-buffer))))))
89
90
91 ;;; Test defining utilities
92
93 (defun context-coloring-test-js-mode (fixture callback &optional setup)
94 "Use FIXTURE as the subject matter for test logic in CALLBACK.
95 Optionally, provide setup code to run before the mode is
96 instantiated in SETUP."
97 (context-coloring-test-with-fixture-async
98 fixture
99 (lambda (done-with-test)
100 (js-mode)
101 (context-coloring-mode)
102 (context-coloring-colorize
103 (lambda ()
104 (funcall callback done-with-test))))
105 setup))
106
107 (defmacro context-coloring-test-js2-mode (fixture &rest body)
108 "Use FIXTURE as the subject matter for test logic in BODY."
109 `(context-coloring-test-with-fixture
110 ,fixture
111 (require 'js2-mode)
112 (setq js2-mode-show-parse-errors nil)
113 (setq js2-mode-show-strict-warnings nil)
114 (js2-mode)
115 (context-coloring-mode)
116 ,@body))
117
118 (defmacro context-coloring-test-deftest-js-mode (name)
119 "Define an asynchronous test for `js-mode' in the typical
120 format."
121 (let ((test-name (intern (format "context-coloring-test-js-mode-%s" name)))
122 (fixture (format "./fixtures/%s.js" name))
123 (function-name (intern-soft (format "context-coloring-test-js-%s" name))))
124 `(ert-deftest-async ,test-name (done)
125 (context-coloring-test-js-mode
126 ,fixture
127 (lambda (teardown)
128 (unwind-protect
129 (,function-name)
130 (funcall teardown))
131 (funcall done))))))
132
133 (defmacro context-coloring-test-deftest-js2-mode (name)
134 "Define a test for `js2-mode' in the typical format."
135 (let ((test-name (intern (format "context-coloring-test-js2-mode-%s" name)))
136 (fixture (format "./fixtures/%s.js" name))
137 (function-name (intern-soft (format "context-coloring-test-js-%s" name))))
138 `(ert-deftest ,test-name ()
139 (context-coloring-test-js2-mode
140 ,fixture
141 (,function-name)))))
142
143
144 ;;; Assertion functions
145
146 (defmacro context-coloring-test-assert-region (&rest body)
147 "Skeleton for asserting something about the face of points in a
148 region. Provides the free variables `i', `length', `point',
149 `face' and `actual-level'."
150 `(let ((i 0)
151 (length (- end start)))
152 (while (< i length)
153 (let* ((point (+ i start))
154 (face (get-text-property point 'face))
155 actual-level)
156 ,@body)
157 (setq i (+ i 1)))))
158
159 (defun context-coloring-test-assert-region-level (start end level)
160 "Assert that all points in the range [START, END) are of level
161 LEVEL."
162 (context-coloring-test-assert-region
163 (when (not (when face
164 (let* ((face-string (symbol-name face))
165 (matches (string-match
166 context-coloring-level-face-regexp
167 face-string)))
168 (when matches
169 (setq actual-level (string-to-number
170 (substring face-string
171 (match-beginning 1)
172 (match-end 1))))
173 (= level actual-level)))))
174 (ert-fail (format (concat "Expected level in region [%s, %s), "
175 "which is \"%s\", to be %s; "
176 "but at point %s, it was %s")
177 start end
178 (buffer-substring-no-properties start end) level
179 point actual-level)))))
180
181 (defun context-coloring-test-assert-region-face (start end expected-face)
182 "Assert that all points in the range [START, END) have the face
183 EXPECTED-FACE."
184 (context-coloring-test-assert-region
185 (when (not (eq face expected-face))
186 (ert-fail (format (concat "Expected face in region [%s, %s), "
187 "which is \"%s\", to be %s; "
188 "but at point %s, it was %s")
189 start end
190 (buffer-substring-no-properties start end) expected-face
191 point face)))))
192
193 (defun context-coloring-test-assert-region-comment-delimiter (start end)
194 "Assert that all points in the range [START, END) have
195 `font-lock-comment-delimiter-face'."
196 (context-coloring-test-assert-region-face
197 start end 'font-lock-comment-delimiter-face))
198
199 (defun context-coloring-test-assert-region-comment (start end)
200 "Assert that all points in the range [START, END) have
201 `font-lock-comment-face'."
202 (context-coloring-test-assert-region-face
203 start end 'font-lock-comment-face))
204
205 (defun context-coloring-test-assert-region-string (start end)
206 "Assert that all points in the range [START, END) have
207 `font-lock-string-face'."
208 (context-coloring-test-assert-region-face
209 start end 'font-lock-string-face))
210
211 (defun context-coloring-test-assert-message (expected buffer)
212 "Assert that BUFFER has message EXPECTED."
213 (when (null (get-buffer buffer))
214 (ert-fail
215 (format
216 (concat
217 "Expected buffer `%s' to have message \"%s\", "
218 "but the buffer did not have any messages.")
219 buffer expected)))
220 (with-current-buffer buffer
221 (let ((messages (split-string
222 (buffer-substring-no-properties
223 (point-min)
224 (point-max))
225 "\n")))
226 (let ((message (car (nthcdr (- (length messages) 2) messages))))
227 (when (not (equal message expected))
228 (ert-fail
229 (format
230 (concat
231 "Expected buffer `%s' to have message \"%s\", "
232 "but instead it was \"%s\"")
233 buffer expected
234 message)))))))
235
236 (defun context-coloring-test-assert-no-message (buffer)
237 "Assert that BUFFER has no message."
238 (when (get-buffer buffer)
239 (ert-fail (format (concat "Expected buffer `%s' to have no messages, "
240 "but it did: `%s'")
241 buffer
242 (with-current-buffer buffer
243 (buffer-string))))))
244
245 (defun context-coloring-test-kill-buffer (buffer)
246 "Kill BUFFER if it exists."
247 (if (get-buffer buffer) (kill-buffer buffer)))
248
249 (defun context-coloring-test-assert-face (level foreground)
250 "Assert that a face for LEVEL exists and that its `:foreground'
251 is FOREGROUND."
252 (let* ((face (context-coloring-face-symbol level))
253 actual-foreground)
254 (when (not face)
255 (ert-fail (format (concat "Expected face for level `%s' to exist; "
256 "but it didn't")
257 level)))
258 (setq actual-foreground (face-attribute face :foreground))
259 (when (not (string-equal foreground actual-foreground))
260 (ert-fail (format (concat "Expected face for level `%s' "
261 "to have foreground `%s'; but it was `%s'")
262 level
263 foreground actual-foreground)))))
264
265
266 ;;; The tests
267
268 (ert-deftest context-coloring-test-unsupported-mode ()
269 (context-coloring-test-with-fixture
270 "./fixtures/function-scopes.js"
271 (context-coloring-mode)
272 (context-coloring-test-assert-message
273 "Context coloring is not available for this major mode"
274 "*Messages*")))
275
276 (ert-deftest context-coloring-test-set-colors ()
277 ;; This test has an irreversible side-effect in that it defines faces beyond
278 ;; 7. Faces 0 through 7 are reset to their default states, so it might not
279 ;; matter, but be aware anyway.
280 (context-coloring-set-colors
281 "#000000"
282 "#111111"
283 "#222222"
284 "#333333"
285 "#444444"
286 "#555555"
287 "#666666"
288 "#777777"
289 "#888888"
290 "#999999")
291 (context-coloring-test-assert-face 0 "#000000")
292 (context-coloring-test-assert-face 1 "#111111")
293 (context-coloring-test-assert-face 2 "#222222")
294 (context-coloring-test-assert-face 3 "#333333")
295 (context-coloring-test-assert-face 4 "#444444")
296 (context-coloring-test-assert-face 5 "#555555")
297 (context-coloring-test-assert-face 6 "#666666")
298 (context-coloring-test-assert-face 7 "#777777")
299 (context-coloring-test-assert-face 8 "#888888")
300 (context-coloring-test-assert-face 9 "#999999"))
301
302 (defvar context-coloring-test-theme-index 0
303 "Unique index for unique theme names.")
304
305 (defun context-coloring-test-get-next-theme ()
306 "Return a unique symbol for a throwaway theme."
307 (prog1
308 (intern (format "context-coloring-test-theme-%s"
309 context-coloring-test-theme-index))
310 (setq context-coloring-test-theme-index
311 (+ context-coloring-test-theme-index 1))))
312
313 (defun context-coloring-test-assert-theme-definedp (settings &optional negate)
314 "Assert that `context-coloring-theme-definedp' returns t for a
315 theme with SETTINGS (or the inverse if NEGATE is non-nil)."
316 (let ((theme (context-coloring-test-get-next-theme)))
317 (put theme 'theme-settings settings)
318 (when (funcall (if negate 'identity 'not) (context-coloring-theme-definedp theme))
319 (ert-fail (format (concat "Expected theme `%s' with settings `%s' "
320 "%sto be considered to have defined a level, "
321 "but it %s.")
322 theme settings
323 (if negate "not " "")
324 (if negate "was" "wasn't"))))))
325
326 (defun context-coloring-test-assert-not-theme-definedp (&rest arguments)
327 "Assert that `context-coloring-theme-definedp' does not return
328 t for a theme with SETTINGS."
329 (apply 'context-coloring-test-assert-theme-definedp (append arguments '(t))))
330
331 (ert-deftest context-coloring-test-theme-definedp ()
332 (context-coloring-test-assert-theme-definedp
333 '((theme-face context-coloring-level-0-face)))
334 (context-coloring-test-assert-theme-definedp
335 '((theme-face face)
336 (theme-face context-coloring-level-0-face)))
337 (context-coloring-test-assert-theme-definedp
338 '((theme-face context-coloring-level-0-face)
339 (theme-face face)))
340 (context-coloring-test-assert-not-theme-definedp
341 '((theme-face face)))
342 )
343
344 (defun context-coloring-test-assert-theme-highest-level (settings expected-level)
345 (let (theme)
346 (put theme 'theme-settings settings)
347 (let ((highest-level (context-coloring-theme-highest-level theme)))
348 (when (not (eq highest-level expected-level))
349 (ert-fail (format (concat "Expected theme with settings `%s' "
350 "to have a highest level of `%s', "
351 "but it was %s.")
352 settings
353 expected-level
354 highest-level))))))
355
356 (ert-deftest context-coloring-test-theme-highest-level ()
357 (context-coloring-test-assert-theme-highest-level
358 '((theme-face foo))
359 -1)
360 (context-coloring-test-assert-theme-highest-level
361 '((theme-face context-coloring-level-0-face))
362 0)
363 (context-coloring-test-assert-theme-highest-level
364 '((theme-face context-coloring-level-1-face))
365 1)
366 (context-coloring-test-assert-theme-highest-level
367 '((theme-face context-coloring-level-1-face)
368 (theme-face context-coloring-level-0-face))
369 1)
370 (context-coloring-test-assert-theme-highest-level
371 '((theme-face context-coloring-level-0-face)
372 (theme-face context-coloring-level-1-face))
373 1)
374 )
375
376 (defmacro context-coloring-test-deftest-define-theme (name &rest body)
377 (declare (indent defun))
378 (let ((deftest-name (intern (format "context-coloring-test-define-theme-%s" name))))
379 `(ert-deftest ,deftest-name ()
380 (context-coloring-test-kill-buffer "*Warnings*")
381 (let ((theme (context-coloring-test-get-next-theme)))
382 (unwind-protect
383 (progn
384 ,@body)
385 ;; Always cleanup.
386 (disable-theme theme)
387 (context-coloring-set-colors-default))))))
388
389 (defun context-coloring-test-deftheme (theme)
390 (eval (macroexpand `(deftheme ,theme))))
391
392 (context-coloring-test-deftest-define-theme additive
393 (context-coloring-test-deftheme theme)
394 (context-coloring-define-theme
395 theme
396 :colors '("#aaaaaa"
397 "#bbbbbb"))
398 (context-coloring-test-assert-no-message "*Warnings*")
399 (enable-theme theme)
400 (context-coloring-test-assert-no-message "*Warnings*")
401 (context-coloring-test-assert-face 0 "#aaaaaa")
402 (context-coloring-test-assert-face 1 "#bbbbbb"))
403
404 (defun context-coloring-test-assert-defined-warning (theme)
405 (context-coloring-test-assert-message
406 (format (concat "Warning (emacs): Context coloring colors for theme "
407 "`%s' are already defined")
408 theme)
409 "*Warnings*"))
410
411 (context-coloring-test-deftest-define-theme unintentional-override
412 (context-coloring-test-deftheme theme)
413 (custom-theme-set-faces
414 theme
415 '(context-coloring-level-0-face ((t (:foreground "#aaaaaa"))))
416 '(context-coloring-level-1-face ((t (:foreground "#bbbbbb")))))
417 (context-coloring-define-theme
418 theme
419 :colors '("#cccccc"
420 "#dddddd"))
421 (context-coloring-test-assert-defined-warning theme)
422 (context-coloring-test-kill-buffer "*Warnings*")
423 (enable-theme theme)
424 (context-coloring-test-assert-defined-warning theme)
425 (context-coloring-test-assert-face 0 "#cccccc")
426 (context-coloring-test-assert-face 1 "#dddddd"))
427
428 (context-coloring-test-deftest-define-theme intentional-override
429 (context-coloring-test-deftheme theme)
430 (custom-theme-set-faces
431 theme
432 '(context-coloring-level-0-face ((t (:foreground "#aaaaaa"))))
433 '(context-coloring-level-1-face ((t (:foreground "#bbbbbb")))))
434 (context-coloring-define-theme
435 theme
436 :override t
437 :colors '("#cccccc"
438 "#dddddd"))
439 (context-coloring-test-assert-no-message "*Warnings*")
440 (enable-theme theme)
441 (context-coloring-test-assert-no-message "*Warnings*")
442 (context-coloring-test-assert-face 0 "#cccccc")
443 (context-coloring-test-assert-face 1 "#dddddd"))
444
445 (context-coloring-test-deftest-define-theme pre-recede
446 (context-coloring-define-theme
447 theme
448 :recede t
449 :colors '("#aaaaaa"
450 "#bbbbbb"))
451 (context-coloring-test-deftheme theme)
452 (custom-theme-set-faces
453 theme
454 '(context-coloring-level-0-face ((t (:foreground "#cccccc"))))
455 '(context-coloring-level-1-face ((t (:foreground "#dddddd")))))
456 (enable-theme theme)
457 (context-coloring-test-assert-no-message "*Warnings*")
458 (context-coloring-test-assert-face 0 "#cccccc")
459 (context-coloring-test-assert-face 1 "#dddddd"))
460
461 (context-coloring-test-deftest-define-theme post-recede
462 (context-coloring-test-deftheme theme)
463 (custom-theme-set-faces
464 theme
465 '(context-coloring-level-0-face ((t (:foreground "#aaaaaa"))))
466 '(context-coloring-level-1-face ((t (:foreground "#bbbbbb")))))
467 (context-coloring-define-theme
468 theme
469 :recede t
470 :colors '("#cccccc"
471 "#dddddd"))
472 (context-coloring-test-assert-no-message "*Warnings*")
473 (context-coloring-test-assert-face 0 "#aaaaaa")
474 (context-coloring-test-assert-face 1 "#bbbbbb")
475 (enable-theme theme)
476 (context-coloring-test-assert-no-message "*Warnings*")
477 (context-coloring-test-assert-face 0 "#aaaaaa")
478 (context-coloring-test-assert-face 1 "#bbbbbb"))
479
480 (context-coloring-test-deftest-define-theme recede-not-defined
481 (context-coloring-test-deftheme theme)
482 (custom-theme-set-faces
483 theme
484 '(foo-face ((t (:foreground "#ffffff")))))
485 (context-coloring-define-theme
486 theme
487 :recede t
488 :colors '("#aaaaaa"
489 "#bbbbbb"))
490 (context-coloring-test-assert-no-message "*Warnings*")
491 (context-coloring-test-assert-face 0 "#aaaaaa")
492 (context-coloring-test-assert-face 1 "#bbbbbb")
493 (enable-theme theme)
494 (context-coloring-test-assert-no-message "*Warnings*")
495 (context-coloring-test-assert-face 0 "#aaaaaa")
496 (context-coloring-test-assert-face 1 "#bbbbbb"))
497
498 (context-coloring-test-deftest-define-theme unintentional-obstinance
499 (context-coloring-define-theme
500 theme
501 :colors '("#aaaaaa"
502 "#bbbbbb"))
503 (context-coloring-test-deftheme theme)
504 (custom-theme-set-faces
505 theme
506 '(context-coloring-level-0-face ((t (:foreground "#cccccc"))))
507 '(context-coloring-level-1-face ((t (:foreground "#dddddd")))))
508 (enable-theme theme)
509 (context-coloring-test-assert-defined-warning theme)
510 (context-coloring-test-assert-face 0 "#aaaaaa")
511 (context-coloring-test-assert-face 1 "#bbbbbb"))
512
513 (context-coloring-test-deftest-define-theme intentional-obstinance
514 (context-coloring-define-theme
515 theme
516 :override t
517 :colors '("#aaaaaa"
518 "#bbbbbb"))
519 (context-coloring-test-deftheme theme)
520 (custom-theme-set-faces
521 theme
522 '(context-coloring-level-0-face ((t (:foreground "#cccccc"))))
523 '(context-coloring-level-1-face ((t (:foreground "#dddddd")))))
524 (enable-theme theme)
525 (context-coloring-test-assert-no-message "*Warnings*")
526 (context-coloring-test-assert-face 0 "#aaaaaa")
527 (context-coloring-test-assert-face 1 "#bbbbbb"))
528
529 (defun context-coloring-test-js-function-scopes ()
530 (context-coloring-test-assert-region-level 1 9 0)
531 (context-coloring-test-assert-region-level 9 23 1)
532 (context-coloring-test-assert-region-level 23 25 0)
533 (context-coloring-test-assert-region-level 25 34 1)
534 (context-coloring-test-assert-region-level 34 35 0)
535 (context-coloring-test-assert-region-level 35 52 1)
536 (context-coloring-test-assert-region-level 52 66 2)
537 (context-coloring-test-assert-region-level 66 72 1)
538 (context-coloring-test-assert-region-level 72 81 2)
539 (context-coloring-test-assert-region-level 81 82 1)
540 (context-coloring-test-assert-region-level 82 87 2)
541 (context-coloring-test-assert-region-level 87 89 1))
542
543 (context-coloring-test-deftest-js-mode function-scopes)
544 (context-coloring-test-deftest-js2-mode function-scopes)
545
546 (defun context-coloring-test-js-global ()
547 (context-coloring-test-assert-region-level 20 28 1)
548 (context-coloring-test-assert-region-level 28 35 0)
549 (context-coloring-test-assert-region-level 35 41 1))
550
551 (context-coloring-test-deftest-js-mode global)
552 (context-coloring-test-deftest-js2-mode global)
553
554 (defun context-coloring-test-js-block-scopes ()
555 (context-coloring-test-assert-region-level 20 64 1)
556 (setq context-coloring-js-block-scopes t)
557 (context-coloring-colorize)
558 (context-coloring-test-assert-region-level 20 27 1)
559 (context-coloring-test-assert-region-level 27 41 2)
560 (context-coloring-test-assert-region-level 41 42 1)
561 (context-coloring-test-assert-region-level 42 64 2))
562
563 (context-coloring-test-deftest-js2-mode block-scopes)
564
565 (defun context-coloring-test-js-catch ()
566 (context-coloring-test-assert-region-level 20 27 1)
567 (context-coloring-test-assert-region-level 27 51 2)
568 (context-coloring-test-assert-region-level 51 52 1)
569 (context-coloring-test-assert-region-level 52 73 2)
570 (context-coloring-test-assert-region-level 73 101 3)
571 (context-coloring-test-assert-region-level 101 102 1)
572 (context-coloring-test-assert-region-level 102 117 3)
573 (context-coloring-test-assert-region-level 117 123 2))
574
575 (context-coloring-test-deftest-js-mode catch)
576 (context-coloring-test-deftest-js2-mode catch)
577
578 (defun context-coloring-test-js-key-names ()
579 (context-coloring-test-assert-region-level 20 63 1))
580
581 (context-coloring-test-deftest-js-mode key-names)
582 (context-coloring-test-deftest-js2-mode key-names)
583
584 (defun context-coloring-test-js-property-lookup ()
585 (context-coloring-test-assert-region-level 20 26 0)
586 (context-coloring-test-assert-region-level 26 38 1)
587 (context-coloring-test-assert-region-level 38 44 0)
588 (context-coloring-test-assert-region-level 44 52 1)
589 (context-coloring-test-assert-region-level 57 63 0)
590 (context-coloring-test-assert-region-level 63 74 1))
591
592 (context-coloring-test-deftest-js-mode property-lookup)
593 (context-coloring-test-deftest-js2-mode property-lookup)
594
595 (defun context-coloring-test-js-key-values ()
596 (context-coloring-test-assert-region-level 78 79 1))
597
598 (context-coloring-test-deftest-js-mode key-values)
599 (context-coloring-test-deftest-js2-mode key-values)
600
601 (defun context-coloring-test-js-comments-and-strings ()
602 (context-coloring-test-assert-region-comment-delimiter 1 4)
603 (context-coloring-test-assert-region-comment 4 8)
604 (context-coloring-test-assert-region-comment-delimiter 9 12)
605 (context-coloring-test-assert-region-comment 12 19)
606 (context-coloring-test-assert-region-string 20 32)
607 (context-coloring-test-assert-region-level 32 33 0))
608
609 (ert-deftest-async context-coloring-test-js-mode-comments-and-strings (done)
610 (context-coloring-test-js-mode
611 "./fixtures/comments-and-strings.js"
612 (lambda (teardown)
613 (unwind-protect
614 (context-coloring-test-js-comments-and-strings)
615 (funcall teardown))
616 (funcall done))
617 (lambda ()
618 (setq context-coloring-comments-and-strings t))))
619
620 (ert-deftest context-coloring-test-js2-mode-comments-and-strings ()
621 (context-coloring-test-js2-mode
622 "./fixtures/comments-and-strings.js"
623 (setq context-coloring-comments-and-strings t)
624 (context-coloring-colorize)
625 (context-coloring-test-js-comments-and-strings)))
626
627 (provide 'context-coloring-test)
628
629 ;;; context-coloring-test.el ends here