1 ;;; jit-lock-tests.el --- tests for jit-lock
3 ;; Copyright (C) 2016-2017 Free Software Foundation, Inc.
5 ;; Author: Dmitry Gutov <dgutov@yandex.ru>
7 ;; This file is part of GNU Emacs.
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.
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.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
29 (defun jit-lock-tests--setup-buffer ()
30 (setq font-lock-defaults
'(nil t
))
34 (ert-deftest jit-lock-fontify-now-fontifies-a-new-buffer
()
35 (ert-with-test-buffer (:name
"xxx")
36 (jit-lock-tests--setup-buffer)
38 (jit-lock-fontify-now (point-min) (point-max))
39 (should-not (text-property-not-all (point-min) (point-max) 'fontified t
))))
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
))))
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
))
58 (with-silent-modifications
59 (put-text-property (point-min) (point-max) 'fontified t
))
60 (jit-lock-fontify-now (point-min) (point-max))))