1 ;;; jit-lock-tests.el --- tests for jit-lock
3 ;; Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
29 (defun jit-lock-tests--setup-buffer ()
30 (setq font-lock-defaults '(nil t))
33 (ert-deftest jit-lock-fontify-now-fontifies-a-new-buffer ()
34 (ert-with-test-buffer (:name "xxx")
35 (jit-lock-tests--setup-buffer)
37 (jit-lock-fontify-now (point-min) (point-max))
38 (should-not (text-property-not-all (point-min) (point-max) 'fontified t))))
40 (ert-deftest jit-lock-fontify-mends-the-gaps ()
41 (ert-with-test-buffer (:name "xxx")
42 (jit-lock-tests--setup-buffer)
43 (insert "aaabbbcccddd")
44 (with-silent-modifications
45 (put-text-property 1 4 'fontified t)
46 (put-text-property 7 10 'fontified t))
47 (jit-lock-fontify-now (point-min) (point-max))
48 (should-not (text-property-not-all (point-min) (point-max) 'fontified t))))
50 (ert-deftest jit-lock-does-not-refontify-unnecessarily ()
51 (ert-with-test-buffer (:name "xxx")
52 (setq font-lock-defaults
53 (list '(((lambda () (error "Don't call me")))) t))
56 (with-silent-modifications
57 (put-text-property (point-min) (point-max) 'fontified t))
58 (jit-lock-fontify-now (point-min) (point-max))))