]> code.delx.au - gnu-emacs/blob - test/lisp/jit-lock-tests.el
Fix the jit-lock-fontify-now test names
[gnu-emacs] / test / lisp / jit-lock-tests.el
1 ;;; jit-lock-tests.el --- tests for jit-lock
2
3 ;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5 ;; Author: Dmitry Gutov <dgutov@yandex.ru>
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23
24 ;;; Code:
25
26 (require 'jit-lock)
27 (require 'ert-x)
28
29 (defun jit-lock-tests--setup-buffer ()
30 (setq font-lock-defaults '(nil t))
31 (let (noninteractive)
32 (font-lock-mode)))
33
34 (ert-deftest jit-lock-fontify-now-fontifies-a-new-buffer ()
35 (ert-with-test-buffer (:name "xxx")
36 (jit-lock-tests--setup-buffer)
37 (insert "xyz")
38 (jit-lock-fontify-now (point-min) (point-max))
39 (should-not (text-property-not-all (point-min) (point-max) 'fontified t))))
40
41 (ert-deftest jit-lock-fontify-now-mends-the-gaps ()
42 (ert-with-test-buffer (:name "xxx")
43 (jit-lock-tests--setup-buffer)
44 (insert "aaabbbcccddd")
45 (with-silent-modifications
46 (put-text-property 1 4 'fontified t)
47 (put-text-property 7 10 'fontified t))
48 (jit-lock-fontify-now (point-min) (point-max))
49 (should-not (text-property-not-all (point-min) (point-max) 'fontified t))))
50
51 (ert-deftest jit-lock-fontify-now-does-not-refontify-unnecessarily ()
52 (ert-with-test-buffer (:name "xxx")
53 (setq font-lock-defaults
54 (list '(((lambda () (error "Don't call me")))) t))
55 (let (noninteractive)
56 (font-lock-mode))
57 (insert "aaa")
58 (with-silent-modifications
59 (put-text-property (point-min) (point-max) 'fontified t))
60 (jit-lock-fontify-now (point-min) (point-max))))